/* ═══════════════════════════════════════════════════════════
   SarfiPay Dashboard Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Dashboard Layout ─────────────────────────────────────── */
.dash-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.dash-sidebar {
    inset-inline-start: 0;
    width: var(--sidebar-width);
    background: var(--background-card);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.dash-sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-bottom: 1px solid var(--border);
}

.dash-sidebar-header img {
    height: 28px;
}

.dash-sidebar-header span {
    font-weight: 800;
    font-size: 1.125rem;
    color: var(--primary);
}

.dash-sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    opacity: 0.6;
    padding: 0 0.75rem;
    margin: 15px 10px 5px;
}

.dash-nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem; /* Perfect alignment spacing */
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    margin-bottom: 4px;
    position: relative;
    overflow: hidden;
    will-change: transform, background-color;
}

.dash-nav-item::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s;
    opacity: 0;
}

.dash-nav-item:hover {
    background: var(--surface-2);
    color: var(--text-primary);
}

.dash-nav-item:active {
    transform: scale(0.97); /* Micro-interaction tap */
}

.dash-nav-item.active {
    background: var(--primary-100);
    color: var(--primary);
    font-weight: 600;
}

.dash-nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
    opacity: 1;
}

[data-theme="dark"] .dash-nav-item.active {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-300);
}

.dash-nav-item .nav-icon {
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dash-nav-item:hover .nav-icon {
    transform: scale(1.1); /* Subtle icon motion */
}

.dash-nav-item .nav-badge {
    margin-inline-start: auto;
    background: var(--error);
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
}

.dash-sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dash-sidebar-footer .user-info {
    flex: 1;
    min-width: 0;
}

.dash-sidebar-footer .user-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.dash-sidebar-footer .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Main Content ─────────────────────────────────────────── */
.dash-main {
    flex: 1;
    margin-inline-start: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ────────────────────────────────────────────────── */
.dash-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    min-height: 64px;
    background: var(--background-modal);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
}

.dash-topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dash-topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.dash-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dash-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    background: var(--surface-2);
    border: 1px solid var(--border);
    width: 280px;
    transition: all var(--duration-fast);
}

.dash-search:focus-within {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.dash-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    color: var(--text-primary);
    width: 100%;
}

.theme-toggle {
    background: var(--background-secondary);
    cursor: pointer;
    transition: all var(--duration-fast);
    font-size: 1rem;
}

.theme-toggle:hover {
    background: var(--surface-3);
}

.notification-btn {
    position: relative;
}

.notification-dot {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error);
    border: 2px solid var(--surface);
}

/* ── Dashboard Content ────────────────────────────────────── */
.dash-content {
    flex: 1;
    padding: 1.5rem;
}

/* ── Quick Actions ────────────────────────────────────────── */
.dash-quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--duration) var(--ease-out);
    text-decoration: none;
    color: var(--text-primary);
}

.quick-action-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--teal);
}

.quick-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.qa-send .quick-action-icon {
    background: var(--primary-100);
}

.qa-recharge .quick-action-icon {
    background: var(--teal-100);
}

.qa-pay .quick-action-icon {
    background: var(--gold-light);
}

.qa-more .quick-action-icon {
    background: var(--gray-100);
}

.quick-action-btn .caption {
    font-weight: 600;
}

/* ── Stat Cards Grid ──────────────────────────────────────── */
.dash-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dash-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--duration) var(--ease-out);
}

.dash-stat-card:hover {
    box-shadow: var(--shadow);
}

.dash-stat-card.accent-primary {
    border-inline-start: 4px solid var(--primary);
}

.dash-stat-card.accent-teal {
    border-inline-start: 4px solid var(--teal);
}

.dash-stat-card.accent-gold {
    border-inline-start: 4px solid var(--gold);
}

.dash-stat-card.accent-error {
    border-inline-start: 4px solid var(--error);
}

.dash-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.dash-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.dash-stat-value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.dash-stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.dash-stat-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
}

.dash-stat-change.up {
    background: var(--success-light);
    color: var(--success);
}

.dash-stat-change.down {
    background: var(--error-light);
    color: var(--error);
}

/* ── Chart Area ───────────────────────────────────────────── */
.dash-chart-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dash-chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.dash-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.dash-chart-title {
    font-weight: 700;
    font-size: 1rem;
}

.dash-chart-filters {
    display: flex;
    gap: 4px;
}

.chart-filter-btn {
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    border: none;
    transition: all var(--duration-fast);
}

.chart-filter-btn.active {
    background: var(--primary);
    color: var(--white);
}

.chart-filter-btn:hover:not(.active) {
    background: var(--surface-2);
}

.chart-placeholder {
    height: 240px;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary-100) 0%, var(--teal-100) 100%);
    display: flex;
    align-items: flex-end;
    padding: 1rem;
    gap: 6px;
}

.chart-bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(to top, var(--primary), var(--teal));
    animation: chartGrow 0.8s var(--ease-out) both;
    opacity: 0.8;
    transition: opacity var(--duration-fast);
}

.chart-bar:hover {
    opacity: 1;
}

@keyframes chartGrow {
    from {
        height: 0;
    }
}

/* ── Donut Chart ──────────────────────────────────────────── */
.donut-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.donut-chart {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    position: relative;
    background: conic-gradient(var(--primary) 0deg 140deg,
            var(--teal) 140deg 230deg,
            var(--gold) 230deg 300deg,
            var(--gray-300) 300deg 360deg);
}

.donut-chart::after {
    content: '';
    position: absolute;
    inset: 30%;
    border-radius: 50%;
    background: var(--surface);
}

.donut-legend {
    width: 100%;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 0.375rem 0;
}

