/* app/assets/css/styles.css - Premium Modern Design */
:root {
    /* Color Palette */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    /* Surface & Background */
    --bg-main: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    
    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* Borders & Shadows */
    --border: #e2e8f0;
    --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);
    
    /* Sizing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --header-height: 70px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Auth Layout */
.auth-wrapper {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-main) 0%, var(--primary-light) 100%);
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}
.auth-header i { font-size: 48px; color: var(--primary); margin-bottom: 10px; }
.auth-header h2 { font-weight: 700; color: var(--text-primary); }
.auth-header p { color: var(--text-secondary); margin-top: 5px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 0.875rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 8px;
}
.form-control {
    width: 100%; padding: 12px 16px;
    border: 1px solid var(--border); border-radius: var(--border-radius-sm);
    font-size: 1rem; color: var(--text-primary); font-family: inherit;
    transition: var(--transition); background: var(--bg-main);
}
.form-control:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--surface);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; font-weight: 500; font-family: inherit;
    border-radius: var(--border-radius-sm); border: none; cursor: pointer;
    transition: var(--transition); gap: 8px; font-size: 0.95rem;
}
.btn-primary { background: var(--primary); color: white; width: 100%; padding: 12px; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--surface-hover); }

/* App Layout */
.app-layout {
    display: flex; height: 100vh; overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; transition: var(--transition);
    z-index: 10;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-header {
    height: var(--header-height); display: flex; align-items: center; padding: 0 20px;
    border-bottom: 1px solid var(--border); justify-content: space-between;
}
.sidebar-header .logo-text { font-size: 1.25rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.sidebar-header .logo-icon { font-size: 24px; color: var(--primary); display: none; }
.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .logo-icon { display: block; margin: 0 auto; }
.toggle-btn { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; }

.sidebar-nav { flex: 1; padding: 20px 10px; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; padding: 12px 15px;
    color: var(--text-secondary); text-decoration: none; border-radius: var(--border-radius-sm);
    margin-bottom: 5px; transition: var(--transition); font-weight: 500;
}
.sidebar-nav a i { font-size: 20px; margin-right: 15px; }
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: var(--primary-light); color: var(--primary);
}
.sidebar.collapsed .sidebar-nav a { padding: 12px; justify-content: center; }
.sidebar.collapsed .sidebar-nav a span { display: none; }
.sidebar.collapsed .sidebar-nav a i { margin-right: 0; }

.sidebar-footer {
    padding: 20px; border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; margin-bottom: 15px; }
.avatar { 
    width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light); 
    color: var(--primary); display: flex; align-items: center; justify-content: center; 
    font-weight: 600; font-size: 1.2rem; flex-shrink: 0;
}
.user-info .details { margin-left: 12px; white-space: nowrap; overflow: hidden; }
.user-info .name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); text-overflow: ellipsis; overflow: hidden; }
.user-info .role { font-size: 0.75rem; color: var(--text-secondary); }
.logout-btn { 
    width: 100%; background: none; border: 1px solid var(--danger-light); color: var(--danger);
    padding: 8px; border-radius: var(--border-radius-sm); cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500;
}
.logout-btn:hover { background: var(--danger-light); }
.sidebar.collapsed .user-info .details, .sidebar.collapsed .logout-btn span { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 20px 10px; }
.sidebar.collapsed .user-info { justify-content: center; margin-bottom: 20px; }

/* Main Content */
.main-content {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* Topbar */
.topbar {
    height: var(--header-height); background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 30px;
}
.page-title { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); }
.icon-btn { 
    background: none; border: none; font-size: 24px; color: var(--text-secondary); 
    cursor: pointer; position: relative; padding: 5px; transition: var(--transition);
}
.icon-btn:hover { color: var(--primary); }
.badge { 
    position: absolute; top: 0; right: 0; background: var(--danger); color: white;
    font-size: 10px; font-weight: bold; width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}

.notifications-dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: 100%; margin-top: 10px; width: 350px;
    background: var(--surface); border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border); z-index: 100;
}
.dropdown-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.dropdown-header h3 { font-size: 1rem; margin: 0; }
.text-btn { background: none; border: none; color: var(--primary); font-size: 0.85rem; font-weight: 500; cursor: pointer; }
.dropdown-body { max-height: 400px; overflow-y: auto; }
.notif-item { display: flex; padding: 15px 20px; border-bottom: 1px solid var(--border); gap: 15px; }
.notif-item:hover { background: var(--surface-hover); }
.notif-icon i { font-size: 24px; color: var(--warning); }
.notif-item.urgente .notif-icon i { color: var(--danger); }
.notif-text p { font-size: 0.9rem; margin-bottom: 5px; line-height: 1.4; }
.notif-text small { color: var(--text-muted); font-size: 0.75rem; }
.empty-state { padding: 30px 20px; text-align: center; color: var(--text-muted); }

