/* ============================================================
   NoriApp — State-of-the-Art Modern Design System
   ============================================================ */

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

:root {
    /* Color Palette — Refined Luxury Corporate Identity (Softened & Lightened Royal Blue) */
    --primary:          #1b3d6c;
    --primary-mid:      #25528f;
    --primary-hover:    #3169b3;
    --primary-dark:     #142e52;
    --primary-light:    #f0f5fc;
    --primary-glow:     rgba(27, 61, 108, 0.25);

    --accent:           #2563eb;
    --accent-hover:     #1d4ed8;
    --accent-light:     #eff6ff;

    --gold:             #d4a017;
    --gold-hover:       #b8860b;
    --gold-light:       #fff8e6;
    --gold-glow:        rgba(212, 160, 23, 0.35);

    --success:          #10b981;
    --success-light:    #ecfdf5;
    --success-glow:     rgba(16, 185, 129, 0.3);

    --danger:           #e11d48;
    --danger-light:     #fff1f2;

    --warning:          #f59e0b;
    --warning-light:    #fffbeb;

    --dark-surface:     #1b3d6c;
    --dark-card:        #25528f;

    --bg-page:          #f4f7fc;
    --card-bg:          #ffffff;
    --border-color:     #d7e4f5;
    --border-hover:     #b8d1f0;

    --text-main:        #0e1726;
    --text-muted:       #64748b;
    --text-light:       #8fa5c5;

    /* Typography */
    --font-family:      'Cairo', 'Tajawal', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

    /* Shadows & Effects */
    --shadow-sm:        0 2px 8px -2px rgba(27, 61, 108, 0.05);
    --shadow-md:        0 8px 24px -4px rgba(27, 61, 108, 0.08);
    --shadow-lg:        0 20px 45px -8px rgba(27, 61, 108, 0.14);
    --shadow-glow:      0 12px 30px -4px var(--primary-glow);
    --shadow-gold:      0 8px 24px -4px var(--gold-glow);

    --glass-bg:         rgba(255, 255, 255, 0.88);
    --glass-border:     rgba(215, 228, 245, 0.8);
    --glass-backdrop:   blur(16px);

    --radius-sm:        8px;
    --radius-md:        14px;
    --radius-lg:        20px;
    --radius-full:      9999px;

    --gradient-hero:    linear-gradient(135deg, #1b3d6c 0%, #25528f 50%, #356fb3 100%);
    --gradient-card:    linear-gradient(145deg, #ffffff 0%, #f8faff 100%);
    --gradient-gold:    linear-gradient(135deg, #d4a017 0%, #f59e0b 100%);

    --transition:       all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Base Setup ────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ── Global: Remove all underlines from navigation & drawer links ── */
.mobile-bottom-nav a,
.mobile-bottom-nav a:hover,
.mobile-bottom-nav a:focus,
.mobile-bottom-nav a:visited,
.mobile-bottom-nav a:active,
.bottom-sheet-drawer a,
.bottom-sheet-drawer a:hover,
.bottom-sheet-drawer a:focus,
.bottom-sheet-drawer a:visited,
.bottom-sheet-drawer a:active,
.drawer-grid-item,
.drawer-grid-item:hover,
.drawer-grid-item:focus,
.drawer-grid-item:visited,
.drawer-grid-item:active,
.drawer-grid-item *,
.bottom-nav-item,
.bottom-nav-item:hover,
.bottom-nav-item:focus,
.bottom-nav-item:visited,
.bottom-nav-item:active {
    text-decoration: none !important;
    -webkit-text-decoration: none !important;
}

html, body {
    font-family: var(--font-family);
    background-color: var(--bg-page);
    background-image: 
        radial-gradient(at 0% 0%, rgba(27, 61, 108, 0.04) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(212, 160, 23, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    direction: rtl;
    text-align: right;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Glassmorphism Panels ─────────────────────────────────── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-backdrop);
    -webkit-backdrop-filter: var(--glass-backdrop);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.glass-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

/* ── Premium Navbar ───────────────────────────────────────── */
.dashboard-nav {
    background: rgba(15, 23, 42, 0.92) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.85rem 0 !important;
    z-index: 1040;
    transition: var(--transition);
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 6px 16px var(--primary-glow);
    transition: var(--transition);
}

.brand-icon:hover {
    transform: rotate(-6deg) scale(1.05);
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.dashboard-nav .nav-link {
    font-weight: 600;
    color: #cbd5e1 !important;
    padding: 0.6rem 1.25rem !important;
    border-radius: var(--radius-full);
    transition: var(--transition);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dashboard-nav .nav-link:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.dashboard-nav .nav-link.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    box-shadow: 0 4px 14px var(--primary-glow);
}

/* User Profile Badge */
.user-profile .avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #334155, #1e293b);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6366f1;
    font-size: 1.1rem;
}

/* ── Hero / Page Banner ────────────────────────────────────── */
.page-banner {
    background: linear-gradient(135deg, #1b3d6c 0%, #25528f 50%, #356fb3 100%);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(27, 61, 108, 0.2);
    border-bottom: 2px solid var(--gold);
    margin-bottom: 2rem;
}

.page-banner::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(212, 160, 23, 0.2) 0%, transparent 70%);
    pointer-events: none;
}

.page-banner h1, .page-banner h2 {
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.page-banner p {
    color: #94a3b8;
    font-size: 1.05rem;
    margin-bottom: 0;
}

/* ── KPI Stat Cards ────────────────────────────────────────── */
.kpi-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.kpi-card .kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.kpi-icon.sales { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.kpi-icon.purchase { background: rgba(244, 63, 94, 0.12); color: var(--danger); }
.kpi-icon.net { background: rgba(79, 70, 229, 0.12); color: var(--primary); }
.kpi-icon.count { background: rgba(14, 165, 233, 0.12); color: var(--accent); }

.kpi-card .kpi-title {
    font-size: 0.88rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

/* ── Data Tables ───────────────────────────────────────────── */
.table-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-custom {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    padding: 1rem 1.25rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.table-custom tbody tr {
    transition: var(--transition);
}

.table-custom tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.03);
}

.table-custom tbody td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.95rem;
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

/* ── Modern Buttons ────────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, #25528f 0%, #2563eb 100%) !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-radius: var(--radius-full) !important;
    padding: 0.6rem 1.5rem !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35) !important;
    transition: var(--transition) !important;
}

.btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.45) !important;
    background: linear-gradient(135deg, #3169b3 0%, #3b82f6 100%) !important;
    color: #ffffff !important;
    opacity: 0.98;
}

.btn-outline-primary {
    border: 2px solid #2563eb !important;
    color: #25528f !important;
    background: transparent !important;
    font-weight: 700 !important;
    border-radius: var(--radius-full) !important;
    padding: 0.55rem 1.4rem !important;
    transition: var(--transition) !important;
}

.btn-outline-primary:hover {
    background: linear-gradient(135deg, #25528f, #2563eb) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35) !important;
}

.btn-gold {
    background: linear-gradient(135deg, #d4a017 0%, #b8860b 100%) !important;
    border: none !important;
    color: #1b3d6c !important;
    font-weight: 800 !important;
    border-radius: var(--radius-full) !important;
    padding: 0.6rem 1.5rem !important;
    box-shadow: 0 4px 14px rgba(212, 160, 23, 0.4) !important;
    transition: var(--transition) !important;
}

.btn-gold:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d4a017 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(212, 160, 23, 0.5) !important;
    color: #000000 !important;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #e11d48) !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-radius: var(--radius-full) !important;
}

.btn-sm {
    padding: 0.35rem 1rem !important;
    font-size: 0.82rem !important;
}

/* ── Badge Pill ────────────────────────────────────────────── */
.badge-pill {
    padding: 0.4em 0.85em;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-sales { background: var(--success-light); color: var(--success); }
.badge-purchase { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* ── Modern Modal Overlays ─────────────────────────────────── */
.modal-backdrop.show {
    opacity: 0.6;
    backdrop-filter: blur(4px);
}

.modal-content {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, #1b3d6c 0%, #25528f 100%);
    color: #ffffff;
    border-bottom: 2px solid var(--gold);
    padding: 1.25rem 1.75rem;
}

.modal-header .btn-close {
    filter: invert(1);
}

.modal-footer {
    background: #edf3fc;
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.75rem;
}

/* ── Form Inputs ───────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: #ffffff;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(26, 111, 212, 0.15);
    outline: none;
}

.form-label {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

/* ── View Switcher Toggle (Table vs Cards) ─────────────────── */
.view-switcher-group {
    background: #edf3fc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 3px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.view-switcher-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-full);
    transition: var(--transition);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.view-switcher-btn:hover {
    color: var(--primary);
}

.view-switcher-btn.active {
    background: linear-gradient(135deg, #25528f 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* ── Mobile Record Card (Universal Responsive Card View) ───── */
.mobile-record-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.mobile-record-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(26, 111, 212, 0.35);
}

.mobile-record-card .card-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.mobile-record-card .card-info-grid {
    background: #f8faff;
    border: 1px solid rgba(215, 228, 245, 0.6);
    border-radius: 10px;
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.85rem;
}

.mobile-record-card .card-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.32rem 0;
    border-bottom: 1px dashed rgba(215, 228, 245, 0.7);
    font-size: 0.85rem;
}

.mobile-record-card .card-info-row:last-child {
    border-bottom: none;
}

.mobile-record-card .card-actions-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.85rem;
}

/* On mobile screens, automatically optimize spacing */
@media (max-width: 768px) {
    .table-responsive {
        margin-bottom: 1rem;
    }
    .view-switcher-group {
        width: 100%;
        justify-content: center;
    }
    .view-switcher-btn {
        flex: 1;
        justify-content: center;
        padding: 0.45rem 0.8rem;
    }

    /* ── Global Mobile Layout ── */
    body {
        padding-bottom: 74px !important;
    }
    footer {
        margin-bottom: 64px !important;
    }
    /* Clean Mobile App Navigation (No underlines) */
    .mobile-bottom-nav a,
    .mobile-bottom-nav button,
    .mobile-bottom-nav span,
    .bottom-sheet-drawer a,
    .bottom-sheet-drawer span,
    .bottom-sheet-drawer small,
    .drawer-grid-item,
    .drawer-grid-item *,
    .bottom-nav-item,
    .bottom-nav-item * {
        text-decoration: none !important;
    }

    .container-fluid { padding-left: 10px !important; padding-right: 10px !important; }
    .page-banner { padding: 2rem 1rem !important; min-height: 120px !important; }
    .page-banner h1 { font-size: 1.4rem !important; }
    .page-banner p { font-size: .8rem !important; }

    /* ── Heading & Toolbar ── */
    h4.fw-bold { font-size: 1.1rem !important; }
    .d-flex.justify-content-between { flex-direction: column !important; gap: .75rem !important; }
    .d-flex.justify-content-between > div:last-child,
    .d-flex.justify-content-between > button:last-child,
    .d-flex.justify-content-between > .d-flex:last-child { width: 100%; }
    .d-flex.justify-content-between > .d-flex:last-child { flex-wrap: wrap; }
    .d-flex.justify-content-between .btn { font-size: .82rem; flex: 1; min-width: 0; }

    /* ── Filter Cards (Invoices stats) ── */
    .col-lg-3.col-sm-6 .card .card-body { padding: .6rem !important; }
    .col-lg-3.col-sm-6 .card .fw-bold.fs-5 { font-size: 1rem !important; }

    /* ── Tables on mobile ── */
    .table th, .table td { padding: .45rem .5rem !important; font-size: .78rem !important; white-space: nowrap; }
    .table th:first-child, .table td:first-child { display: none; } /* hide # column */

    /* ── Modal dialogs ── */
    .modal-panel { width: 100vw !important; border-radius: 0 0 12px 12px !important; }
    .modal-dialog.modal-xl { max-width: 100% !important; margin: 0 !important; }
    .modal-dialog.modal-xl .modal-content { border-radius: 0 !important; }
    .modal-body, .modal-panel-body { padding: 14px !important; }
    .modal-container { max-width: 95vw !important; margin: 0 10px; }

    /* ── Form fields ── */
    .form-control-sm, .form-select-sm { font-size: .82rem !important; }
    .row.g-3 > [class^="col-md-"] { flex: 0 0 100% !important; max-width: 100% !important; }

    /* ── Mobile record cards ── */
    .mobile-record-card { margin-bottom: 0; }
    .mobile-record-card .card-top-bar { gap: .6rem; }
    .card-actions-bar .btn { font-size: .72rem !important; padding: 4px 8px !important; }

    /* ── Home page ── */
    .home-page .row.g-4 > [class^="col-"] { flex: 0 0 50% !important; max-width: 50% !important; }

    /* ── Stat badges ── */
    .badge { font-size: .68rem !important; }

    /* ── NavMenu mobile ── */
    .sidebar { width: 260px !important; }
}

/* Extra small phones */
@media (max-width: 480px) {
    .container-fluid { padding-left: 6px !important; padding-right: 6px !important; }
    .page-banner { padding: 1.2rem .8rem !important; min-height: 90px !important; }
    .page-banner h1 { font-size: 1.15rem !important; }

    /* Stack stats cards */
    .col-lg-3.col-sm-6 { flex: 0 0 50% !important; max-width: 50% !important; }

    /* Mobile cards full width */
    .col-sm-6 { flex: 0 0 100% !important; max-width: 100% !important; }

    /* Actions row */
    .card-actions-bar { flex-wrap: wrap; gap: 4px !important; }

    /* Home page 2-col on tiny */
    .home-page .row.g-4 > [class^="col-"] { flex: 0 0 100% !important; max-width: 100% !important; }
}

/* ── Footer ────────────────────────────────────────────────── */
footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 3rem 0 2rem;
    margin-top: 4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

footer a {
    color: #cbd5e1;
    transition: var(--transition);
}

footer a:hover {
    color: #ffffff;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.4s ease-out forwards;
}