:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-sidebar: #1e293b;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #8b5cf6;
    --error: #ef4444;
    --success: #10b981;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --font-main: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

html, body {
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* --- RBAC & READ ONLY MODE --- */
.read-only-mode .btn-primary,
.read-only-mode .btn-edit,
.read-only-mode .btn-delete,
.read-only-mode .btn-success,
.read-only-mode .btn-add,
.read-only-mode #btn-add-materia,
.read-only-mode #btn-add-depto,
.read-only-mode .modal-actions button[type="submit"],
.read-only-mode .asig-item:hover::after {
    display: none !important;
}

.read-only-mode input,
.read-only-mode select,
.read-only-mode textarea {
    pointer-events: none;
    opacity: 0.7;
}

.info-banner {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rbac-container {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
}

.rol-selector-wrapper {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.matrix-table td {
    text-align: center !important;
}

.matrix-table td:first-child {
    text-align: left !important;
}

.mod-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mod-icon {
    font-size: 1.2rem;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-success:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Eliminamos scrollbars globales para evitar interferencias generales */
* {
    scrollbar-width: thin; /* Para Firefox */
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    margin: 0;
    overflow-x: hidden;
}

#app, .screen {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#main-screen {
    flex-direction: row; /* Sidebar side by side with Content */
}

h1, h2, h3 {
    font-family: var(--font-heading);
}

.hidden {
    display: none !important;
}

/* Base Screens */
/* Quitamos .screen de aquí para evitar conflictos con la redefinición arriba */

/* Login Screen Styles */
#login-screen {
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    justify-content: center;
    align-items: center;
}

.cal-modal {
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    width: 95% !important;
    max-width: 1000px !important;
    padding: 1.2rem 2rem; /* Más compacto */
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7);
    position: relative;
    max-height: 95vh;
    overflow-y: auto;
    color: white;
    z-index: 1000;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.modal-header h2 {
    font-size: 1.3rem !important;
    margin: 0;
}

.modal-horizontal-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0.5rem;
    align-items: start;
}

.modal-section {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.025);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #818cf8;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
}

.modal-col-left, .modal-col-right {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    margin-bottom: 0 !important;
}

.btn-close-modal {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-section {
    margin-bottom: 1rem; /* Reducido de 2rem */
    padding: 1rem; /* Reducido de 1.5rem */
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.section-title {
    font-size: 0.85rem; /* Más compacto */
    font-weight: 700;
    color: #818cf8;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-existing-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 8px;
}

.modal-existing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 4px solid #6366f1;
    transition: background 0.2s;
}

.modal-existing-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.existing-info {
    font-size: 0.85rem;
    line-height: 1.4;
}

.existing-info strong {
    color: #cbd5e1;
}

.existing-info small {
    display: block;
    color: #94a3b8;
    font-style: italic;
    margin-top: 2px;
}

.modal-form-inline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.modal-checks-horiz {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
}

.modal-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
}

.modal-check-item input {
    width: 16px;
    height: 16px;
    accent-color: #6366f1;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    padding: 3rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeInScale 0.5s ease-out;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -1px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-dim);
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
}

.form-group input, .form-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: white;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Mejora de contraste para opciones de select */
select option {
    background-color: #0f172a; /* Fondo muy oscuro para contraste */
    color: white;
    padding: 10px;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
    margin-top: 1rem;
}

/* Sidebar Styles */
#sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#sidebar.collapsed .logo {
    display: none;
}

#sidebar.collapsed .sidebar-header {
    padding: 2rem 1rem;
    justify-content: center;
}

.btn-toggle {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
}

.btn-toggle:hover {
    background: var(--primary);
    color: white;
}

#sidebar.collapsed .btn-toggle {
    transform: rotate(180deg);
}

#main-nav {
    flex: 1;
    padding: 0 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar Sutil e Indigo para el Sidebar */
#main-nav::-webkit-scrollbar {
    width: 6px;
}

#main-nav::-webkit-scrollbar-track {
    background: transparent;
}

#main-nav::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 10px;
}

#main-nav::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

#sidebar.collapsed #main-nav {
    padding: 0;
}

#main-nav ul {
    list-style: none;
}

#main-nav li {
    margin-bottom: 0.5rem;
}

#main-nav a {
    display: block;
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

#main-nav li.active a,
#main-nav a:hover {
    background: var(--glass);
    color: white;
}

#sidebar.collapsed #main-nav a {
    padding: 0.75rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
}

#sidebar.collapsed #main-nav span {
    display: none;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}

#sidebar.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#user-display {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
}

#sidebar.collapsed .user-info {
    align-items: center;
}

#sidebar.collapsed #user-display {
    display: none;
}

#logout-btn {
    background: none;
    border: none;
    color: var(--error);
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
    padding: 0;
}

/* Main Content Styles */
#content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    overflow: hidden; /* Evitar scroll doble */
}

#view-container {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 2rem;
    min-height: 0;
    position: relative;
    scrollbar-gutter: stable;
    transition: padding 0.3s ease;
}

#view-container.minimal-padding {
    padding: 0.5rem;
}

/* Aplicamos estilo 'Calendario' SOLO al panel de contenido derecho */
#view-container::-webkit-scrollbar {
    width: 12px;
}

#view-container::-webkit-scrollbar-track {
    background: #0f172a;
    border-left: 1px solid var(--border);
}

#view-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
    border: 3px solid #0f172a;
}

#view-container::-webkit-scrollbar-thumb:hover {
    background: #818cf8;
}

#top-bar {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: #0f172a;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

#top-bar.collapsed {
    padding: 0.1rem 2rem;
    height: 40px;
}

#top-bar.collapsed #page-title {
    display: none;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-toggle-mini {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

#top-bar.collapsed .btn-toggle-mini {
    transform: rotate(180deg);
}

.select-modern {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    min-width: 150px;
}

.btn-icon {
    background: var(--glass);
    border: 1px solid var(--border);
    color: white;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
}

#view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view {
    flex: 1;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#view-container:has(#grid-container) .view {
    padding: 0.5rem 1rem 0 1rem; /* Casi sin padding arriba y abajo */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--text-dim);
}

