/* ============================================================
   Fincore ERP — Main Stylesheet
   ============================================================ */

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --success:       #10b981;
    --danger:        #ef4444;
    --warning:       #f59e0b;
    --info:          #06b6d4;
    --dark:          #0f172a;
    --sidebar-bg:    #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active:#2563eb;
    --sidebar-text:  #cbd5e1;
    --sidebar-width: 260px;
    --topnav-height: 64px;
    --body-bg:       #f1f5f9;
    --card-bg:       #ffffff;
    --border:        #e2e8f0;
    --text-primary:  #1e293b;
    --text-secondary:#64748b;
    --radius:        12px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:     0 4px 24px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--body-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform .3s ease;
    overflow-y: auto;
}
html[dir="ltr"] .sidebar { left: 0; }
html[dir="rtl"] .sidebar { right: 0; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #334155;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    text-decoration: none;
}
.sidebar-logo i { color: var(--primary); font-size: 1.4rem; }
.sidebar-close { background: none; border: none; color: var(--sidebar-text); font-size: 1.2rem; cursor: pointer; }

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
}
.user-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
    flex-shrink: 0;
}
.user-name { color: #fff; font-weight: 600; font-size: .9rem; }
.user-role { color: var(--sidebar-text); font-size: .75rem; }

/* Sidebar Nav */
.sidebar-nav {
    list-style: none;
    flex: 1;
    padding: 12px 0;
}
.sidebar-nav .nav-section {
    padding: 12px 20px 4px;
    color: #64748b;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    margin: 2px 8px;
    transition: background .15s, color .15s;
    font-size: .9rem;
}
.sidebar-nav li a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav li.active a { background: var(--sidebar-active); color: #fff; }
.sidebar-nav li a i { width: 18px; text-align: center; font-size: .95rem; }

/* ── Sidebar standalone list (Dashboard) ── */
.sidebar-nav-standalone { list-style: none; padding: 6px 0 0; }

/* ── Sidebar collapsible nav-groups ── */
.nav-group {
    position: relative;
    --sidebar-active: var(--gc, #2563eb);
}
.nav-group.grp-open::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0; bottom: 0;
    width: 3px;
    background: var(--gc, #475569);
    border-radius: 2px;
    opacity: .75;
}
.nav-group-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px 7px;
    background: none;
    border: none;
    color: #8da2b7;
    font-size: .9rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: .01em;
    cursor: pointer;
    margin-top: 6px;
    transition: color .15s;
}
.nav-group-btn:hover { color: #cbd5e1; }
.nav-group.grp-open > .nav-group-btn { color: var(--gc, #cbd5e1); }
.nav-group-ico {
    color: var(--gc, #64748b);
    font-size: .88rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    transition: color .15s;
}
.nav-group-label { flex: 1; text-align: start; }
.nav-group-arrow {
    font-size: .55rem;
    opacity: .4;
    transition: transform .25s ease;
    flex-shrink: 0;
}
.nav-group.grp-open > .nav-group-btn .nav-group-arrow {
    transform: rotate(180deg);
    opacity: .75;
}
.nav-group-list {
    list-style: none;
    overflow: hidden;
    max-height: 0;
    transition: max-height .3s ease;
    padding: 0;
}
.nav-group.grp-open > .nav-group-list { max-height: 1000px; }
/* Sub-items — smaller than section header */
.nav-group-list li a { font-size: .84rem; }

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid #334155;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lang-toggle, .logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: .88rem;
    transition: background .15s, color .15s;
}
.lang-toggle:hover { background: var(--sidebar-hover); color: #fff; }
.logout-link:hover { background: rgba(239,68,68,.15); color: #ef4444; }

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topnav-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 1020;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
html[dir="ltr"] .top-navbar { margin-left: var(--sidebar-width); }
html[dir="rtl"] .top-navbar { margin-right: var(--sidebar-width); }

.navbar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: none;
}
.navbar-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    flex: 1;
}
.navbar-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    padding: calc(var(--topnav-height) + 24px) 24px 40px;
    min-height: 100vh;
}
html[dir="ltr"] .main-content { margin-left: var(--sidebar-width); }
html[dir="rtl"] .main-content { margin-right: var(--sidebar-width); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title i { color: var(--primary); }
.card-body { padding: 20px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.stat-card.income::before  { background: var(--success); }
.stat-card.expense::before { background: var(--danger); }
.stat-card.profit::before  { background: var(--primary); }
.stat-card.invoice::before { background: var(--warning); }

.stat-label  { font-size: .8rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-value  { font-size: 1.8rem; font-weight: 800; margin: 6px 0 4px; }
.stat-change { font-size: .8rem; display: flex; align-items: center; gap: 4px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-icon {
    position: absolute;
    top: 16px;
    font-size: 2rem;
    opacity: .08;
}
html[dir="ltr"] .stat-icon { right: 16px; }
html[dir="rtl"] .stat-icon { left: 16px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
.table { margin-bottom: 0; }
.table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .9rem; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-draft     { background: #f1f5f9; color: #64748b; }
.badge-sent      { background: #dbeafe; color: #1d4ed8; }
.badge-paid      { background: #d1fae5; color: #059669; }
.badge-cancelled { background: #fee2e2; color: #dc2626; }
.badge-income    { background: #d1fae5; color: #059669; }
.badge-expense   { background: #fee2e2; color: #dc2626; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 600; font-size: .88rem; color: var(--text-primary); margin-bottom: 6px; }
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: .9rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    outline: none;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: 8px; font-weight: 600; font-size: .88rem; padding: 9px 18px; transition: all .15s; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 800; margin: 0; }
.page-breadcrumb { font-size: .82rem; color: var(--text-secondary); margin-top: 3px; }

/* ============================================================
   FINANCIAL REPORT STYLES
   ============================================================ */
.report-section-title {
    font-weight: 800;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    padding: 10px 16px 6px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.report-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: .9rem;
}
.report-row:hover { background: #f8fafc; }
.report-row.total-row {
    font-weight: 700;
    background: #f1f5f9;
    border-top: 2px solid var(--border);
}
.report-row.grand-total {
    font-weight: 800;
    font-size: 1rem;
    background: var(--primary);
    color: #fff;
    border-radius: 0 0 var(--radius) var(--radius);
}
.positive { color: var(--success); font-weight: 600; }
.negative { color: var(--danger); font-weight: 600; }

/* ============================================================
   INVOICE STYLES
   ============================================================ */
.invoice-preview {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 800px;
    margin: 0 auto;
}
.invoice-header {
    padding: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
}
.invoice-body { padding: 32px; }
.invoice-footer {
    padding: 20px 32px;
    background: #f8fafc;
    border-radius: 0 0 var(--radius) var(--radius);
    border-top: 1px solid var(--border);
}
.invoice-items-table th { background: var(--primary-light); color: var(--primary-dark); }
.invoice-total-box {
    background: #f8fafc;
    border-radius: 10px;
    padding: 16px 20px;
}

/* ============================================================
   INDUSTRY TOOL CARDS
   ============================================================ */
.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}
.metric-value { font-size: 2.2rem; font-weight: 800; }
.metric-label { font-size: .8rem; color: var(--text-secondary); font-weight: 600; margin-top: 4px; }
.gauge-wrapper { position: relative; display: inline-block; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    border-radius: var(--radius);
    border: none;
    font-size: .9rem;
    padding: 14px 18px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-info     { background: #e0f2fe; color: #0c4a6e; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo .logo-icon {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    margin-bottom: 12px;
}
.auth-logo h1 { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.auth-logo p  { font-size: .85rem; color: var(--text-secondary); }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.hero-section {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1e293b 100%);
    color: #fff;
    display: flex;
    align-items: center;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(37,99,235,.2);
    border: 1px solid rgba(37,99,235,.4);
    color: #93c5fd;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 20px;
}
.hero-title { font-size: 3.2rem; font-weight: 900; line-height: 1.15; margin-bottom: 20px; }
.hero-title .highlight { color: #60a5fa; }
.hero-subtitle { font-size: 1.15rem; color: #94a3b8; margin-bottom: 36px; line-height: 1.7; }
.feature-card {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius);
    padding: 24px;
    transition: transform .2s, background .2s;
}
.feature-card:hover { transform: translateY(-4px); background: rgba(255,255,255,.08); }
.feature-icon {
    width: 48px; height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 14px;
}
.pricing-card {
    background: #fff;
    border-radius: 20px;
    padding: 36px;
    text-align: center;
    position: relative;
}
.pricing-card.featured {
    border: 2px solid var(--primary);
    transform: scale(1.05);
}
.pricing-badge {
    position: absolute;
    top: -12px;
    left: 50%; transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
}
.price { font-size: 3rem; font-weight: 900; color: var(--text-primary); }
.price sup { font-size: 1rem; font-weight: 600; vertical-align: top; margin-top: 14px; }
.price-period { font-size: .9rem; color: var(--text-secondary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    html[dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show {
        transform: translateX(0) !important;
    }
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 16px;
        padding-right: 16px;
    }
    .top-navbar {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .navbar-toggle { display: flex !important; }
    .hero-title { font-size: 2rem; }
    .pricing-card.featured { transform: none; }
}

@media (max-width: 575.98px) {
    .auth-card { padding: 24px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .hero-title { font-size: 1.7rem; }
}
