/* 
    iSale Premium Design System 
    High-End SaaS Aesthetic Overhaul
*/

:root {
    /* Color Palette */
    --accent: #9333ea;
    --accent-rgb: 147, 51, 234;
    --accent-dark: #7e22ce;
    --accent-light: rgba(147, 51, 234, 0.1);
    
    --bg-base: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-surface-soft: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border-soft: rgba(0, 0, 0, 0.04);
    --border-rich: rgba(0, 0, 0, 0.08);

    /* Elevation System */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-premium: rgba(0, 0, 0, 0.04) 0px 5px 22px, rgba(0, 0, 0, 0.03) 0px 0px 0px 0.5px;
    
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;
}

/* Core Overrides */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(var(--accent-rgb), 0.02) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(var(--accent-rgb), 0.02) 0px, transparent 50%);
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb), 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--accent-rgb), 0.2); }

/* Typography Refinement */
h1, h2, h3, h4 {
    letter-spacing: -0.025em;
    font-weight: 800;
}

/* Premium Sidebar */
.sidebar {
    width: 280px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    padding: 2.5rem 1.25rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 2.5rem;
    padding: 0 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.375rem;
}

nav {
    margin-bottom: 3rem;
}

.nav-link:hover {
    background: var(--bg-surface-soft);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 8px 20px -6px rgba(var(--accent-rgb), 0.4);
}

.nav-link i {
    width: 18px;
    height: 18px;
}

/* Main Content Wrapper */
.main-content {
    margin-left: 280px;
    padding: 2rem 3rem;
    width: calc(100% - 280px);
}

/* Component: Modern Card */
.glass {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-premium);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel {
    border-radius: var(--radius-lg);
    padding: 2rem;
}

/* Layout Utilities: Spatial Rhythm */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.content-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* --- Responsive Architecture --- */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .content-row {
        grid-template-columns: 1fr;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 1rem;
    }
}

.mobile-toolbar {
    display: none;
    padding: 1rem;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 40;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 1024px) {
    .mobile-toolbar {
        display: flex;
    }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- Authentication Framework --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: url('/images/auth-bg.png') no-repeat center center fixed;
    background-size: cover;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2.5rem;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .auth-card {
        padding: 2rem 1.5rem;
        border-radius: 1.5rem;
    }
}

.auth-card-wide {
    max-width: 580px;
}

.auth-card .form-label {
    font-weight: 800;
    font-size: 0.7rem;
    color: var(--text-primary);
    opacity: 0.7;
}

.auth-card .form-control {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.05);
}

.auth-card .form-control:focus {
    background: white;
    border-color: var(--accent);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: rgba(0, 0, 0, 0.08) 0px 10px 40px -10px, rgba(0, 0, 0, 0.03) 0px 0px 0px 0.5px;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.06em;
    margin: 0.25rem 0;
    color: var(--text-primary);
}

/* --- Intelligence Dashboard v3 --- */

.intelligence-card {
    position: relative;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.intelligence-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.status-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.75rem;
    position: relative;
}

.status-pulse::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.4;
    animation: statusPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(2.5); opacity: 0; }
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 700;
    border-radius: 0.75rem;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Inputs & Form Logic */
.form-label {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: block;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1.125rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

/* Button Refinement */
.btn {
    padding: 0.875rem 1.5rem;
    border-radius: 0.875rem;
    font-weight: 700;
    font-size: 0.9375rem;
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 10px 20px -10px var(--accent);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 12px 24px -8px var(--accent);
    transform: translateY(-1px);
}

/* Page reveal animation */
@keyframes revealUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.reveal {
    animation: revealUp 0.6s cubic-bezier(0.2, 1, 0.3, 1) forwards;
}

/* Custom Table Styles */
.table-container {
    overflow: hidden;
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(var(--accent-rgb), 0.02);
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.725rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.075em;
    border-bottom: 1px solid var(--border-soft);
}

td {
    padding: 1.5rem 1.75rem;
    border-top: 1px solid var(--border-soft);
    font-size: 0.9375rem;
}

.badge {
    padding: 0.375rem 0.8125rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid transparent;
}

.badge-success { background: rgba(var(--success-rgb, 16, 185, 129), 0.1); color: var(--success); }
.badge-danger { background: rgba(var(--danger-rgb, 239, 68, 68), 0.1); color: var(--danger); }
.badge-warning { background: rgba(var(--warning-rgb, 245, 158, 11), 0.1); color: var(--warning); }
.badge-info { background: rgba(var(--accent-rgb), 0.1); color: var(--accent); }

/* --- Global Utilities --- */
.status-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.status-pulse::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.35;
    animation: statusPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 0.35; }
    50% { transform: scale(2.2); opacity: 0; }
}

:root {
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}