/* Content Wrapper */
.content-wrapper { padding: 30px; flex: 1; overflow-y: auto; background: var(--bg-main); }

/* --- RESPONSIVE DESIGN --- */

/* Mobile Menu Button (Hidden by default) */
.mobile-menu-btn { display: none; }

/* Table Container for overflow */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius-sm);
}

/* Base Responsive Rules */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    .topbar { padding: 0 20px; }
    .content-wrapper { padding: 20px; }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    /* Sidebar as Mobile Overlay */
    .sidebar {
        position: fixed;
        left: -280px; /* Posición inicial fuera de pantalla */
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 2000; /* Por encima de todo */
        transition: var(--transition);
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
        transform: none !important;
    }
    .sidebar.mobile-open {
        left: 0; /* Entra a pantalla */
    }
    .sidebar.collapsed { width: 280px; } /* Don't collapse on mobile */
    .sidebar-header .toggle-btn { display: none; } /* Hide desktop toggle */
    
    /* Backdrop for mobile menu */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    .sidebar-backdrop.active { display: block; }

    /* Topbar adjustments */
    .topbar { 
        padding: 0 15px; 
        z-index: 1001; /* Asegura que esté sobre el contenido pero bajo el sidebar */
        position: relative;
    }
    .mobile-menu-btn {
        display: flex;
        background: var(--bg-main);
        border: 1px solid var(--border);
        border-radius: var(--border-radius-sm);
        font-size: 26px; /* Un poco más grande */
        color: var(--primary);
        cursor: pointer;
        padding: 10px; /* Área de toque más amplia */
        margin-right: 15px;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }
    .page-title { font-size: 1.1rem; }
    
    /* Content adjustments */
    .content-wrapper { padding: 15px; }
    
    /* Cards and Grids */
    .module-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px;
    }
    .module-header .btn, .module-header select { width: 100% !important; }

    /* Forms: Force 1 column */
    form div[style*="grid-template-columns"], 
    .auth-card div[style*="grid-template-columns"],
    div[style*="display: grid; grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    
    .card { padding: 15px !important; }
}

/* Auth responsive */
@media (max-width: 480px) {
    .auth-card { padding: 30px 20px; border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
    .auth-wrapper { padding: 0; background: var(--surface); }
}

/* --- MOBILE CARDS VIEW --- */
.mobile-cards-view {
    display: none;
    flex-direction: column;
    gap: 15px;
}

@media (max-width: 768px) {
    .table-responsive { display: none !important; }
    .mobile-cards-view { display: flex; }
    
    .mobile-card {
        background: var(--surface);
        border-radius: var(--border-radius);
        border: 1px solid var(--border);
        overflow: hidden;
        box-shadow: var(--shadow-sm);
        transition: var(--transition);
    }
    
    .mobile-card:active { transform: scale(0.98); }
    
    .mobile-card-header {
        height: 160px;
        background: #f1f5f9;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        position: relative;
    }
    
    .mobile-card-header img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .mobile-card-header .header-icon {
        font-size: 64px;
        color: var(--text-muted);
    }
    
    .mobile-card-header .header-badge {
        position: absolute;
        top: 10px;
        right: 10px;
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 700;
        box-shadow: var(--shadow-md);
    }
    
    .mobile-card-body {
        padding: 15px;
    }
    
    .mobile-card-title {
        font-size: 1.2rem;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 5px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-card-subtitle {
        font-size: 0.9rem;
        color: var(--text-secondary);
        margin-bottom: 15px;
    }
    
    .mobile-card-info {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 15px;
        padding: 10px;
        background: var(--bg-main);
        border-radius: var(--border-radius-sm);
    }
    
    .info-item {
        font-size: 0.8rem;
    }
    
    .info-item label {
        display: block;
        color: var(--text-muted);
        margin-bottom: 2px;
        text-transform: uppercase;
        font-size: 0.65rem;
        font-weight: 700;
    }
    
    .info-item span {
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .mobile-card-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
        border-top: 1px solid var(--border);
        background: var(--bg-main);
    }
    
    .mobile-card-actions button, 
    .mobile-card-actions a {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 15px;
        border: none;
        background: none;
        color: var(--text-secondary);
        font-size: 1.4rem;
        border-right: 1px solid var(--border);
        text-decoration: none;
    }
    
    .mobile-card-actions button:last-child,
    .mobile-card-actions a:last-child {
        border-right: none;
    }
    
    .mobile-card-actions button:active { background: var(--surface-hover); }
}