/* Module Layout */
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.module-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.module-header .btn-primary {
    width: auto;
    margin-top: 0;
    padding: 0.625rem 1.25rem;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th, 
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 2001;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-actions .btn-primary {
    width: auto;
}

/* Utility Buttons */
.btn-secondary {
    background: var(--glass);
    color: white;
    border: 1px solid var(--border);
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-edit, .btn-delete {
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: all 0.2s;
}

.btn-edit {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.btn-edit:hover {
    background: var(--primary);
    color: white;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.btn-delete:hover {
    background: var(--error);
    color: white;
}

textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: white;
    font-family: inherit;
    min-height: 100px;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* Grid Editor Styles */
.editor-controls {
    display: flex;
    gap: 1rem;
}

.grid-scroll {
    width: 100%;
    flex: 1; /* Ocupar todo el espacio disponible */
    overflow: auto;
    margin-top: 0; 
    background: var(--bg-card);
    border-radius: 1.5rem; /* Bordes más redondeados y completos */
    padding: 0;
    border: 1px solid var(--border);
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin-bottom: 0.5rem;
}

/* Scrollbar contrast */
.grid-scroll::-webkit-scrollbar {
    height: 14px;
    width: 14px;
}
.grid-scroll::-webkit-scrollbar-track {
    background: #0f172a;
}
.grid-scroll::-webkit-scrollbar-thumb {
    background: #6366f1; /* Color vibrante para que se vea */
    border-radius: 10px;
    border: 3px solid #0f172a;
}
.grid-scroll::-webkit-scrollbar-thumb:hover {
    background: #818cf8;
}

.grid-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.grid-table th {
    padding: 1rem;
    background: #1e293b; /* Color sólido para evitar transparencias al solapar */
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    min-width: 150px;
}

.grid-table td {
    border: 1px solid var(--border);
    padding: 0;
    vertical-align: top;
}

.time-cell {
    background: #1e293b !important;
    min-width: 120px;
    padding: 0.5rem 1rem !important; /* Más compacto */
    position: sticky;
    left: 0;
    z-index: 20;
}

.mod-num {
    font-weight: 700;
    font-size: 0.875rem;
}

.mod-time {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.grid-cell {
    cursor: pointer;
    transition: all 0.2s;
    /* Remover min-height fijo para permitir compactación */
}

.grid-cell:hover {
    background: rgba(255, 255, 255, 0.05);
}

.empty-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    color: var(--text-dim);
    font-size: 1.2rem;
    opacity: 0.3;
}

.asig-item {
    padding: 0;
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    background: rgba(99, 102, 241, 0.15);
    line-height: 1.2;
}

.asig-comision {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.asig-docente {
    font-size: 0.8rem;
    color: white;
}

.day-group-header td, 
.header-days th {
    background: rgba(99, 102, 241, 0.2) !important;
    font-weight: 800;
    text-align: center;
    padding: 0.75rem !important;
    color: var(--primary);
    letter-spacing: 0.1em;
    border: 1px solid var(--border) !important;
}

.header-aulas th {
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-dim);
    padding: 0.5rem !important;
    min-width: 120px;
}

.grid-weekly .grid-cell {
    min-width: 120px;
}

.grid-main-header {
    background: var(--primary) !important;
    color: white !important;
    font-size: 1.5rem !important;
    padding: 1rem !important;
    text-align: center;
    border: none !important;
    font-family: var(--font-heading);
    letter-spacing: 2px;
}

/* New Grid Header Controls */
.grid-header-content {
    display: flex;
    justify-content: flex-start; /* Alineado a la izquierda */
    align-items: center;
    padding: 0.2rem 1rem;
    gap: 2rem;
}

.dept-title {
    flex: 1;
    text-align: left;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-controls {
    display: flex;
    gap: 0.5rem;
}

.select-mini {
    background: rgba(30, 41, 59, 0.8); /* Fondo más sólido */
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none; /* Mejor control en algunos navegadores */
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L3.451 6.633a.5.5 0 0 1 .398-.85h7.302a.5.5 0 0 1 .398.85L7.247 11.14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 25px;
}

.select-mini option {
    background-color: #1e293b;
    color: white;
    padding: 10px;
}

/* ----------------------------------------------------------------- */
/* GLOBO DE RESULTADOS DE BUSQUEDA (Google Style)                    */
/* ----------------------------------------------------------------- */
.search-results-balloon {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 2000;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    animation: slideDownFade 0.2s ease-out;
}

@keyframes slideDownFade {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateX(4px);
}

.res-date-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 80px;
}

.res-year { font-size: 0.65rem; color: var(--text-dim); font-weight: 700; }
.res-month { font-size: 0.75rem; color: var(--primary); font-weight: 600; text-transform: uppercase; }
.res-day { font-size: 1.1rem; color: white; font-weight: 700; line-height: 1; }

.res-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.res-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.res-cat {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}

.res-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.search-results-balloon::-webkit-scrollbar {
    width: 6px;
}
.search-results-balloon::-webkit-scrollbar-track {
    background: transparent;
}
.search-results-balloon::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* Resaltado de búsqueda en las celdas */
.dcell.search-highlight {
    box-shadow: inset 0 0 0 2px var(--primary), 0 0 15px rgba(99, 102, 241, 0.4);
    z-index: 5;
    transform: scale(1.02);
}

/* Enfoque al hacer clic en un resultado del globo */
.search-focus {
    animation: pulseHighlight 2s ease-out;
}

@keyframes pulseHighlight {
    0% { box-shadow: 0 0 0 0px var(--primary); transform: scale(1.02); }
    30% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); transform: scale(1.1); }
    50% { box-shadow: 0 0 0 0px var(--primary); transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* --- FIX OVERLAP & CLIPPING FOR SEARCH BALLOON --- */
.calendario-header {
    z-index: 2100 !important; /* Por encima de la grilla y otros elementos */
    position: relative;
    overflow: visible !important; /* Vital para que el globo no se corte */
}

.header-row {
    overflow: visible !important;
}

.search-input-wrapper {
    position: relative;
    overflow: visible !important;
}

.search-results-balloon {
    /* z-index ya es 2000, pero vamos a subirlo para estar seguros */
    z-index: 3000 !important;
}

/* Selector de Mes Premium */
.month-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.select-month-premium {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    color: white;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.4rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L3.451 6.633a.5.5 0 0 1 .398-.85h7.302a.5.5 0 0 1 .398.85L7.247 11.14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 45px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.select-month-premium:hover {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    background-color: rgba(255, 255, 255, 0.05);
}

.select-month-premium option {
    background: #1e293b;
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    padding: 10px;
}

/* RECREOS */
.break-row {
    background: rgba(245, 158, 11, 0.08); /* Ámbar muy suave */
    height: 32px;
}

.break-row td {
    padding: 0 !important;
    border-top: 1px solid rgba(245, 158, 11, 0.2);
    border-bottom: 1px solid rgba(245, 158, 11, 0.2);
    text-align: center;
    vertical-align: middle;
}

.break-content {
    display: flex;
    justify-content: flex-start; /* Alineado a la izquierda */
    align-items: center;
    gap: 1.5rem;
    padding-left: 1.5rem; /* Margen para no pegar al borde */
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    font-weight: 600;
}

.break-excluded {
    background: transparent !important;
    border: 1px dashed rgba(255, 255, 255, 0.05) !important;
    cursor: pointer;
}

.break-excluded:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.break-label {
    color: #f59e0b;
    font-weight: 800;
    text-transform: uppercase;
}

.break-duration {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
}

.break-time {
    opacity: 0.6;
    font-weight: 400;
    letter-spacing: 1px;
}

/* --- BLINDAJE DE HEADERS STICKY (ALTURAS FIJAS Y PIXEL-PERFECT) --- */

/* Fila 1: Departamento (Altura fija 60px) */
.grid-table thead tr:nth-child(1) th { 
    top: 0; 
    height: 60px;
    z-index: 500 !important; 
    background: var(--primary) !important;
    padding: 0 1rem !important;
}

/* Fila 2: Días (Altura fija 45px, top = height F1) */
.grid-table thead tr:nth-child(2) th { 
    top: 60px; 
    height: 45px;
    z-index: 490 !important; 
    background: #1e293b !important;
    padding: 0 !important;
}

/* Fila 3: Aulas (Altura fija 35px, top = height F1 + F2) */
.grid-table thead tr:nth-child(3) th { 
    top: 105px; 
    height: 35px;
    z-index: 480 !important; 
    background: #0f172a !important;
    padding: 0 !important;
}

/* Fila 4 (si existiera) */
.grid-table thead tr:nth-child(4) th { 
    top: 140px; 
    z-index: 470 !important; 
}

/* PRIMERA COLUMNA (Sticky Horizontal y Vertical) */
.time-cell {
    position: sticky;
    left: 0;
    background: #1e293b !important;
    border-right: 2px solid var(--primary) !important;
    z-index: 450 !important; /* Entre los headers principales y las celdas de datos */
}

/* Los rincones superiores izquierdos deben tener mayor prioridad que sus filas */
.grid-table thead tr:nth-child(1) .time-cell { z-index: 510 !important; }
.grid-table thead tr:nth-child(2) .time-cell { z-index: 505 !important; }
.grid-table thead tr:nth-child(3) .time-cell { z-index: 495 !important; }

/* Separador vertical entre días */
.day-divider {
    border-left: 2px solid var(--primary) !important;
}

/* El main header debe estar siempre arriba de todo */
.grid-main-header {
    position: sticky;
    top: 0;
    background: var(--primary) !important;
}

/* --- ESTILOS DE IMPRESIÓN (INK-FRIENDLY & HIGH-CONTRAST) --- */
@media print {
    /* Ocultar elementos de UI */
    #sidebar, #top-bar, .grid-controls, .sidebar-toggle, .btn-toggle-mini, .btn-icon, .select-mini, .sidebar-footer {
        display: none !important;
    }

    /* Reset de layout total */
    body, #app, #main-screen, #content, #view-container, .view {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        color: black !important;
        overflow: visible !important;
    }

    #content { margin-left: 0 !important; }

    .grid-scroll {
        overflow: visible !important;
        height: auto !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        flex: none !important;
    }

    /* Desactivar STICKY para evitar cortes y solapamientos */
    .grid-table thead tr th,
    .time-cell,
    .grid-main-header {
        position: static !important;
        top: auto !important;
        left: auto !important;
        z-index: auto !important;
    }

    /* Forzar colores de fondo y bordes */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .grid-table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: auto !important;
        border: 2px solid #000 !important;
    }

    .grid-table th, .grid-table td {
        border: 1px solid #000 !important;
        color: #000 !important;
        padding: 4px !important;
        font-size: 8pt !important;
        background: white !important;
    }

    /* Resaltar cabeceras con gris claro para ahorro de tinta pero legibilidad */
    .grid-main-header {
        background-color: #eee !important;
        padding: 10px !important;
    }

    .grid-table thead tr:nth-child(2) th { background-color: #f8f8f8 !important; }
    .grid-table thead tr:nth-child(3) th { background-color: #fefefe !important; }

    .dept-title {
        color: #000 !important;
        font-size: 14pt !important;
        font-weight: bold !important;
        display: block !important;
        text-align: center !important;
    }

    .time-cell {
        background-color: #f0f0f0 !important;
        font-weight: bold !important;
        min-width: 80px !important;
    }

    /* Asegurar que las materias se vean con alto contraste */
    .asig-item {
        background-color: #f0f4ff !important;
        border: 1px solid #6366f1 !important;
        color: #000 !important;
        padding: 4px !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
    }

    .asig-comision { 
        color: #000 !important;
        font-weight: bold !important; 
        font-size: 9pt !important;
        display: block !important;
    }
    
    .asig-docente { 
        color: #000 !important; 
        font-weight: bold !important;
        opacity: 1 !important;
        font-size: 8.5pt !important;
        margin-top: 2px !important;
        display: block !important;
    }

    /* Estilos de Recreo en Impresión */
    .break-row td {
        background-color: #fff7ed !important; /* Soft orange tint */
        border: 1px solid #f97316 !important;
        height: 20pt !important;
    }
    .break-content {
        color: #9a3412 !important;
        font-size: 7.5pt !important;
        letter-spacing: 1px !important;
        justify-content: flex-start !important;
        padding-left: 10pt !important;
    }
    .break-label { font-weight: bold !important; margin-right: 5pt !important; }
    .break-duration { 
        background-color: #ffedd5 !important;
        border: 1px solid #fdba74 !important;
        padding: 1pt 4pt !important;
        border-radius: 4pt !important;
        font-weight: bold !important;
    }

    /* Ocultar los "+" de edición en la impresión de forma definitiva */
    tr { page-break-inside: avoid; }
}

/* --- DASHBOARD REAL-TIME --- */
#dashboard-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto !important;
    scrollbar-gutter: stable;
}

/* Aplicamos el estilo de scrollbar 'Calendario' al Dashboard */
#dashboard-view::-webkit-scrollbar {
    width: 12px;
}

#dashboard-view::-webkit-scrollbar-track {
    background: #0f172a;
    border-left: 1px solid var(--border);
}

#dashboard-view::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
    border: 3px solid #0f172a;
}

