/**
 * Sistema Eventos IML - CSS Principal
 * Bootstrap 5 - Mobile First - Responsive
 * Color principal: Cyan/Turquesa (#0891b2 / #0e7490)
 */

/* ==================== VARIABLES ==================== */
:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #22d3ee;
    --primary-darker: #155e75;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --sidebar-width: 260px;
    --navbar-height: 56px;
    --footer-height: 50px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --border-radius: 0.5rem;
}

/* ==================== BASE ==================== */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: var(--gray-100);
    color: var(--gray-800);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow: hidden;
}

/* Móvil: sidebar oculto */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--navbar-height);
}

.sidebar-logo {
    font-size: 1.5rem;
    color: #fff;
}

.sidebar-title {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
}

.btn-close-sidebar {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
}

.btn-close-sidebar:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Sidebar User Info */
.sidebar-user {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
    color: #fff;
    font-size: 1.5rem;
}

.sidebar-user .user-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.sidebar-user .user-role {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.1);
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
}

/* ==================== MENÚ NAV ==================== */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-section {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1.25rem 1rem 0.5rem;
}

.nav-menu .nav-item {
    margin: 2px 0.5rem;
}

.nav-menu .nav-link {
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
    gap: 0.75rem;
    min-height: 44px;
}

.nav-menu .nav-link i:first-child {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.85;
}

.nav-menu .nav-link span {
    flex: 1;
}

.nav-menu .nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.nav-menu .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 500;
}

/* ==================== OVERLAY ==================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ==================== TOP NAVBAR ==================== */
.top-navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--navbar-height);
    background: #fff;
    box-shadow: var(--shadow);
    z-index: 1030;
    display: flex;
    align-items: center;
}

@media (min-width: 992px) {
    .top-navbar {
        left: var(--sidebar-width);
    }
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 1rem;
    height: 100%;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-menu {
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-menu:hover {
    background: var(--gray-100);
    color: var(--primary-dark);
}

@media (min-width: 992px) {
    .btn-menu {
        display: none;
    }
}

.page-title {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 1rem;
}

.btn-icon {
    position: relative;
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    font-size: 1.1rem;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--gray-100);
    color: var(--primary);
}

/* User Button */
.btn-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 2rem;
    transition: all 0.2s ease;
}

.btn-user:hover {
    background: var(--gray-100);
}

.user-name {
    font-size: 0.875rem;
    color: var(--gray-700);
    font-weight: 500;
    padding-left: 0.5rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    min-height: 100vh;
    padding-top: var(--navbar-height);
    padding-bottom: var(--footer-height);
    transition: margin-left 0.3s ease;
}

@media (min-width: 992px) {
    .main-content {
        margin-left: var(--sidebar-width);
    }
}

.content-wrapper {
    padding: 1.5rem;
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1rem;
    }
}

/* ==================== FOOTER ==================== */
.main-footer {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: var(--footer-height);
    background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    z-index: 1020;
}

@media (min-width: 992px) {
    .main-footer {
        left: var(--sidebar-width);
    }
}

.footer-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 1.5rem;
}

