/* ============================================
   GOBVANTAGE INVOICE PORTAL — STYLES
   ============================================ */

:root {
    --navy: #1e3a5f;
    --navy-dark: #152a45;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --muted: #64748b;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --info: #2563eb;
    --hover: #f1f5f9;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ─── NAVBAR ─────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navy);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    gap: 24px;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
    flex-shrink: 0;
}

.navbar-brand img {
    height: 36px;
    width: auto;
    border-radius: 4px;
}

.navbar-brand-text {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgba(255,255,255,0.95);
    line-height: 1.2;
}

.navbar-links {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nav-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.12);
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.navbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.15s;
    border: none;
    background: none;
    cursor: pointer;
}

.navbar-icon-btn:hover {
    color: white;
    background: rgba(255,255,255,0.12);
}

/* ─── MAIN LAYOUT ─────────────────────────────── */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* ─── PAGE HEADER ─────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

/* ─── BUTTONS ──────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--navy);
    color: white;
}
.btn-primary:hover { background: var(--navy-dark); }

.btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--hover); }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #15803d; }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    padding: 6px 10px;
}
.btn-ghost:hover { background: var(--hover); color: var(--text); }

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
}

.btn-lg {
    padding: 10px 22px;
    font-size: 14.5px;
}

/* ─── CARDS ────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* ─── SUMMARY CARDS ───────────────────────────── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.summary-card {
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.summary-card-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    margin-bottom: 6px;
}

.summary-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.summary-card.draft .summary-card-value { color: var(--muted); }
.summary-card.sent .summary-card-value { color: var(--info); }
.summary-card.paid .summary-card-value { color: var(--success); }
.summary-card.overdue .summary-card-value { color: var(--danger); }
.summary-card.cancelled .summary-card-value { color: var(--warning); }

/* ─── FILTER / SORT BAR ───────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-pills {
    display: flex;
    gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
}

.filter-pill {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: none;
    text-decoration: none;
    transition: all 0.15s;
}

.filter-pill:hover { color: var(--text); }

.filter-pill.active {
    background: var(--navy);
    color: white;
}

.sort-select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

/* ─── TABLE ────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

thead th {
    padding: 11px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--hover); }

tbody td {
    padding: 12px 14px;
    font-size: 13.5px;
    color: var(--text);
}

.table-link {
    color: var(--navy);
    text-decoration: none;
    font-weight: 500;
}
.table-link:hover { text-decoration: underline; }

/* ─── STATUS BADGES ────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-overdue { background: #fee2e2; color: #dc2626; }
.badge-cancelled { background: #fef3c7; color: #b45309; }

/* ─── FORMS ────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.form-control::placeholder { color: #94a3b8; }

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ─── LOGIN PAGE ───────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, #2d4a6f 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo {
    height: 80px;
    margin-bottom: 16px;
    border-radius: 8px;
}

.login-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 28px;
}

.login-error {
    background: #fee2e2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

.login-form .form-group {
    text-align: left;
}

.login-form .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 11px;
    font-size: 14px;
    margin-top: 8px;
}

/* ─── INLINE EDIT ──────────────────────────────── */
.edit-toggle {
    display: none;
}
.edit-mode .view-field { display: none; }
.edit-mode .edit-toggle { display: inline; }
.edit-actions { display: none; }
.edit-mode .edit-actions { display: flex; gap: 6px; }

.inline-input {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    background: var(--card-bg);
}
.inline-input:focus {
    outline: none;
    border-color: var(--navy);
}

/* ─── LINE ITEMS TABLE ─────────────────────────── */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.line-items-table th {
    padding: 8px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.line-items-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.line-items-table .col-desc { width: 40%; }
.line-items-table .col-qty { width: 12%; text-align: center; }
.line-items-table .col-rate { width: 16%; text-align: right; }
.line-items-table .col-amount { width: 16%; text-align: right; font-weight: 600; }
.line-items-table .col-action { width: 8%; text-align: center; }

.line-items-table input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    text-align: inherit;
}
.line-items-table input:focus {
    outline: none;
    border-color: var(--navy);
}

.total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    font-weight: 700;
    font-size: 15px;
    color: var(--navy);
}

/* ─── CLIENT DROPDOWN ─────────────────────────── */
.client-dropdown {
    position: relative;
}

.client-dropdown-display {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 14px;
    min-height: 42px;
    display: flex;
    align-items: center;
}

.client-dropdown-display.placeholder {
    color: #94a3b8;
}

.client-dropdown-search {
    display: none;
}

.client-dropdown.open .client-dropdown-search {
    display: block;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.client-dropdown-search input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.client-dropdown.open .client-dropdown-display {
    border-color: var(--navy);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.client-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--navy);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow-md);
}

.client-dropdown.open .client-dropdown-list {
    display: block;
}

.client-dropdown-item {
    padding: 9px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
}

.client-dropdown-item:hover {
    background: var(--hover);
}

.client-dropdown-item .client-name {
    font-weight: 600;
    color: var(--text);
}

.client-dropdown-item .client-code {
    font-size: 11px;
    color: var(--muted);
    background: var(--bg);
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 6px;
}

/* ─── MODAL ────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 20px;
}
.modal-close:hover { background: var(--hover); color: var(--text); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ─── INVOICE VIEW PAGE ────────────────────────── */
.invoice-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.invoice-meta-item {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.invoice-meta-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 4px;
}

.invoice-meta-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.invoice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.invoice-notes {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-top: 24px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
}

.invoice-notes strong {
    color: var(--text);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 6px;
}

/* ─── SETTINGS PAGE ────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.settings-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ─── EMPTY STATE ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* ─── TOAST / ALERT ────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 16px;
}

.alert-success {
    background: #dcfce7;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* ─── RESPONSIVE ───────────────────────────────── */
@media (max-width: 640px) {
    .main-content { padding: 16px 12px; }
    .navbar { padding: 0 12px; gap: 8px; }
    .navbar-brand-text { display: none; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .invoice-actions { flex-direction: column; }
    .invoice-actions .btn { width: 100%; justify-content: center; }
}