#dashboard-view::-webkit-scrollbar-thumb:hover {
    background: #818cf8;
}

/* Dashboard Timeline Header (Retro Clock & Weather) */
.dashboard-header {
    display: flex;
    justify-content: flex-start; /* Alineado a la izquierda */
    align-items: stretch; /* Misma altura para ambos widgets */
    gap: 1.5rem;
    padding: 0.5rem 0 1.5rem 1.5rem; /* Menos espacio superior */
    flex-wrap: wrap; /* Permitir que se acomoden en pantallas chicas */
}

/* 24h Retro Digital Clock */
.retro-clock-wrapper {
    background: #0f172a;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid #1e293b;
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.8),
        0 10px 20px rgba(0,0,0,0.4);
    display: flex;
}

.retro-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #020617; /* Fondo súper oscuro */
    padding: 1rem 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 250px;
    width: 100%;
    box-sizing: border-box;
}

.rc-time {
    font-family: 'Courier New', Courier, monospace; /* Fuente retro por defecto, asumiendo Monospace */
    font-size: 3.5rem;
    font-weight: 900;
    color: #4ade80; /* Verde terminal/radar */
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5), 0 0 20px rgba(74, 222, 128, 0.3);
    letter-spacing: 2px;
    line-height: 1;
}

.rc-sec {
    font-size: 1.5rem;
    color: #22c55e;
    opacity: 0.8;
}

