/* ============================================
   TEMA GLOBAL - VARIABLES Y ESTILOS BASE
   ============================================ */

:root {
    /* Colors - Light Theme */
    --primary: #2563eb; /* Royal Blue */
    --primary-dark: #1d4ed8;
    --secondary: #64748b; /* Slate Grey */
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-secondary: #f8f9fa;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border: #e1e8ed;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 5px 15px rgba(0, 0, 0, 0.15);
    
    /* Sidebar Colors */
    --sidebar-bg: #ffffff;
    --sidebar-text: #334155;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(255, 255, 255, 0.15);
    --sidebar-submenu-bg: rgba(0, 0, 0, 0.2);
    
    /* Sizing */
    --sidebar-width: 280px;
    --sidebar-width-tablet: 250px;
    --header-height: 70px;
}

/* Dark Mode */
body.dark-mode {
    --background: #1a1a1a;
    --surface: #2d2d2d;
    --surface-secondary: #333333;
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --border: #404040;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 5px 15px rgba(0, 0, 0, 0.5);
    --sidebar-hover: rgba(255, 255, 255, 0.15);
    --sidebar-active: rgba(255, 255, 255, 0.25);
    --sidebar-submenu-bg: rgba(0, 0, 0, 0.4);
    
    /* Adjust primary colors for better contrast on dark background if needed */
    --primary: #3498db;
    --primary-dark: #2980b9;
}

/* ============================================
   ESTILOS BASE
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-primary);
    background-color: var(--background);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

/* ============================================
   MENÚ LATERAL MEJORADO
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid var(--sidebar-submenu-bg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-header i {
    font-size: 24px;
    flex-shrink: 0;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 0;
}

.menu-section {
    margin-bottom: 10px;
}

.menu-section-title {
    padding: 0 20px 5px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
    user-select: none;
}

.menu-item {
    position: relative;
    list-style: none;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.menu-link:hover {
    background-color: var(--sidebar-hover);
    padding-left: 25px;
}

.menu-link.active {
    background-color: var(--sidebar-active);
    border-left: 3px solid #ffffff;
    padding-left: 17px;
}

.menu-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.menu-link .badge {
    margin-left: auto;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.menu-link .arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 14px;
}

.menu-item.active > .menu-link .arrow {
    transform: rotate(180deg);
}

/* Submenú */
.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: var(--sidebar-submenu-bg);
}

.submenu.active {
    max-height: 500px;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 20px 6px 50px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
}

.submenu-link:hover {
    color: #ffffff;
    padding-left: 55px;
    background-color: rgba(255, 255, 255, 0.05);
}

.submenu-link.active {
    color: #ffffff;
    font-weight: 600;
    border-left: 2px solid #ffffff;
    padding-left: 48px;
}

/* Scrollbar personalizado */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   TOGGLE DEL TEMA Y MENÚ MOBILE
   ============================================ */

.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 999;
}

.theme-toggle:hover {
    background-color: var(--primary-dark);
    transform: scale(1.1);
}

.menu-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
}

.menu-toggle:hover {
    background-color: var(--primary-dark);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 992px) {
    :root {
        --sidebar-width: var(--sidebar-width-tablet);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        display: none;
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 480px) {
    .menu-link,
    .submenu-link {
        padding-left: 15px;
        font-size: 13px;
    }
    
    .menu-link i,
    .submenu-link i {
        font-size: 16px;
    }
    
    .sidebar-header {
        padding: 20px 15px;
    }
}



/* ============================================
   UTILITY CLASSES
   ============================================ */

.container {
    color: var(--text-primary);
    background-color: var(--surface);
}

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    background-color: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

/* ============================================
   SWEETALERT2 OVERRIDES
   ============================================ */
.swal2-popup {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
}

.swal2-title, .swal2-content, .swal2-html-container {
    color: var(--text-primary) !important;
}

.swal2-confirm {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.swal2-cancel {
    background-color: var(--text-secondary) !important;
    color: #ffffff !important;
}

.swal2-deny {
    background-color: var(--danger) !important;
    color: #ffffff !important;
}
