/* Archivo: /assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta de colores base (Azul médico moderno) */
    --primary: #10b981;       /* Verde médico principal */
    --primary-hover: #047857; /* Verde oscuro para un contraste fuerte en el hover */
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Manrope', sans-serif;
}

body.bg-light {
    background-color: var(--bg-color);
    color: var(--text-main);
}

/* --- Layout del Login --- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px; /* Margen para celulares */
}

.login-card {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.icono-logo {
    font-size: 48px;
    color: var(--primary);
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-top: 10px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 5px;
}

/* --- Formularios --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper i {
    position: absolute;
    left: 15px;
    color: var(--text-muted);
    font-size: 20px;
}

.input-icon-wrapper input {
    width: 100%;
    padding: 12px 15px 12px 45px; /* Espacio izquierdo para el icono */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}

.input-icon-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s; /* Animación más suave */
    text-decoration: none; /* Elimina el espantoso subrayado */
    font-family: 'Inter', sans-serif; /* Forzamos la fuente correcta */
}

/* Le damos un pequeño efecto de hundimiento al hacer clic para más interactividad */
.btn:active {
    transform: scale(0.98);
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* ========================================= */
/* 04. COMPONENTE: NAVBAR SUPERIOR           */
/* ========================================= */
.navbar {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
}

.nav-logo i {
    font-size: 28px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* ========================================= */
/* 05. COMPONENTE: HERO SECTION (INDEX)      */
/* ========================================= */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 100px 20px 20px; /* Padding top compensa el navbar fijo */
    text-align: center;
}

.hero-content {
    max-width: 600px;
}

.badge-construccion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #fff3cd;
    color: #856404;
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
}

.hero-content h1 {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 15px;
    color: var(--text-main);
}

.hero-content p {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Ajustes responsivos básicos para celulares */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 28px;
    }
}

/* ========================================= */
/* 06. COMPONENTE: ALERTAS                   */
/* ========================================= */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.alert i {
    font-size: 18px;
}

.alert-danger {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #f87171;
}

/* ========================================= */
/* 07. COMPONENTE: LAYOUT DEL DASHBOARD      */
/* ========================================= */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar (Menú Lateral) --- */
.sidebar {
    width: 260px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.sidebar-header i {
    font-size: 28px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover, .nav-item.active {
    background-color: #ecfdf5; /* Fondo verde muy claro */
    color: var(--primary);
    border-right: 4px solid var(--primary);
}

.text-danger {
    color: #dc2626 !important;
}
.nav-item.text-danger:hover {
    background-color: #fef2f2;
    border-right: 4px solid #dc2626;
}

.sidebar-footer {
    padding: 15px 0;
    border-top: 1px solid var(--border-color);
}

/* --- Main Content (Contenido Principal) --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-color);
}

.topbar {
    background-color: var(--card-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    /* MAGIA STICKY */
    position: sticky;
    top: 0;
    z-index: 1020; /* Se superpone al contenido pero queda debajo de los modales */
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
    display: none; /* Oculto en PC, se muestra en móviles */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.badge-rol {
    background-color: #e5e7eb;
    color: #374151;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.content-wrapper {
    padding: 30px;
}

.content-wrapper h1 {
    font-size: 24px;
    color: var(--text-main);
    margin-bottom: 5px;
}

/* ========================================= */
/* 08. MEDIA QUERIES (MODO MÓVIL)            */
/* ========================================= */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%); /* Oculto por defecto en móvil */
    }

    .sidebar.active {
        transform: translateX(0); /* Se muestra al tocar el botón */
    }

    .menu-toggle {
        display: block;
    }
}

/* ========================================= */
/* 09. COMPONENTE: TABLAS DE DATOS           */
/* ========================================= */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-container {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    border: 1px solid var(--border-color);
    overflow-x: auto; /* ESENCIAL PARA RESPONSIVE EN MÓVILES */
}