.rc-date {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 0.5rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 700;
}

/* Weather Widget */
.weather-widget {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 250px; /* Mismo ancho que reloj */
    box-sizing: border-box;
}

.ww-header {
    font-size: 0.75rem;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.25rem;
}

.ww-body {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.ww-detail span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ----------------------------------------------------------------- */
/* SMART ALERTS PANEL                                                */
/* ----------------------------------------------------------------- */

.smart-alerts-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 120px; /* Igualar o aproximar altura a los relojes */
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.smart-alerts-panel::-webkit-scrollbar {
    width: 4px;
}
.smart-alerts-panel::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
}

.sa-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.7);
    border-left: 4px solid #334155;
    animation: slideInDown 0.3s ease-out;
}

.sa-alert .sa-icon {
    font-size: 1.2rem;
}

.sa-alert .sa-text {
    font-size: 0.8rem;
    color: #f1f5f9;
    font-weight: 500;
    line-height: 1.3;
}

.sa-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.sa-dismiss {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem;
    margin-left: 0.5rem;
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sa-dismiss:hover {
    color: #ef4444;
    transform: scale(1.1);
}

/* Tipos de Alerta */
.sa-alert.empty {
    border-left-color: #ef4444; /* Rojo para revisar cierres */
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, rgba(15, 23, 42, 0.7) 100%);
}

.sa-alert.end-class {
    border-left-color: #f59e0b; /* Naranja/Ambar fin de clase */
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, rgba(15, 23, 42, 0.7) 100%);
}

.sa-alert.start-class {
    border-left-color: #3b82f6; /* Azul ingreso alumnos */
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, rgba(15, 23, 42, 0.7) 100%);
}

.sa-alert.break-soon {
    border-left-color: #10b981; /* Verde esmeralda para recreos inminentes */
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 0%, rgba(15, 23, 42, 0.7) 100%);
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.ww-temp {
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.ww-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #94a3b8;
}

.ww-error {
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 700;
}

.loading-mini {
    color: #94a3b8;
    font-size: 0.85rem;
    animation: pulse 1.5s infinite;
}

.timeline-scale {
    position: relative;
    height: 40px; /* Aumentado para dar espacio a los números */
    margin-bottom: 0.5rem;
    margin-left: calc(1.5rem + 100px); /* Padding de la card (1.5rem) + ancho del label (100px) */
    border-bottom: 2px solid #334155;
}

.scale-mark {
    position: absolute;
    top: 20px; /* La línea arranca más abajo para dejar hueco al texto */
    bottom: 0;
    width: 1px;
    background: #334155;
}

.scale-mark.minor {
    top: 28px;
    background: #475569;
}

.scale-mark span {
    position: absolute;
    top: -20px; /* El texto se ubica justo encima de la línea */
    left: -15px;
    width: 30px;
    text-align: center;
    font-size: 0.75rem;
    color: #cbd5e1;
    font-weight: 700;
}

.scale-mark.minor span {
    font-size: 0.65rem;
    color: #64748b;
    top: -15px;
    font-weight: 400;
}

.timeline-track.cargo-track {
    border-top: 2px dashed rgba(139, 92, 246, 0.2);
    margin-top: 0.5rem;
}

