/* =============================================
   D-Medic Instruments S.A.R.L. - Invoice Management System
   Branding: #2d5f7a | #7EC8E3 | #1a3a4a | #ffffff
   Font: Montserrat
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

:root {
    --dmedic-primary: #2d5f7a;
    --dmedic-secondary: #a8d4e6;
    --dmedic-blue: #7EC8E3;
    --dmedic-accent: #4a9bc7;
    --dmedic-white: #ffffff;
    --dmedic-light-bg: #f0f6f9;
    --dmedic-dark: #1a3a4a;
    --dmedic-sidebar-bg: #1a3a4a;
    --dmedic-sidebar-active: #7EC8E3;
    --font-primary: 'Montserrat', sans-serif;
}

* {
    font-family: var(--font-primary);
}

body {
    background: var(--dmedic-light-bg);
    color: var(--dmedic-primary);
    font-weight: 400;
    font-size: 14px;
}

/* =============================================
   SIDEBAR
   ============================================= */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

#sidebar {
    min-width: 260px;
    max-width: 260px;
    background: var(--dmedic-sidebar-bg);
    color: var(--dmedic-secondary);
    transition: all 0.3s;
    min-height: 100vh;
}

#sidebar.active {
    margin-left: -260px;
}

#sidebar .sidebar-header {
    padding: 20px;
    background: #fff;
    border-bottom: 1px solid #e8e8ec;
    text-align: center;
}

.dmedic-logo {
    max-width: 160px;
    height: auto;
    display: block;
    margin: 0 auto;
}

#sidebar ul.components {
    padding: 16px 0;
}

#sidebar ul li {
    padding: 0;
}

#sidebar ul li a {
    padding: 12px 20px;
    font-size: 0.88em;
    display: block;
    color: #a0a0a8;
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: all 0.2s;
    font-weight: 500;
}

#sidebar ul li a:hover {
    color: var(--dmedic-white);
    background: rgba(26, 93, 180, 0.15);
    border-left-color: var(--dmedic-blue);
}

#sidebar ul li a i {
    margin-right: 10px;
    font-size: 1.1em;
    width: 20px;
    text-align: center;
}

#sidebar ul li.active a {
    color: var(--dmedic-white);
    background: rgba(26, 93, 180, 0.25);
    border-left-color: var(--dmedic-blue);
}

#sidebar ul li.active a i {
    color: var(--dmedic-blue);
}

#sidebar .sidebar-heading {
    padding: 14px 20px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #6b6b75;
    margin-top: 10px;
    pointer-events: none;
    font-weight: 600;
    border-top: 1px solid #2d2d35;
}

/* =============================================
   CONTENT AREA
   ============================================= */
#content {
    width: 100%;
    padding: 0;
    min-height: 100vh;
    transition: all 0.3s;
    background: var(--dmedic-light-bg);
}