.footer-left {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.footer-right {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ==================== CARDS ==================== */
.card {
    background: #fff;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ==================== STAT CARDS ==================== */
.stat-card {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
}

.stat-card .stat-icon.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-card .stat-icon.success { background: linear-gradient(135deg, var(--success), #059669); }
.stat-card .stat-icon.warning { background: linear-gradient(135deg, var(--warning), #d97706); }
.stat-card .stat-icon.danger { background: linear-gradient(135deg, var(--danger), #dc2626); }
.stat-card .stat-icon.info { background: linear-gradient(135deg, var(--info), #2563eb); }

.stat-card .stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
    line-height: 1;
}

.stat-card .stat-info p {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin: 0.25rem 0 0;
}

/* ==================== TABLES ==================== */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-responsive {
    border-radius: var(--border-radius);
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* ==================== FORMS ==================== */
.form-control, .form-select {
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    padding: 0.6rem 0.75rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* ==================== BUTTONS ==================== */
.btn {
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ==================== BADGES ==================== */
.badge {
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
}

/* ==================== ALERTS ==================== */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem 1.25rem;
}

/* ==================== MODALS ==================== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
}

/* ==================== UTILITIES ==================== */
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.border-primary { border-color: var(--primary) !important; }

.text-uppercase-force { text-transform: uppercase !important; }

/* ==================== RESPONSIVE HELPERS ==================== */
@media (max-width: 575.98px) {
    .hide-mobile { display: none !important; }
    .btn { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .hide-tablet { display: none !important; }
}

@media (min-width: 992px) {
    .hide-desktop { display: none !important; }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ==================== PUBLIC PAGE STYLES ==================== */
.public-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2rem 0;
    color: #fff;
    text-align: center;
}

.public-header h1 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.public-header p {
    opacity: 0.9;
    margin: 0;
}

.event-card {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.3s ease;
}

.event-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-5px);
}

.event-card .event-header {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    padding: 1.5rem;
    color: #fff;
}

.event-card .event-body {
    padding: 1.25rem;
}

.event-card .event-footer {
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-darker) 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    background: var(--gray-50);
    padding: 2rem;
    text-align: center;
}

.login-header i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-body {
    padding: 2rem;
}

/* ==================== MEJORAS MÓVILES Y TOUCH ==================== */

/* Touch targets mínimo 44px para accesibilidad */
.nav-menu .nav-link,
.btn,
.form-control,
.form-select,
.dropdown-item {
    min-height: 44px;
}

/* Mejorar scroll en tablas móviles */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
}

/* Indicador visual de scroll horizontal */
.table-responsive::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-responsive:hover::after {
    opacity: 1;
}

/* Botones más grandes en móvil para touch */
@media (max-width: 768px) {
    .btn {
        padding: 0.65rem 1rem;
        min-height: 48px;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        min-height: 40px;
    }
    
    /* Links del menú más grandes para touch */
    .nav-menu .nav-link {
        padding: 0.85rem 1rem;
        min-height: 50px;
    }
    
    /* Mejorar spacing en cards móviles */
    .card-body {
        padding: 1rem;
    }
    
    /* Tablas: texto más pequeño pero legible */
    .table {
        font-size: 0.85rem;
    }
    
    .table thead th {
        font-size: 0.7rem;
        padding: 0.5rem;
    }
    
    .table tbody td {
        padding: 0.6rem 0.5rem;
    }
    
    /* Botones de acción en tablas */
    .table .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    
    /* Dropdown menus más amigables al touch */
    .dropdown-menu {
        min-width: 200px;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
    
    /* Modales full width en móvil */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    /* Form controls más grandes */
    .form-control,
    .form-select {
        padding: 0.75rem 1rem;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    /* Stats cards en móvil */
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .stat-card .stat-info h3 {
        font-size: 1.25rem;
    }
}

/* Extra small devices */
@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 0.75rem;
    }
    
    /* Header más compacto */
    .page-title {
        font-size: 0.9rem;
    }
    
    /* Cards stack mejor */
    .row > [class*="col-"] {
        margin-bottom: 0.75rem;
    }
    
    /* Ocultar texto en botones muy pequeños, solo icono */
    .btn-action-text {
        display: none;
    }
    
    /* Alertas más compactas */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* Mejorar interacción touch */
@media (hover: none) and (pointer: coarse) {
    /* Dispositivos touch: quitar efectos hover */
    .btn:hover,
    .nav-menu .nav-link:hover,
    .card:hover {
        transform: none;
    }
    
    /* Feedback visual en touch */
    .btn:active,
    .nav-menu .nav-link:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    /* Scrollbars más gruesos para touch */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.3);
        border-radius: 4px;
    }
}

/* Safe area para iPhones con notch */
@supports (padding: max(0px)) {
    .main-content {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .main-footer {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* ==================== FIX SCROLL TABLAS MÓVILES ==================== */
/* Asegurar scroll horizontal en tablas para móviles */
@media (max-width: 991.98px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
    
    /* Asegurar ancho mínimo en tablas */
    .table-responsive > .table {
        min-width: 500px;
        margin-bottom: 0;
    }
    
    /* Hacer las celdas no romper líneas */
    .table-responsive .table th,
    .table-responsive .table td {
        white-space: nowrap;
    }
    
    /* Indicador de scroll - sombra a la derecha */
    .table-responsive {
        position: relative;
        background: 
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 100% 0,
            radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.1), transparent),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.1), transparent) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }
}