.time-block.block-cargo {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-left: 4px solid #8b5cf6;
    border-radius: 8px;
    z-index: 5;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.time-block.block-cargo .tb-head {
    color: #c084fc;
    font-weight: 800;
}

.dashboard-timelines {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-bottom: 2rem;
}

.timeline-card {
    background: rgba(30, 41, 59, 1); /* Solid back to hide sliding elements perfectly */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem 0; /* Padding superior e inferior solamente */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
    /* overflow: hidden; REMOVIDO PARA PERMITIR POSITION: STICKY EN HIJOS */
}

.timeline-depto-title {
    font-size: 1.25rem;
    color: white;
    font-weight: 800;
    letter-spacing: 1px;
    margin: 0;
    padding-bottom: 0.5rem;
    padding-left: 1.5rem; /* El padding que quitamos a la tarjeta */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    
    /* Sticky title */
    position: sticky;
    left: 0;
    width: max-content; /* Se ajusta solo a su texto, permitiendo ver el fondo */
    background: rgba(30, 41, 59, 1); /* Solid para ocultar info pasando por detrás */
    z-index: 12;
}

/* Wrapper global para scroll horizontal que sincroniza cabecera y tarjetas */
.timeline-global-scroll {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1rem;
    scrollbar-width: none; /* Firefox */
}
.timeline-global-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Contenedor interno que fuerza un ancho mínimo para extender la línea de tiempo */
.timeline-wrapper-inner {
    width: 2400px; /* 15 horas a 160px c/u aprox, excelente legibilidad */
    min-width: 2400px; 
    display: flex;
    flex-direction: column;
    gap: 3rem; /* Separación marcada entre departamentos */
    padding: 0 50vw; /* El espacio vital para el centrado infinito de bordes */
    box-sizing: content-box;
}

.timeline-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Transversal Global Current Time Line */
.global-fixed-cursor {
    position: absolute;
    left: 50%;
    transform: translateX(-50%); /* Centrado exacto por píxel */
    top: 0;
    bottom: 0px; 
    width: 2px;
    background: #ef4444; /* Rojo vibrante */
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.global-fixed-cursor::before {
    content: '';
    position: absolute;
    top: 25px; /* Adjust according to timeline scale top */
    left: -4px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

.cursor-time-bubble {
    position: absolute;
    top: -5px;
    left: -20px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    pointer-events: auto; /* Permite detectar el ratón a pesar del padre */
    cursor: help;
}

.timeline-track {
    display: flex;
    align-items: center;
    height: 60px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.05);
}

.track-label {
    width: calc(100px + 1.5rem); /* Extendemos para cubrir el antiguo padding de timeline-card */
    min-width: calc(100px + 1.5rem);
    padding: 0 10px 0 1.5rem;
    font-weight: 800;
    color: #f97316; /* Color naranja vibrante para aulas */
    font-size: 0.85rem;
    border-right: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    height: 100%;
    
    /* Configuración Sticky para aulas que tapa el rastro de la información */
    box-sizing: border-box; 
    position: sticky;
    left: 0; 
    background: rgba(30, 41, 59, 1); /* Sólido puro coincidente */
    z-index: 10;
}

.track-content {
    position: relative;
    flex: 1;
    height: 100%;
    background: repeating-linear-gradient(
        to right,
        transparent,
        transparent calc((100% / 15) - 1px), /* 15 hours from 7 to 22 */
        rgba(255,255,255,0.02) calc((100% / 15) - 1px),
        rgba(255,255,255,0.02) calc(100% / 15)
    );
}

.time-block {
    position: absolute;
    top: 4px;
    bottom: 4px;
    border-radius: 6px;
    padding: 2px 6px; /* Padding más compacto */
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    box-sizing: border-box; /* CRUCIAL: evita que el padding sume al width original */
}

/* Reglas comunes de ellipsis para el texto interno del bloque */
.time-block > div {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 100%;
}

.block-class {
    background: rgba(99, 102, 241, 0.2);
    border-left: 3px solid var(--primary);
}

.block-break {
    background: repeating-linear-gradient(
        45deg,
        rgba(245, 158, 11, 0.1),
        rgba(245, 158, 11, 0.1) 10px,
        rgba(245, 158, 11, 0.2) 10px,
        rgba(245, 158, 11, 0.2) 20px
    );
    border: 1px dashed rgba(245, 158, 11, 0.5);
}

.tb-head {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
}

.tb-body {
    font-size: 0.75rem;
    color: white;
}

.tb-time {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* ----------------------------------------------------------------- */
/* REAL-TIME GLASSMORPHISM SUMMARY BALLOON                           */
/* ----------------------------------------------------------------- */
.glass-balloon {
    position: absolute;
    top: -10px; /* Alineado a la altura de la burbuja */
    transform: translateX(35px); /* Desplazado a la derecha de la aguja */
    width: 320px;
    background: rgba(15, 23, 42, 0.45); /* Base ultra oscura y transparente */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; /* Que no interrumpa el hover */
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.glass-balloon.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(25px); /* Efecto de acercamiento lateral */
    pointer-events: auto; /* Permitir scroll e interacción */
}

/* Indicador de flecha en el globo hacia el cursor */
.glass-balloon::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 20px; /* Alineado en la zona superior donde está la burbuja */
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid rgba(255, 255, 255, 0.2); 
    backdrop-filter: blur(4px);
}

.gb-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gb-header-title {
    font-size: 0.8rem;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
}

.gb-header-icon {
    font-size: 1.2rem;
    animation: pulse 2s infinite;
}

.gb-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px; /* Prevenir desbordamiento extremo */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.5) transparent;
}

.gb-content::-webkit-scrollbar {
    width: 4px;
}
.gb-content::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.5);
    border-radius: 4px;
}

.gb-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    border-left: 3px solid #6366f1; /* Color clase activo */
}

.gb-item.recreo {
    border-left-color: #f59e0b; /* Color recreo */
}

.gb-item-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}

.gb-item-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
}

.gb-empty {
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
    font-style: italic;
    padding: 1rem 0;
}

/* ----------------------------------------------------------------- */
/* MÓDULO DE REPORTES                                                */
/* ----------------------------------------------------------------- */

#reportes-view {
    overflow-y: visible; /* Permite que el contenedor view crezca y force el scroll global */
    height: max-content;
}

.reports-header {
    background: linear-gradient(135deg, rgba(30,41,59,0.9), rgba(15,23,42,0.95));
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.reports-header h2 {
    color: #f8fafc;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.reports-subtitle {
    color: #94a3b8;
    font-size: 0.9rem;
}

.reports-controls {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
    background: #1e293b;
    padding: 1.5rem;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.reports-form-group {
    flex: 1;
    min-width: 250px;
}

.reports-container {
    animation: fadeIn 0.4s ease-out;
}

.report-metric-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.metric-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.5);
}