/* Top Navbar */
.top-navbar {
    padding: 14px 24px;
    background: var(--dmedic-white);
    border-bottom: 1px solid #e8e8ec;
    margin-bottom: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.top-navbar .navbar-brand {
    color: var(--dmedic-primary);
    font-weight: 600;
    font-size: 1.15rem;
}

/* =============================================
   CARDS
   ============================================= */
.card {
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 24px;
    background: var(--dmedic-white);
}

.card-header {
    background: var(--dmedic-white);
    border-bottom: 1px solid #f0f0f4;
    padding: 16px 20px;
    font-weight: 600;
    border-radius: 8px 8px 0 0 !important;
    color: var(--dmedic-primary);
    font-size: 0.95rem;
}

.card-header i {
    color: var(--dmedic-blue);
    margin-right: 8px;
}

/* =============================================
   STAT CARDS - DVista Style
   ============================================= */
.stat-card {
    padding: 24px 20px;
    border-radius: 8px;
    color: var(--dmedic-white);
    position: relative;
    overflow: hidden;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3.5rem;
    opacity: 0.12;
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card.primary { background: linear-gradient(135deg, #57565b 0%, #3d3d42 100%); }
.stat-card.blue { background: linear-gradient(135deg, #1a5db4 0%, #144a8e 100%); }
.stat-card.gold { background: linear-gradient(135deg, #7EC8E3 0%, #4a9bc7 100%); color: #2d2d30; }
.stat-card.gold .stat-label { opacity: 0.7; }
.stat-card.light { background: linear-gradient(135deg, #f5f6f8 0%, #e8e8ec 100%); color: var(--dmedic-primary); border: 1px solid #e0e0e5; }
.stat-card.light .stat-label { opacity: 0.6; color: var(--dmedic-primary); }
.stat-card.success { background: linear-gradient(135deg, #2d8a4e 0%, #1f6b3a 100%); }
.stat-card.danger { background: linear-gradient(135deg, #b83b3b 0%, #8f2d2d 100%); }

/* =============================================
   TABLES
   ============================================= */
.table-container {
    background: var(--dmedic-white);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}

.table thead th {
    background: #f8f9fb;
    border-bottom: 2px solid #e8e8ec;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #7a7a82;
    padding: 14px 16px;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    color: var(--dmedic-primary);
}

.table tbody tr:hover {
    background: #f8f9fb;
}

/* =============================================
   STATUS BADGES - DVista Style
   ============================================= */
.status-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-draft { background: #f0f0f4; color: #6b6b75; border: 1px solid #e0e0e5; }
.status-sent { background: rgba(26, 93, 180, 0.1); color: var(--dmedic-blue); border: 1px solid rgba(26, 93, 180, 0.2); }
.status-paid { background: rgba(45, 138, 78, 0.1); color: #2d8a4e; border: 1px solid rgba(45, 138, 78, 0.2); }
.status-overdue { background: rgba(184, 59, 59, 0.1); color: #b83b3b; border: 1px solid rgba(184, 59, 59, 0.2); }
.status-cancelled { background: #f0f0f4; color: #9a9aa0; border: 1px solid #e0e0e5; text-decoration: line-through; }
.status-accepted { background: rgba(26, 93, 180, 0.1); color: var(--dmedic-blue); border: 1px solid rgba(26, 93, 180, 0.2); }
.status-rejected { background: rgba(184, 59, 59, 0.1); color: #b83b3b; border: 1px solid rgba(184, 59, 59, 0.2); }
.status-converted { background: rgba(45, 138, 78, 0.1); color: #2d8a4e; border: 1px solid rgba(45, 138, 78, 0.2); }
.status-applied { background: rgba(26, 93, 180, 0.1); color: var(--dmedic-blue); border: 1px solid rgba(26, 93, 180, 0.2); }
.status-void { background: #f0f0f4; color: #9a9aa0; border: 1px solid #e0e0e5; }
.status-notpaid { background: rgba(184, 59, 59, 0.15); color: #b83b3b; border: 1px solid rgba(184, 59, 59, 0.3); font-weight: 700; font-size: 0.85rem; padding: 6px 18px; }

/* =============================================
   DVista INVOICE DESIGN - Print & Preview
   ============================================= */
.dvista-invoice {
    background: var(--dmedic-white);
    border-radius: 0;
    padding: 50px 55px;
    max-width: 900px;
    margin: 0 auto;
}

.dvista-invoice-header {
    margin-bottom: 35px;
}

.dvista-invoice-header .invoice-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--dmedic-primary);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.dvista-invoice-header .invoice-number {
    font-size: 1.1rem;
    color: var(--dmedic-blue);
    font-weight: 600;
    letter-spacing: 1px;
}

.dvista-invoice-header .invoice-number span {
    color: var(--dmedic-primary);
    font-weight: 400;
}

.dvista-billing-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 35px;
    gap: 40px;
}

.dvista-billing-block {
    flex: 1;
}

.dvista-billing-block .billing-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #9a9aa0;
    font-weight: 600;
    margin-bottom: 10px;
}

.dvista-billing-block .billing-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dmedic-primary);
    margin-bottom: 6px;
}

.dvista-billing-block .billing-detail {
    font-size: 0.82rem;
    color: #7a7a82;
    line-height: 1.7;
}

.dvista-invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.dvista-invoice-table thead th {
    background: var(--dmedic-primary);
    color: var(--dmedic-white);
    padding: 14px 16px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
}

.dvista-invoice-table thead th:first-child {
    text-align: left;
    padding-left: 20px;
}

.dvista-invoice-table thead th:last-child {
    text-align: right;
    padding-right: 20px;
}

.dvista-invoice-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f4;
    font-size: 0.88rem;
    color: var(--dmedic-primary);
}

.dvista-invoice-table tbody td:first-child {
    padding-left: 20px;
}

.dvista-invoice-table tbody td:last-child {
    text-align: right;
    padding-right: 20px;
    font-weight: 600;
}

.dvista-invoice-table tbody tr:last-child td {
    border-bottom: 2px solid var(--dmedic-primary);
}

/* Totals Section */
.dvista-totals {
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-top: 0;
}

.dvista-totals .total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    font-size: 0.9rem;
    color: #7a7a82;
}

.dvista-totals .total-row.divider {
    border-top: 1px solid #e8e8ec;
    margin-top: 4px;
    padding-top: 12px;
}

.dvista-totals .total-row.grand-total {
    background: var(--dmedic-primary);
    color: var(--dmedic-white);
    padding: 14px 20px;
    font-weight: 700;
    font-size: 1rem;
    margin-top: 4px;
}

.dvista-totals .total-row.grand-total .total-value {
    font-weight: 800;
    font-size: 1.1rem;
}

/* Amount Paid Section */
.dvista-amount-paid {
    margin: 20px 0;
    padding: 14px 20px;
    background: rgba(26, 93, 180, 0.05);
    border-left: 4px solid var(--dmedic-blue);
}

.dvista-amount-paid .paid-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--dmedic-blue);
    font-weight: 600;
    margin-bottom: 4px;
}

.dvista-amount-paid .paid-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dmedic-primary);
}

/* Balance Due Section */
.dvista-balance-due {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(184, 59, 59, 0.06);
    border-left: 4px solid #b83b3b;
    margin-bottom: 25px;
}

.dvista-balance-due .balance-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #b83b3b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dvista-balance-due .balance-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #b83b3b;
}

/* Notes Section */
.dvista-notes-section {
    margin-bottom: 25px;
}

.dvista-notes-section .section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #9a9aa0;
    font-weight: 600;
    margin-bottom: 8px;
}

.dvista-notes-section .notes-content {
    font-size: 0.85rem;
    color: #7a7a82;
    line-height: 1.6;
    padding: 12px 16px;
    background: #fafafb;
    border-radius: 4px;
}

/* Payment History */
.dvista-payment-history {
    margin-bottom: 25px;
}

.dvista-payment-history .section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #9a9aa0;
    font-weight: 600;
    margin-bottom: 12px;
}

.dvista-payment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f4;
    font-size: 0.88rem;
}

.dvista-payment-item .payment-method {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dvista-payment-item .payment-method .bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dmedic-blue);
    flex-shrink: 0;
}

.dvista-payment-item .payment-date {
    color: #9a9aa0;
    font-size: 0.8rem;
}

.dvista-payment-item .payment-amount {
    font-weight: 700;
    color: var(--dmedic-primary);
}

/* Footer Tagline */
.dvista-invoice-footer {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid #e8e8ec;
}

.dvista-invoice-footer .tagline {
    font-size: 0.9rem;
    color: var(--dmedic-blue);
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.dvista-invoice-footer .brand-name {
    font-size: 0.75rem;
    color: #9a9aa0;
    margin-top: 4px;
    letter-spacing: 1px;
}

/* =============================================
   LINE ITEMS (Forms)
   ============================================= */
.line-items-table input,
.line-items-table select {
    border: 1px solid #e0e0e5;
    border-radius: 4px;
    padding: 8px 10px;
    width: 100%;
    font-size: 0.85rem;
    font-family: var(--font-primary);
}

.line-items-table input:focus,
.line-items-table select:focus {
    border-color: var(--dmedic-blue);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(26, 93, 180, 0.12);
}

/* =============================================
   FORMS
   ============================================= */
.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 6px;
    color: var(--dmedic-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--dmedic-blue);
    box-shadow: 0 0 0 3px rgba(26, 93, 180, 0.12);
}

.btn {
    border-radius: 6px;
    font-weight: 600;
    padding: 10px 24px;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.btn-primary { background: var(--dmedic-blue); border-color: var(--dmedic-blue); }
.btn-primary:hover { background: #144a8e; border-color: #144a8e; }

.btn-success { background: #2d8a4e; border-color: #2d8a4e; }
.btn-success:hover { background: #1f6b3a; border-color: #1f6b3a; }

.btn-danger { background: #b83b3b; border-color: #b83b3b; }
.btn-danger:hover { background: #8f2d2d; border-color: #8f2d2d; }

.btn-warning { background: var(--dmedic-blue); border-color: var(--dmedic-blue); color: #2d2d30; }
.btn-warning:hover { background: #4a9bc7; border-color: #4a9bc7; color: #2d2d30; }

.btn-outline-primary { border-color: var(--dmedic-blue); color: var(--dmedic-blue); }
.btn-outline-primary:hover { background: var(--dmedic-blue); color: var(--dmedic-white); }

.btn-sm {
    padding: 6px 14px;
    font-size: 0.75rem;
}

/* =============================================
   ALERTS
   ============================================= */
.alert-success {
    background: rgba(45, 138, 78, 0.08);
    border-color: rgba(45, 138, 78, 0.2);
    color: #1f6b3a;
}

.alert-danger {
    background: rgba(184, 59, 59, 0.08);
    border-color: rgba(184, 59, 59, 0.2);
    color: #8f2d2d;
}

/* =============================================
   PRINT STYLES
   ============================================= */
@media print {
    .sidebar, .top-navbar, .btn, .no-print, #sidebarCollapse {
        display: none !important;
    }
    #content { margin: 0 !important; padding: 0 !important; }
    .card { box-shadow: none; border: 1px solid #e0e0e5; }
    body { background: white !important; }
    .dvista-invoice { padding: 30px 40px; }
}

/* =============================================
   PAGE TITLE & HELPERS
   ============================================= */
.page-title {
    font-weight: 700;
    color: var(--dmedic-primary);
    margin-bottom: 24px;
    font-size: 1.4rem;
    letter-spacing: -0.3px;
}

.page-title i {
    color: var(--dmedic-blue);
    margin-right: 10px;
}

.currency-display {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--dmedic-primary);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9a9aa0;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.4;
    color: var(--dmedic-secondary);
}

/* Toggle Button */
#sidebarCollapse {
    background: transparent;
    border: 1px solid #e0e0e5;
    color: var(--dmedic-primary);
    padding: 6px 12px;
}

#sidebarCollapse:hover {
    background: #f5f6f8;
    border-color: var(--dmedic-blue);
    color: var(--dmedic-blue);
}

/* Action Buttons */
.btn-action {
    padding: 5px 10px;
    font-size: 0.78rem;
    margin: 0 2px;
}

/* Footer */
.footer {
    margin-top: 40px;
    border-top: 1px solid #e8e8ec;
    padding: 20px;
}

.footer .text-muted {
    color: #9a9aa0;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar { margin-left: -260px; }
    #sidebar.active { margin-left: 0; }
    .dvista-billing-section { flex-direction: column; gap: 20px; }
}