.table-pro {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap; /* Evita que el texto se apile en pantallas chicas */
}

.table-pro th, .table-pro td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table-pro th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table-pro tbody tr:hover {
    background-color: #f9fafb;
}

.font-weight-600 {
    font-weight: 600;
    color: var(--text-main);
}

/* Badges de Estado */
.badge {
    padding: 6px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background-color: #d1fae5; color: #065f46; }
.badge-danger { background-color: #fee2e2; color: #991b1b; }

/* Botones de acción en tabla */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: 0.2s;
}

.btn-icon i { font-size: 20px; }
.btn-icon:hover { background-color: var(--bg-color); color: var(--primary); }
.btn-icon.text-danger:hover { color: #dc2626; }

/* --- NORMALIZACIÓN DE BOTONES DE ACCIÓN GLOBALES --- */
.table-pro .btn-sm {
    transition: all 0.2s ease-in-out;
    border-width: 1px;
}
.table-pro .btn-outline-secondary { color: #64748b; border-color: #cbd5e1; }
.table-pro .btn-outline-secondary:hover { background-color: #f1f5f9; color: #0f172a; border-color: #94a3b8; }

.table-pro .btn-outline-info { color: #0ea5e9; border-color: #bae6fd; }
.table-pro .btn-outline-info:hover { background-color: #e0f2fe; color: #0284c7; border-color: #7dd3fc; }

.table-pro .btn-outline-primary { color: #3b82f6; border-color: #bfdbfe; }
.table-pro .btn-outline-primary:hover { background-color: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }

.table-pro .btn-outline-danger { color: #ef4444; border-color: #fecaca; }
.table-pro .btn-outline-danger:hover { background-color: #fef2f2; color: #b91c1c; border-color: #fca5a5; }

.table-pro .btn-outline-success { color: #10b981; border-color: #a7f3d0; }
.table-pro .btn-outline-success:hover { background-color: #ecfdf5; color: #047857; border-color: #6ee7b7; }

/* ========================================= */
/* 08. MEDIA QUERIES & RESPONSIVE CARDS      */
/* ========================================= */
@media screen and (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }

    /* --- FLAT DESIGN MÓVIL PARA TABLAS --- */
    
    /* 1. Hacemos el contenedor transparente y sin borde para evitar "doble borde" */
    .table-container {
        background-color: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0;
    }

    .table-pro {
        border: 0;
        white-space: normal !important; /* MATAMOS EL NOWRAP DEL ESCRITORIO */
    }
    
    .table-pro thead {
        border: none;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
    }
    
    /* 2. Las filas se convierten en tarjetas planas */
    .table-pro tr {
        background-color: var(--card-bg);
        border-radius: 8px;
        box-shadow: none !important; /* DISEÑO PLANO: Cero sombras */
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color); /* Único borde nítido */
    }

    .table-pro tr:last-child {
        margin-bottom: 0; /* Evita margen muerto abajo de todo */
    }
    
    .table-pro td {
        border-bottom: 1px solid var(--bg-color); /* Línea divisoria interna sutil */
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 12px 15px;
        font-size: 0.9rem;
        /* REGLAS PARA ROMPER TEXTOS LARGOS (WORD WRAP) */
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        gap: 10px; /* Separación entre el título y el texto largo */        
    }
    
    .table-pro td:last-child {
        border-bottom: 0;
        justify-content: center;
        padding-top: 15px;
    }

    /* 3. Ajuste PRO: Si la tabla está vacía (colspan), centramos el mensaje */
    .table-pro td[colspan] {
        justify-content: center !important;
        text-align: center !important;
        flex-direction: column;
    }
    .table-pro td[colspan]::before {
        display: none !important; /* Ocultamos etiquetas en mensajes vacíos */
    }

    .table-pro td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-right: 15px;
        /* LA MAGIA PARA QUE NO SE APLASTE EL TÍTULO */
        flex-shrink: 0; 
        min-width: 85px;
    }
}

/* ========================================= */
/* --- LOOK & FEEL AGENDA (Estilo SaaS Pro) --- */
/* ========================================= */
.fc { font-family: 'Manrope', sans-serif !important; }
.fc .fc-toolbar-title { color: var(--text-main) !important; font-size: 1.1rem !important; }

.fc .fc-button-primary { background-color: #ffffff !important; color: var(--primary) !important; border: 1px solid var(--border-color) !important; text-transform: capitalize; }
.fc .fc-button-primary:hover { background-color: var(--bg-color) !important; }
.fc .fc-button-primary.fc-button-active { background-color: var(--primary) !important; color: #fff !important; }

/* Tarjetas de Turnos (Fondo Tiza, Borde Izquierdo de Color) */
.fc-event { 
    border-style: solid !important;
    /* Borde grueso a la izquierda, los demás en 1px */
    border-width: 1px 1px 1px 5px !important; 
    /* Pintamos los bordes superior, derecho y abajo de gris claro */
    border-top-color: #e5e7eb !important;
    border-right-color: #e5e7eb !important;
    border-bottom-color: #e5e7eb !important;
    /* El border-left-color lo toma automáticamente del $color_medico que pasamos en JS */
    
    border-radius: 6px !important; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
    padding: 2px 4px !important;
    cursor: pointer !important;
    overflow: hidden !important; /* Nada sobresale del card */
}

.fc-event:hover { background-color: #ffffff !important; box-shadow: 0 4px 6px rgba(0,0,0,0.08) !important; }

/* Diseño especial para "En Sala" (Borde completo verde llamativo) */
.turno-estado-en_sala {
    border-top-color: #10b981 !important;
    border-right-color: #10b981 !important;
    border-bottom-color: #10b981 !important;
    /* Mantenemos el izquierdo de 5px con el color del médico, pero engrosamos el resto a 2px para que destaque */
    border-width: 2px 2px 2px 5px !important;
    background-color: #ecfdf5 !important; /* Fondo apenas verde */
}

/* Manejo de opacidad para los que ya pasaron */
.turno-estado-atendido { opacity: 0.6; }
.turno-estado-ausente, .turno-estado-cancelado { opacity: 0.4; filter: grayscale(100%); }
.turno-estado-cancelado .fc-event-main { text-decoration: line-through; }

/* Grilla (Aquí cambiamos la altura) */
.fc-theme-standard td, .fc-theme-standard th { border-color: #e5e7eb !important; }
.fc-timegrid-slot { border-bottom: 1px solid #f3f4f6; height: 60px !important; } /* <-- ALTURA DE FILAS AQUÍ */
.fc-timegrid-axis { background: #f9fafb; }
.fc-col-header-cell { background: #f3f4f6; font-weight: 600; padding: 8px 0 !important; }
.fc .fc-day-today { background-color: #f8fafc !important; } 

/* Quitar el subrayado feo de hipervínculo en los días de la cabecera */
.fc-col-header-cell a {
    text-decoration: none !important;
    color: var(--text-main) !important;
    text-transform: capitalize; /* Para que diga "Lunes" y no "lunes" */
}
.fc-col-header-cell a:hover {
    text-decoration: underline !important; /* Solo si pasan el mouse */
}

/* Agenda Móvil */
@media (max-width: 768px) {
    #calendar { padding: 5px !important; min-height: 500px; }
    .fc .fc-toolbar { flex-direction: column; gap: 10px; }
    .fc-toolbar-title { font-size: 1.1rem !important; }
    .fc-dayGridMonth-button, .fc-timeGridWeek-button { display: none !important; }
    
    .fc-list-table { border-collapse: separate !important; border-spacing: 0 8px !important; }
    .fc-list-event { border: 1px solid #e5e7eb !important; border-left-width: 5px !important; background: #fff !important; }
    .fc .fc-list-event td { padding: 12px !important; border: none !important; }
}