/* Colores de Tarjetas Métricas */
.metric-card.primary { border-top: 4px solid var(--primary); }
.metric-card.acc-time { border-top: 4px solid #ef4444; }
.metric-card.depts { border-top: 4px solid #f59e0b; }
.metric-card.staff { border-top: 4px solid #10b981; }
.metric-card.users { border-top: 4px solid #8b5cf6; }

.mc-icon {
    font-size: 2.5rem;
    opacity: 0.9;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.mc-data small {
    display: block;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.mc-data h3 {
    color: #f1f5f9;
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.report-section-title {
    color: #cbd5e1;
    font-size: 1.15rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.report-list-container {
    background: #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.badge-time {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* ----------------------------------------------------------------- */
/* IMPRESIÓN Y EXPORTACIÓN A PDF (ALTO CONTRASTE)                    */
/* ----------------------------------------------------------------- */
@media print {
    body, #content, .view, #view-container, .reports-container, .report-list-container, .metric-card {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .reports-header, .reports-controls, #top-bar, #sidebar, .btn-primary, .btn-secondary, .btn-icon, .filter-group {
        display: none !important; /* Ocultar UI que no suma al PDF */
    }

    .report-metric-cards {
        display: flex !important;
        gap: 1rem !important;
        border-bottom: 2px solid #000;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .metric-card {
        padding: 0.5rem !important;
        border: 1px solid #ccc !important;
    }

    .mc-data h3 {
        color: black !important;
    }

    .mc-data small {
        color: #333 !important;
    }

    .data-table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    .data-table th, .data-table td {
        border: 1px solid #ccc !important;
        color: black !important;
        background: white !important;
        padding: 8px !important;
    }

    .data-table th {
        background: #f1f5f9 !important;
        font-weight: bold !important;
        color: #000 !important;
    }

    .badge-time {
        border: none !important;
        background: none !important;
        color: black !important;
        font-weight: normal !important;
        padding: 0 !important;
    }

    h2, h3, h4, .report-section-title {
        color: black !important;
        border-color: #000 !important;
    }
}

/* ----------------------------------------------------------------- */
/* MÓDULO DE CALENDARIO ACADÉMICO (PREMIUM GLASSMORPISM)             */
/* ----------------------------------------------------------------- */

.calendario-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 2.5rem;
    margin-bottom: 2rem;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.cal-title-box {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.cal-year-badge {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 99px;
    font-weight: 800;
    font-size: 1.2rem;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.cal-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.year-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.year-selector button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.year-selector button:hover {
    background: var(--primary);
}

.calendario-main-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
}

.cal-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.cal-grid-container.monthly-mode {
    grid-template-columns: 1fr;
}

/* Tarjetas de Mes */
.mcard {
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mcard:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.mname {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    margin-bottom: 1.25rem;
    border-left: 4px solid var(--primary);
    padding-left: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Grilla de Días Anual */
.dcont-annual {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.dcont-annual .dlbl {
    font-size: 0.6rem;
    color: #64748b;
    text-align: center;
    padding-bottom: 4px;
}

.dcont-annual .dcell {
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #94a3b8;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

/* Vista Mensual Premium */
.mcard.single-month {
    padding: 2.5rem;
}

.dcont-monthly {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.month-header-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.month-header-grid .dlbl {
    text-align: center;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.month-days-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 120px;
    gap: 1rem;
}

.month-days-grid .dcell {
    padding: 1rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    transition: all 0.2s ease;
    cursor: cell;
}

.month-days-grid .dcell:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
    z-index: 10;
}

.dcell.today {
    border: 2px solid #ffffff !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6), inset 0 0 8px rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1) !important;
    z-index: 5;
    position: relative;
}

.month-days-grid .dcell.selected {
    border: 2px solid #10b981 !important;
    background: rgba(16, 185, 129, 0.1) !important;
}

.dnum {
    font-size: 1.1rem;
    font-weight: 800;
    color: #f8fafc;
}

.dstack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.dtxt {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

/* Sidebar - Referencias y Notas */
.cal-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-x: hidden; /* Evita que las notas rotadas rompan el layout */
    padding: 0.5rem;    /* Espacio para el sombreado de las notas */
}

.categories-box h3, .cork-board h3 {
    font-size: 1rem;
    margin-bottom: 1.25rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cat-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.cat-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
}

.cat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cat-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.cat-item:hover .cat-actions {
    opacity: 1;
}

.btn-icon-small {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--primary);
    color: white;
}

.btn-icon-small.btn-del:hover {
    background: #ef4444;
}

.cat-name {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 600;
}

/* Tablero de Notas Neón */
.cork-board {
    background: rgba(15, 23, 42, 0.3);
    min-height: 400px;
}

.cork-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-icon-add {
    background: var(--primary);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.sticky-notes-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.sticky-note {
    padding: 1rem;
    border-radius: 4px;
    box-shadow: 4px 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    transform: rotate(1deg);
    transition: transform 0.2s ease;
}

.sticky-note:nth-child(even) { transform: rotate(-1.5deg); }

.sticky-note:hover {
    transform: rotate(0) scale(1.05);
    z-index: 5;
}

.sticky-note::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

.note-content {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: #1e293b;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-all;
}

.note-content a {
    color: #6366f1;
    text-decoration: underline;
    font-weight: 700;
    cursor: pointer;
}

.note-content a:hover {
    color: #4f46e5;
}

.note-del {
    position: absolute;
    top: 2px;
    right: 2px;
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: rgba(0,0,0,0.3);
}

/* Modal de Calendario */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-overlay.active { display: flex; }

.cal-modal {
    width: 450px;
    padding: 1.5rem 2.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.cal-modal h2.premium-title {
    margin-top: 0.5rem;
    font-size: 1.5rem;
}

.modal-cat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.modal-cat-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.modal-cat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(3px);
}

.modal-desc-box textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    padding: 0.5rem;
    color: white;
    font-family: inherit;
    resize: none;
    height: 45px; /* Altura mínima para no forzar scroll */
    margin-top: 0.2rem;
}

.modal-form-inline {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.modal-checks-horiz {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    background: rgba(148, 163, 184, 0.05);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
}

.modal-actions-inline {
    display: flex;
    gap: 0.8rem;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-danger-outline-mini, .btn-secondary-mini {
    flex: 1;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.btn-danger-outline-mini {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.btn-danger-outline-mini:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.btn-secondary-mini {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}

.btn-secondary-mini:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-right: auto;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.workload-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    min-width: 32px;
    text-align: center;
    border: 1px solid rgba(129, 140, 248, 0.3);
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.ddot, .docente-evt-badge {
    display: none !important;
}

.is-holiday {
    position: relative;
}

.cal-grid-container:not(.monthly-mode) .dcell {
    height: 55px !important;
    padding: 2px !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.cal-grid-container:not(.monthly-mode) .dstack {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    max-height: 15px;
    overflow: hidden;
}

.cal-grid-container:not(.monthly-mode) .dnum {
    font-size: 0.8rem !important;
}

.cal-grid-container.monthly-mode .dcell {
    height: 15vh !important;
    min-height: 100px;
    overflow: hidden;
    position: relative;
    padding: 8px !important;
}

.cal-grid-container.monthly-mode .dstack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 25px; /* Espacio para el número y badge */
}

.dtxt {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    cursor: help;
    transition: background 0.2s ease;
}

.dtxt:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Tooltip estalizado para el calendario */
.cal-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.cal-tooltip.active {
    opacity: 1;
    pointer-events: auto;
}

.cal-tooltip h4 {
    margin: 0 0 8px 0;
    color: #818cf8;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.dcell.selected {
    outline: 2px solid #6366f1 !important;
    outline-offset: -2px;
    background: rgba(99, 102, 241, 0.2) !important;
    box-shadow: inset 0 0 10px rgba(99, 102, 241, 0.3), 0 0 15px rgba(99, 102, 241, 0.4);
    z-index: 5;
    position: relative;
}

/* Marca de Feriado (X) */
.dcell.is-holiday::before {
    content: "";
    position: absolute;
    inset: 0;
    background: 
        linear-gradient(to top right, transparent 48%, rgba(255, 255, 255, 0.1) 49%, rgba(255, 255, 255, 0.1) 51%, transparent 52%),
        linear-gradient(to top left, transparent 48%, rgba(255, 255, 255, 0.1) 49%, rgba(255, 255, 255, 0.1) 51%, transparent 52%);
    pointer-events: none;
    z-index: 2;
}

.cal-grid-container:not(.monthly-mode) .dcell.is-holiday::before {
    background: 
        linear-gradient(to top right, transparent 45%, rgba(255, 255, 255, 0.08) 48%, rgba(255, 255, 255, 0.08) 52%, transparent 55%),
        linear-gradient(to top left, transparent 45%, rgba(255, 255, 255, 0.08) 48%, rgba(255, 255, 255, 0.08) 52%, transparent 55%);
}

.workload-legend {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.workload-legend .workload-badge {
    position: static;
    display: inline-block;
}

.workload-legend small {
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.2;
}

/* --- PULIDO RELOJ RETRO --- */
#rc-date {
    transition: all 0.3s ease;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
}

#rc-date:hover {
    color: #818cf8 !important; /* Indigo suave */
    border-color: #6366f1 !important; /* Indigo más intenso */
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

/* --- PULIDO NOMBRES DE MESES (CALENDARIO ANUAL) --- */
.mname-link {
    cursor: pointer;
    display: inline-block;
    padding: 0 10px;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.mname-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: #6366f1;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.mname-link:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8 !important;
    outline: 1px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mname-link:hover::after {
    width: 80%;
}

.mname-link:active {
    transform: scale(0.95);
}

.mcard .mname {
    margin: 0;
    border-left: none !important; /* Quitar el borde rígido en annual si se desea, o integrarlo */
}

/* ----------------------------------------------------------------- */
/* MODO EXPORTACIÓN PDF (ALTO CONTRASTE)                             */
/* ----------------------------------------------------------------- */

.cal-pdf-mode {
    background: white !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 !important;
}

.cal-pdf-mode .calendario-header,
.cal-pdf-mode .cal-sidebar,
.cal-pdf-mode .year-selector,
.cal-pdf-mode .btn-export,
.cal-pdf-mode .search-group-wrapper {
    display: none !important;
}

.cal-pdf-mode .mcard, 
.cal-pdf-mode .glass-card {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

.cal-pdf-mode .mname,
.cal-pdf-mode .dnum,
.cal-pdf-mode .dlbl,
.cal-pdf-mode .premium-title,
.cal-pdf-mode .cal-year-badge {
    color: black !important;
}

.cal-pdf-mode .dcell {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    height: auto !important; /* Permitir que monthly-mode o annual-mode decidan */
}

.cal-pdf-mode .dcell.is-holiday::before {
    background: 
        linear-gradient(to top right, transparent 47%, rgba(0, 0, 0, 0.8) 48%, rgba(0, 0, 0, 0.8) 52%, transparent 53%),
        linear-gradient(to top left, transparent 47%, rgba(0, 0, 0, 0.8) 48%, rgba(0, 0, 0, 0.8) 52%, transparent 53%) !important;
    z-index: 10;
    opacity: 1 !important;
}

.cal-pdf-mode .cal-grid-container.monthly-mode .dcell {
    height: 120px !important;
    width: auto !important;
}

/* Ajustes para la grilla anual en PDF */
.cal-pdf-mode #calendario-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 15px !important;
    width: 1000px !important;
    background: white !important;
    padding: 20px !important;
}

.cal-pdf-mode .mcard-annual {
    padding: 10px !important;
    border: 1px solid #ddd !important;
    background: white !important;
    box-shadow: none !important;
}

.cal-pdf-mode .single-month,
.cal-pdf-mode #monthly-view-target {
    width: 1400px !important;
    height: 950px !important;
    max-width: none !important;
    background: white !important;
    padding: 30px !important;
    display: flex !important;
    flex-direction: column !important;
}

.cal-pdf-mode .dcont-monthly {
    width: 1300px !important;
    flex: 1 !important;
}

.cal-pdf-mode .dcell.empty {
    background: white !important;
    border: none !important;
}

.cal-pdf-mode .dtxt {
    background: rgba(0, 0, 0, 0.05) !important;
    color: #1a1a1a !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    font-weight: bold !important;
}

.cal-pdf-mode .mname {
    border-left: 5px solid black !important;
}

.cal-pdf-mode .workload-badge {
    background: white !important;
    border: 1px solid black !important;
    color: black !important;
}
/* ----------------------------------------------------------------- */
/* UTILERÍAS DE GLASSMORPISM                                         */
/* ----------------------------------------------------------------- */
.glass-card {
    background: rgba(30, 41, 59, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    border-radius: 12px;
}

/* ----------------------------------------------------------------- */
/* SELECTOR DE VISTA SEGMENTADO                                      */
/* ----------------------------------------------------------------- */
.view-selector-segmented {
    display: flex;
    background: rgba(15, 23, 42, 0.5);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    gap: 4px;
    align-items: center;
}

.calendario-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cal-title-box {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cal-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* ----------------------------------------------------------------- */
/* BUSCADOR INTELIGENTE                                              */
/* ----------------------------------------------------------------- */
.search-group-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    max-width: 500px;
    justify-content: flex-end;
}

.cal-search-container {
    display: contents; /* Deshabilitado por el nuevo layout, pero mantenemos compatibilidad si hiciera falta */
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    padding: 0.1rem 1rem;
    transition: all 0.3s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
    background: rgba(15, 23, 42, 0.6);
    transform: translateY(-1px);
}

.search-icon {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-right: 0.75rem;
}

#cal-search-input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}

.btn-clear-search {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.btn-clear-search:hover {
    background: var(--error);
    color: white;
}

.search-footer-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
}

.btn-sync-holidays {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 0.65rem 1.25rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.header-actions-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions-right .btn-export {
    padding: 0.65rem 1.5rem;
    font-weight: 700;
    border-radius: 12px;
}

.btn-sync-holidays:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.btn-sync-holidays i {
    color: #ef4444;
}

/* Efecto de Resaltado de Búsqueda */
.dcell.search-highlight {
    transform: scale(1.15) !important;
    z-index: 100 !important;
    border: 2px solid white !important;
    box-shadow: 0 0 30px var(--primary) !important;
    background: rgba(99, 102, 241, 0.3) !important;
    filter: brightness(1.2);
}

.segmented-item {
    cursor: pointer;
    position: relative;
}

.segmented-item input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.segmented-item span {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    transition: all 0.2s ease;
    white-space: nowrap; /* Evita que Modo Docente se rompa */
}

.segmented-item input:checked + span {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.segmented-item:hover span {
    color: white;
}

/* ----------------------------------------------------------------- */
/* MODO DOCENTE                                                      */
/* ----------------------------------------------------------------- */
.cal-grid-container.docente-mode {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.docente-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2.5rem;
    color: #cbd5e1;
    margin-bottom: 2rem;
    min-height: 297mm; /* Proporción A4 */
}

.docente-row {
    display: grid;
    grid-template-columns: 30% 70%; /* Cambiado de 280px 1fr para cumplir con requerimiento 30/70 */
    gap: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
    align-items: flex-start;
}

.docente-row:last-child { border-bottom: none; }

.docente-month-col .mname {
    color: white;
    border-left-color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.docente-month-col .dcont-annual {
    transform: scale(0.9);
    transform-origin: top left;
}

.docente-month-col .dcell {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    transition: all 0.2s ease;
}

.docente-month-col .dcell.today {
    border: 1px solid #ffffff !important;
    background: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.docente-refs-col {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 1.5rem;
    max-height: 330px; /* Coincide con el alto del grid escalado */
    overflow-y: hidden;
    position: relative;
}

.ref-line {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 1.6rem;
    height: auto;
    display: flex;
    align-items: flex-start;
    font-size: 0.85rem;
    color: #94a3b8;
    padding: 0.3rem 0.5rem;
    line-height: 1.3;
    word-break: break-word;
    white-space: normal;
    flex-shrink: 0;
}

.ref-line .ref-date {
    font-weight: bold;
    margin-right: 0.5rem;
    color: var(--primary);
    min-width: 30px;
    flex-shrink: 0;
}

.ref-line .ref-desc {
    flex: 1;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Estilos para el Checkbox de Privacidad en el Modal */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-row label {
    font-size: 0.9rem;
    color: #cbd5e1;
    cursor: pointer;
}

/* Ocultar eventos privados si se desea */
.ddot.is-private {
    border: 1px solid #fff;
    box-shadow: 0 0 5px rgba(255,255,255,0.5);
}

.dtxt.is-private {
    font-style: italic;
    opacity: 0.8;
}

.dtxt.is-private::before {
    content: '🔒 ';
}

.docente-evt-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
    pointer-events: none;
}

.cal-grid-container.annual-mode .docente-evt-badge {
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
}

/* Modo Exportación PDF - Ajustes de Contraste Total */
.cal-pdf-mode {
    background-color: #ffffff !important;
    background: #ffffff !important;
}

.cal-pdf-mode body {
    background-color: #ffffff !important;
}

.cal-pdf-mode * {
    color: #000000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-color: #dddddd !important;
}

.cal-pdf-mode .docente-page {
    width: 210mm !important; 
    height: 297mm !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: none !important;
    padding: 5mm 20mm !important; /* Margen superior/inferior reducido de 10mm a 5mm */
}

.cal-pdf-mode .docente-row {
    grid-template-columns: 35% 65% !important;
    gap: 5mm !important; /* Reducido de 8mm para ganar espacio vertical */
    border-bottom: none !important; /* Quitar la línea divisora entre meses */
    padding-bottom: 0 !important; /* Eliminar padding extra entre meses */
    margin-bottom: 3mm !important; /* Pequeña separación controlada */
}

.cal-pdf-mode .docente-month-col .dcell {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
}

.cal-pdf-mode .docente-month-col .dcell.today {
    background: #f0f0f0 !important;
    border: 2px solid #000000 !important;
}

.cal-pdf-mode .ref-line {
    border-bottom: 1px solid #000000 !important;
    font-size: 0.75rem !important;
    padding: 0.15rem 0.4rem !important;
    min-height: 1.3rem !important;
    line-height: 1.2 !important;
}

.cal-pdf-mode .ref-date {
    font-size: 0.75rem !important;
    font-weight: bold !important;
}

.cal-pdf-mode .dcell {
    border: 1px solid #000000 !important;
}

.cal-pdf-mode .docente-evt-badge,
.cal-pdf-mode .ddot {
    display: none !important;
}

/* ----------------------------------------------------------------- */
/* TOOLTIP DE EVENTOS MEJORADO                                       */
/* ----------------------------------------------------------------- */
.cal-tooltip {
    position: fixed;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    max-width: 350px;
    min-width: 220px;
    transform: translateY(10px);
}

.cal-tooltip.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cal-tooltip .tooltip-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cal-tooltip .event-item {
    margin-bottom: 0.75rem;
    display: flex;
    gap: 0.75rem;
}

.cal-tooltip .event-item:last-child {
    margin-bottom: 0;
}

.cal-tooltip .event-color {
    width: 4px;
    height: auto;
    min-height: 1.5rem;
    border-radius: 2px;
    flex-shrink: 0;
}

.cal-tooltip .event-info {
    flex: 1;
}

.cal-tooltip .event-cat {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    margin-bottom: 2px;
}

.cal-tooltip .event-desc {
    font-size: 0.875rem;
    line-height: 1.4;
    word-break: break-word;
}

.cal-tooltip .event-privacy {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-top: 2px;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 4px;
}
/* ----------------------------------------------------------------- */
/* ESTILOS PARA FORMULARIOS M2M Y MODALES GRANDES                    */
/* ----------------------------------------------------------------- */
.modal-large {
    max-width: 800px;
    width: 90%;
}

.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.form-group.half {
    flex: 1;
}

.m2m-container {
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.inst-m2m-block {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.inst-m2m-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.75rem;
}

.dept-m2m-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-left: 1.5rem;
    transition: opacity 0.3s ease;
}

.dept-m2m-list.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.dept-check-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.75rem !important;
    padding: 6px 10px !important;
    border-radius: 6px;
    width: 100%;
}

.dept-check-item input[type="checkbox"] {
    margin: 0 !important;
    width: 1.1rem !important;
    height: 1.1rem !important;
    cursor: pointer;
    flex-shrink: 0;
}

.correlativas-list {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 180px;
    overflow-y: auto;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px;
    margin-top: 0.5rem;
}

.dept-check-item label {
    font-size: 0.85rem;
    cursor: pointer;
}

.badge-inst {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-dept {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
    margin: 1px;
}


.btn-close-x {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close-x:hover {
    color: white;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* ----------------------------------------------------------------- */
/* ESTILOS DE IMPRESIÓN PROFESIONAL                                   */
/* ----------------------------------------------------------------- */
@media print {
    @page {
        margin: 0.5cm !important;
    }

    html, body {
        background: white !important;
        color: black !important;
        overflow: visible !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #sidebar, #top-bar, .modal, .btn-primary, .btn-secondary, .btn-edit, .btn-delete, .module-header button, .btn-toggle-mini {
        display: none !important;
    }

    #app, .screen, #main-screen, #content, #view-container {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    .view {
        padding: 0 !important;
        margin: 0 !important;
    }

    .data-table {
        background: white !important;
        border: 1px solid #000 !important;
        color: black !important;
        width: 100% !important;
        font-size: 10pt !important;
        margin-top: 10px !important;
    }

    .data-table th {
        background: #f0f0f0 !important;
        color: black !important;
        border-bottom: 2px solid #000 !important;
    }

    .data-table td {
        border-bottom: 1px solid #ddd !important;
    }

    /* Encabezado Institucional para Impresión */
    .print-header {
        display: block !important;
        margin: 0 0 20px 0 !important;
        padding: 0 0 10px 0 !important;
        border-bottom: 3px solid #000;
    }

    .print-header h1 {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 18pt;
        text-transform: uppercase;
    }

    .print-header h2 {
        margin: 5px 0 !important;
        font-size: 14pt;
        color: #444;
    }

    .print-header .print-meta {
        font-size: 9pt;
        color: #666;
        text-align: right;
    }
}

/* Ocultar encabezado de impresión en pantalla */
.print-header {
    display: none;
}