.donut-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── Transaction Table ────────────────────────────────────── */
.tx-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dash-tx-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.dash-tx-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.dash-tx-table {
    width: 100%;
    border-collapse: collapse;
}

.dash-tx-table th {
    text-align: start;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.dash-tx-table td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--duration-fast);
}

.dash-tx-table tr:hover td {
    background: var(--surface-2);
}

.dash-tx-table tr:last-child td {
    border-bottom: none;
}

.tx-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tx-user .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.75rem;
}

.tx-amount {
    font-weight: 700;
    font-family: var(--font-mono);
}

.tx-amount.credit {
    color: var(--success);
}

.tx-amount.debit {
    color: var(--error);
}

.tx-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.tx-status.completed {
    background: var(--success-light);
    color: var(--success);
}

.tx-status.pending {
    background: var(--warning-light);
    color: var(--warning);
}

.tx-status.failed {
    background: var(--error-light);
    color: var(--error);
}

.tx-status.cancelled {
    background: var(--gray-100);
    color: var(--gray-500);
}

.tx-status.expired {
    background: var(--gray-200);
    color: var(--text-muted);
}

.tx-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 1024px) {
    .dash-sidebar {
        transform: translateX(-100%);
        width: 280px; /* Compact mobile width */
        max-width: 85vw; /* Safe padding for phones */
    }

    [dir="rtl"] .dash-sidebar {
        transform: translateX(100%);
    }

    .dash-sidebar.open, .dash-sidebar.active {
        transform: translateX(0) !important;
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.15);
    }

    [dir="rtl"] .dash-sidebar.open, [dir="rtl"] .dash-sidebar.active {
        transform: translateX(0) !important;
        box-shadow: -4px 0 32px rgba(0, 0, 0, 0.15);
    }

    [data-theme="dark"] .dash-sidebar.open, [data-theme="dark"] .dash-sidebar.active {
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
    }
    
    [dir="rtl"][data-theme="dark"] .dash-sidebar.open, [dir="rtl"][data-theme="dark"] .dash-sidebar.active {
        box-shadow: -4px 0 32px rgba(0, 0, 0, 0.5);
    }

    .dash-main {
        margin-inline-start: 0;
    }

    .dash-chart-section {
        grid-template-columns: 1fr;
    }

    .dash-search {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .dash-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-tx-table {
        font-size: 0.8125rem;
    }

    .dash-search {
        display: none;
    }
}

/* ── Sidebar Overlay ─────────────────────────────────────── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
    will-change: opacity;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ── Desktop Sidebar Active override prevention ── */
/* Handled by media queries cleanly */

@media (max-width: 480px) {
    .dash-content {
        padding: 1rem;
    }
    .dash-topbar-left {
        gap: 0.5rem;
    }
    .dash-topbar-title {
        font-size: 1.1rem;
    }
    .dash-stats-grid {
        grid-template-columns: 1fr;
    }
    .dash-quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .quick-action-btn {
        padding: 0.75rem;
    }
    .dash-stat-card {
        padding: 1rem;
    }
    .dash-chart-card {
        padding: 1rem;
    }
}

/* ── Standard Modal System ────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 26, 0.4);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: var(--radius-xl);
    box-shadow: 0 40px 100px -20px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border);
}

.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    z-index: 10;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-alt);
    color: var(--text-muted);
    transition: all 0.2s;
    font-size: 1.25rem;
    border: none;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--error-light);
    color: var(--error);
    transform: rotate(90deg);
}

.modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--surface-2);
}

@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end; /* Snap to bottom */
    }
    .modal-card {
        max-height: 90vh;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        transform: translateY(100%);
    }
    .modal-overlay.active .modal-card {
        transform: translateY(0);
    }
    /* Drag Handle */
    .modal-card::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border-strong);
        border-radius: 4px;
        margin: 12px auto 0 auto;
        flex-shrink: 0;
    }
}
/* ──────────────────────────────────────────────────────────
   MERCHANT PORTAL ISOLATION (VUE SEPARÉ)
   ────────────────────────────────────────────────────────── */
.merchant-portal-active {
    --primary: #0f172a; /* Deeper Indigo/Slate for Business */
    --primary-rgb: 15, 23, 42;
    --grad-primary: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    background-color: #f8fafc;
}

[data-theme="dark"] .merchant-portal-active {
    --primary: #38bdf8; /* Sky Blue for Dark Theme Business */
    --primary-rgb: 56, 189, 248;
    --grad-primary: linear-gradient(135deg, #0369a1 0%, #0c4a6e 100%);
    background-color: #020617;
}

.merchant-portal-active .dash-sidebar {
    border-inline-end: 2px solid rgba(var(--primary-rgb), 0.1);
}

.merchant-portal-active .dash-nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    border-inline-start: 4px solid var(--primary);
    border-radius: 0 12px 12px 0;
}

.merchant-portal-active .dash-topbar {
    border-bottom: 2px solid rgba(var(--primary-rgb), 0.05);
    background: rgba(var(--background-card-rgb), 0.8);
    backdrop-filter: blur(20px);
}

.merchant-portal-active .return-account {
    margin-top: 2rem;
    border: 1px dashed var(--border);
    background: rgba(var(--primary-rgb), 0.03);
}

.merchant-portal-active .return-account:hover {
    background: var(--primary);
    color: white !important;
}

/* Fix for logo in merchant portal */
.merchant-portal-active .logo-text span {
    color: var(--primary);
    font-weight: 900;
    margin-left: 4px;
}
/* ── Toasts ──────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid var(--primary);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warning); }

@keyframes toastIn {
    from { transform: translateY(100%) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
