/* 
   AETHER DESIGN SYSTEM - Clean & Light
   Theme: Claro y Limpio | Estética Premium
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    /* Color Palette (HSL) */
    --primary-h: 230;
    --primary-s: 70%;
    --primary-l: 55%;

    --brand-primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --brand-dark: hsl(var(--primary-h), var(--primary-s), 15%);
    --brand-light: hsl(var(--primary-h), 20%, 98%);
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;

    /* Premium Effects */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-blur: blur(12px);
    --premium-gradient: linear-gradient(135deg, hsl(var(--primary-h), var(--primary-s), 95%) 0%, hsl(var(--primary-h), var(--primary-s), 85%) 100%);
    --brand-gradient: linear-gradient(135deg, var(--brand-primary) 0%, hsl(var(--primary-h), var(--primary-s), 40%) 100%);

    /* Spacing & Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

h1, h2, h3, h4, .font-heading {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--brand-primary);
    white-space: nowrap;
    opacity: 1;
    transition: var(--transition);
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    pointer-events: none;
}

.nav-menu {
    flex: 1;
    padding: 1.5rem 0.75rem;
    list-style: none;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
    background: hsl(var(--primary-h), var(--primary-s), 96%);
    color: var(--brand-primary);
}

.nav-link i {
    font-size: 1.25rem;
    min-width: 24px;
    margin-right: 1rem;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0;
}

.sidebar.collapsed .nav-text {
    display: none;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-width: 0; /* Prevents flex children from overflowing */
}

.sidebar.collapsed + .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.app-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.content-body {
    padding: 2rem;
}

/* Dashboard Specific Grid */
.dashboard-stats {
    gap: 1.5rem;
}

.stat-card {
    flex: 1;
    min-width: 240px;
}

.dashboard-grid-main {
    display: flex;
    gap: 1.5rem;
}

.activity-feed-container {
    flex: 2;
}

.quick-actions-container {
    flex: 1;
}

/* UI Components */
.card-premium {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

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

.btn-premium {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--brand-primary);
    color: var(--text-on-primary);
}

.btn-primary:hover {
    background: hsl(var(--primary-h), var(--primary-s), 45%);
}

.badge-finance {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-paid { background: #dcfce7; color: #166534; }
.badge-pending { background: #fee2e2; color: #991b1b; }

/* Utility Classes */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-4 { margin-top: 1.5rem; }

/* Security & Layout Overrides */
.app-container.full-width {
    display: block;
}

.full-width .main-wrapper {
    margin-left: 0 !important;
}

.content-body.p-0 {
    padding: 0 !important;
}

/* Master Fix for Sticky Header with Sticky Navigation Header */
.table-responsive {
    max-height: calc(100vh - (var(--header-height) + 120px));
    overflow-y: auto;
}

/* RESPONSIVE BREAKPOINTS (AETHER FLUIDITY) */

/* Tablet & Smaller Desktop */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    
    .content-body {
        padding: 1.5rem;
    }
}

/* Mobile Devices (The Definitive Fix) */
@media (max-width: 768px) {
    .sidebar {
        left: -100% !important;
        width: 280px !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
        position: fixed;
    }
    
    .sidebar.active {
        left: 0 !important;
    }

    /* Keep text visible on mobile even if toggled */
    .sidebar.active .nav-text,
    .sidebar.active .logo-text {
        display: block !important;
        opacity: 1 !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar.collapsed + .main-wrapper {
        margin-left: 0 !important;
    }

    .app-header {
        padding: 0 1rem;
        background: var(--glass-bg);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
    }

    .content-body {
        padding: 1rem;
    }

    /* Dashboard Wrapping & Grid Stacking */
    .dashboard-stats {
        flex-direction: column !important;
        gap: 1rem;
    }

    .dashboard-grid-main {
        flex-direction: column !important;
        gap: 1rem;
    }

    .card-premium {
        flex: 1 1 100% !important;
        margin-bottom: 0;
        margin-right: 0 !important;
    }

    .header-right .search-box {
        display: none;
    }
}

/* Tables & Data (Already Verified) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table-responsive table {
    min-width: 600px;
}

/* Backdrops & Overlays (Fixed Selector) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 95;
}

.sidebar.active ~ .sidebar-backdrop {
    display: block !important;
}

/* 🧪 AETHER FLUID V8.5.0 - COMPONENT LIBRARY */

.card-premium-stat {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border-left: 4px solid var(--brand-primary);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.stat-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon-primary { background: rgba(var(--primary-h), 100%, 95%); color: var(--brand-primary); }
.stat-icon-success { background: #ecfdf5; color: #10b981; }
.stat-icon-danger { background: #fef2f2; color: #ef4444; }

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

.table-master thead tr,
.table-premium thead tr {
    text-align: left;
    background: var(--bg-main);
    border-bottom: 2px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky !important;
    top: -1px; /* To prevent gap with header */
    z-index: 10;
}

.table-master th {
    padding: 1.25rem 1rem;
}

.table-master td {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.table-master tbody tr:hover {
    background: rgba(0,0,0,0.01);
}

.badge-finance-status {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-finance-success { background: #ecfdf5; color: #059669; border: 1px solid #10b98133; }
.badge-finance-pending { background: #fefce8; color: #854d0e; border: 1px solid #eab30833; }
.badge-finance-danger { background: #fef2f2; color: #991b1b; border: 1px solid #ef444433; }

.breadcrumb-premium {
    list-style: none;
    padding: 0;
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap; /* Master fix for mobile overflow */
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.breadcrumb-premium a {
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.2s;
}

.breadcrumb-premium a:hover {
    color: var(--brand-primary);
}

/* ==========================================================================
   🍞 MODERN TOAST NOTIFICATIONS (V8.5.5 Premium)
   ========================================================================== */
.toast-container-modern {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast-modern {
    pointer-events: auto;
    min-width: 320px;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
    padding: 16px;
    position: relative;
    overflow: hidden;
    animation: toastSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

.toast-modern.toast-fade-out {
    opacity: 0 !important;
    transform: translateX(20px) scale(0.95) !important;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.toast-success .toast-icon { background: #dcfce7; color: #16a34a; }
.toast-error .toast-icon { background: #fee2e2; color: #dc2626; }
.toast-info .toast-icon { background: #e0f2fe; color: #0284c7; }

.toast-msg {
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
    flex-grow: 1;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover { color: var(--text-main); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--brand-primary);
    opacity: 0.4;
    width: 100%;
}

.toast-success .toast-progress { background: #16a34a; }
.toast-error .toast-progress { background: #dc2626; }

.toast-modern.active .toast-progress {
    transition: width 5s linear;
    width: 0;
}
