/* ===================================
   InvoicePro - Main Stylesheet
   =================================== */

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --sidebar-width: 240px;
    --sidebar-bg: #0F172A;
    --sidebar-text: #94A3B8;
    --sidebar-active-bg: #1E293B;
    --sidebar-active-text: #FFFFFF;
    --topbar-height: 60px;
    --bg-main: #F8FAFC;
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.03);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: var(--font);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .3s ease;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #1E293B;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.3px;
}

.brand-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #818CF8);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
    color: #475569;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 20px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: all .15s ease;
    font-weight: 500;
    font-size: 13.5px;
    position: relative;
    margin: 1px 8px;
    border-radius: 8px;
}

.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.nav-item:hover {
    color: #fff;
    background: #1E293B;
}

.nav-item.active {
    color: var(--sidebar-active-text);
    background: var(--primary);
}

.nav-item.active i { color: #fff; }
.text-danger-soft { color: #F87171 !important; }
.text-danger-soft:hover { color: #FCA5A5 !important; background: #1E293B !important; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid #1E293B;
    color: var(--sidebar-text);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin .3s ease;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    display: none;
}

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-date {
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
}

/* ===== PAGE CONTENT ===== */
.page-content { padding: 24px; flex: 1; }

/* ===== CARDS ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: none;
    border-bottom: 1px solid var(--border-color);
    padding: 14px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s ease, transform .2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #EFF6FF; color: var(--info); }
.stat-icon.green  { background: #ECFDF5; color: var(--success); }
.stat-icon.yellow { background: #FFFBEB; color: var(--warning); }
.stat-icon.red    { background: #FEF2F2; color: var(--danger); }
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-icon.gray   { background: #F1F5F9; color: var(--secondary); }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }

/* ===== AVATARS ===== */
.user-avatar-small {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #818CF8);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-avatar-tiny {
    width: 22px; height: 22px;
    background: linear-gradient(135deg, var(--primary), #818CF8);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    margin-right: 4px;
}

.client-avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

/* ===== TABLES ===== */
.table-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table {
    margin: 0;
}

.table thead th {
    background: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 12px 16px;
    white-space: nowrap;
}

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

.table tbody tr:hover { background: #F8FAFC; }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== BUTTONS ===== */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-icon {
    width: 30px; height: 30px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 7px;
    font-size: 12px;
}

/* ===== BADGES ===== */
.badge { font-weight: 600; font-size: 11px; padding: 4px 8px; }

/* ===== INVOICE NUMBER ===== */
.inv-number {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 8px;
    border-radius: 5px;
}

/* ===== FORMS ===== */
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    padding: 8px 12px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
    outline: none;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.breadcrumb { margin: 0; }
.breadcrumb-item { font-size: 12.5px; }

/* ===== INVOICE PRINT STYLES ===== */
.invoice-preview-wrap {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
}

.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 36px; }
.invoice-logo img { max-height: 60px; }
.invoice-meta { text-align: right; }
.invoice-meta h1 { font-size: 32px; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px; }
.party-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); letter-spacing: .5px; margin-bottom: 6px; }
.party-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.party-detail { font-size: 13px; color: var(--text-secondary); line-height: 1.7; }

.invoice-total-section { display: flex; justify-content: flex-end; margin-top: 16px; }
.invoice-total-table { min-width: 280px; }
.invoice-total-table td { padding: 6px 0; font-size: 13.5px; }
.invoice-total-table .grand-total { font-size: 18px; font-weight: 700; color: var(--primary); border-top: 2px solid var(--border-color); }

/* ===== SEARCH & FILTER BAR ===== */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

/* ===== AUTH PAGES ===== */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo .brand-icon { margin: 0 auto 12px; width: 52px; height: 52px; font-size: 22px; }
.auth-logo h1 { font-size: 24px; font-weight: 800; color: var(--text-primary); margin: 0; }
.auth-logo p { color: var(--text-secondary); margin: 4px 0 0; font-size: 13.5px; }

/* ===== INSTALLER ===== */
.install-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0F172A, #312E81);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.install-card {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 640px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0,0,0,.3);
}

.install-header {
    background: linear-gradient(135deg, var(--primary), #818CF8);
    padding: 30px 36px;
    color: #fff;
}

.install-header h1 { font-size: 24px; font-weight: 800; margin: 0; }
.install-header p { margin: 4px 0 0; opacity: .8; font-size: 14px; }

.install-steps {
    display: flex;
    gap: 0;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    overflow-x: auto;
}

.install-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.install-step.active { color: var(--primary); border-bottom-color: var(--primary); }
.install-step.done { color: var(--success); }
.install-step-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
}
.install-step.active .install-step-num { background: var(--primary); color: #fff; }
.install-step.done .install-step-num { background: var(--success); color: #fff; }

.install-body { padding: 32px 36px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .topbar-date { display: none; }
    .page-content { padding: 16px; }
    .stat-value { font-size: 20px; }
    .invoice-parties { grid-template-columns: 1fr; }
    .invoice-header { flex-direction: column; gap: 12px; }
    .invoice-meta { text-align: left; }
}

/* ===== UTILITIES ===== */
.fw-600 { font-weight: 600; }
.text-mono { font-family: var(--font-mono); }
.gap-2 { gap: 8px; }
.rounded-10 { border-radius: 10px; }

/* ===== AVATAR COLORS ===== */
.av-blue   { background: #3B82F6; }
.av-green  { background: #10B981; }
.av-purple { background: #8B5CF6; }
.av-orange { background: #F59E0B; }
.av-red    { background: #EF4444; }
.av-pink   { background: #EC4899; }
.av-teal   { background: #14B8A6; }
.av-indigo { background: #6366F1; }

/* ===== INVOICE ITEMS TABLE ===== */
#itemsTable .item-row td { padding: 8px; }
#itemsTable input { font-size: 13px; }

/* Chart container */
#revenueChart { max-height: 280px; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin: 0; }
    .page-content { padding: 0; }
    .invoice-preview-wrap { border: none; padding: 20px; }
    body { background: #fff; }
}

/* ===== DASHBOARD STAT CARDS ===== */
.dash-stat-card {
    border-radius: var(--radius);
    padding: 20px 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.dash-stat-card::after {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
}
.dash-stat-icon {
    font-size: 28px;
    opacity: .85;
    position: absolute;
    right: 20px; top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}
.dash-stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    opacity: .9;
    margin-bottom: 6px;
}
.dash-stat-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.5px;
}

/* ===== INVOICE LIST DATATABLE STYLE ===== */
.dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}
.dt-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.entries-select {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.btn-excel {
    background: #217346;
    color: #fff;
    border: none;
    padding: 5px 14px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-excel:hover { background: #1a5c38; color: #fff; }

.invoice-actions .btn { padding: 4px 8px; font-size: 12px; margin: 1px; }
