/* =====================================================================
   SISTEMA DE GESTIÓN SOCIOEDUCATIVA - IRSE-ARABA
   Estilos Principales, Responsivos y Accesibles
   ===================================================================== */

:root {
    --color-primary: #0284c7;
    --color-primary-dark: #0369a1;
    --color-primary-light: #e0f2fe;
    --color-secondary: #0f766e;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-danger-light: #fef2f2;
    --color-warning: #d97706;
    --color-warning-light: #fffbeb;
    --color-text-main: #0f172a;
    --color-text-muted: #64748b;
    --color-bg-page: #f8fafc;
    --color-bg-card: #ffffff;
    --color-border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --layout-max-width: 1440px;
    --layout-padding-x: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

html, body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

.card[id],
div[id^="seccion-"] {
    scroll-margin-top: 80px;
}

img, svg, video, canvas, audio, iframe, embed, object {
    display: block;
    max-width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-bg-page);
    color: var(--color-text-main);
    line-height: 1.5;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* Header Global y Barra de Búsqueda */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 8px var(--layout-padding-x);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-main);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barra de Búsqueda Global */
.global-search-container {
    flex: 1 1 auto;
    max-width: 580px;
    min-width: 280px;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-input {
    width: 100%;
    height: 42px;
    padding: 0 16px 0 42px;
    border-radius: 22px;
    border: 1px solid var(--color-border);
    background: #f1f5f9;
    font-size: 14px;
    color: var(--color-text-main);
    transition: all 0.2s ease;
}

.search-input:focus {
    background: #ffffff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: var(--color-text-muted);
    pointer-events: none;
    line-height: 1;
}

.search-dropdown-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    margin-top: 0;
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    max-height: 380px;
    overflow-y: auto;
    display: none;
}

.search-dropdown-item {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text-main);
    text-decoration: none;
    transition: background 0.15s;
}

.search-dropdown-item:hover {
    background: #f8fafc;
    text-decoration: none;
}

/* Selector de Centro Activo y Usuario */
.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.centro-selector-form select {
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main);
    cursor: pointer;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botón de Ayuda en Cabecera (Desktop) */
.header-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: #f8fafc;
    border: 1px solid var(--color-border);
    color: #475569;
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    line-height: 1;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.header-help-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--color-text-main);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.header-help-btn:active {
    background: #e2e8f0;
}

.header-help-btn .help-btn-icon {
    display: inline-block;
    user-select: none;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Barra de Navegación Principal */
.app-nav {
    background: #ffffff;
    border-bottom: 1px solid var(--color-border);
}

.nav-inner {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 0 var(--layout-padding-x);
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.nav-link {
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.nav-link.active {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary);
}

/* Layout y Contenedor Principal */
.main-wrapper {
    flex: 1;
    max-width: var(--layout-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 24px var(--layout-padding-x);
}

/* Contenedor genérico para vistas */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 14px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text-main);
}

.page-subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary { background: var(--color-primary); color: #ffffff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--color-danger); color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--color-success); color: #ffffff; }
.btn-success:hover { background: #15803d; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text-main); }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Tarjetas y Contenedores */
.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
    min-width: 0;
    max-width: 100%;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-text-main);
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Alertas y Notificaciones */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.alert-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* Badges / Etiquetas */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* Estilos Específicos del Diario y Alertas Visuales (Sección 2.3 y 5.2) */
.diario-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}

.diario-card:hover {
    box-shadow: var(--shadow-md);
}

/* Resaltado visual en rojo para Incidencia Significativa */
.diario-card.alerta-roja {
    border-left: 6px solid var(--color-danger);
    background: var(--color-danger-light);
}

/* Resaltado visual en ámbar para Pendiente de Reunión */
.diario-card.alerta-ambar {
    border-left: 6px solid var(--color-warning);
    background: var(--color-warning-light);
}

.diario-card.alerta-doble {
    border-left: 6px solid var(--color-danger);
    background: #fff7ed;
}

.diario-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.diario-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-text-main);
    line-height: 1.3;
}

.diario-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.diario-content {
    font-size: 14.5px;
    line-height: 1.6;
    color: #334155;
    white-space: pre-line;
}

.diario-footer {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.diario-audit-trace {
    font-style: italic;
    color: #475569;
    font-weight: 500;
}

/* Formulario Híbrido del Diario (Sección 2.3) */
.hybrid-form-top {
    background: #f8fafc;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--color-border);
}

.hybrid-form-bottom {
    background: #ffffff;
}

/* Tablas Responsivas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
}

.table-custom {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table-custom th {
    background: #f8fafc;
    color: var(--color-text-muted);
    text-align: left;
    padding: 11px 14px;
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.table-custom td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table-custom tr:hover {
    background: #fbfcfe;
}

.table-custom td:last-child,
.table-custom th:last-child {
    white-space: nowrap;
}

/* Utilidades de visibilidad responsiva */
.desktop-only {
    display: flex !important;
}

.mobile-only {
    display: none !important;
}

/* Clases de Layout Dividido (Sustituyen estilos en línea rígidos) */
.layout-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
}

.layout-sidebar-right {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
}

.layout-admin-split {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}

.layout-split > *,
.layout-sidebar-right > *,
.layout-admin-split > * {
    min-width: 0;
    max-width: 100%;
}

/* Formularios y Grids Responsivos */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

/* Formularios y Controles */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text-main);
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    outline: none;
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
    padding-right: 36px;
    cursor: pointer;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.app-footer {
    padding: 24px;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

/* Botón Hamburguesa Móvil */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 38px;
    height: 38px;
    padding: 9px 8px;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--color-text-main);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.header-mobile-controls {
    display: none;
    align-items: center;
}

/* Drawer / Menú Lateral Móvil */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 86vw);
    background: #ffffff;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-drawer.open {
    transform: translateX(0);
}

.mobile-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.mobile-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
}

.drawer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-logo {
    height: 32px;
    width: auto;
}

.drawer-close-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    background: #f8fafc;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
}

.drawer-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
}

.drawer-search-wrapper {
    position: relative;
}

.drawer-section {
    display: flex;
    flex-direction: column;
}

.drawer-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 8px;
}

.drawer-nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--color-text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s;
}

.drawer-nav-item:hover, .drawer-nav-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    text-decoration: none;
}

.drawer-user-card {
    margin-top: auto;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

/* Modales Responsivos */
.modal-dialog {
    width: 100% !important;
    max-width: min(650px, calc(100vw - 24px)) !important;
    margin: 16px auto !important;
    max-height: 90vh;
    overflow-y: auto;
}

/* ==========================================================================
   Media Queries Responsivas
   ========================================================================== */
@media (max-width: 991px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }

    .mobile-menu-toggle {
        display: flex;
        flex-shrink: 0;
    }

    .header-mobile-controls {
        flex-shrink: 0;
    }

    .brand-section {
        min-width: 0;
        flex: 1;
        gap: 10px;
    }

    .brand-subtitle {
        max-width: 170px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Ocultar menú horizontal en móvil y tablet: ya se encuentra en el menú hamburguesa */
    .app-nav {
        display: none !important;
    }

    .layout-split,
    .layout-sidebar-right,
    .layout-admin-split {
        grid-template-columns: 1fr !important;
        gap: 18px !important;
    }

    .header-inner {
        padding: 8px 14px;
        min-height: 52px;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .main-wrapper {
        padding: 14px 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
    }

    .page-title {
        font-size: 19px;
    }

    .card {
        padding: 14px !important;
        margin-bottom: 14px;
        border-radius: var(--radius);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .card-title {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .form-grid,
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .diario-header {
        flex-direction: column;
        gap: 8px;
    }

    .diario-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .diario-content-full {
        font-size: 14.5px !important;
        line-height: 1.7 !important;
    }

    .btn {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 13.5px;
    }

    .btn-sm {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 12.5px;
    }

    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    input[type="number"],
    select,
    textarea {
        min-height: 40px;
        font-size: 16px !important; /* Evita que Safari en iOS haga zoom forzado molesto al pulsar en campos */
    }

    /* Tabla responsiva y no aplastada en móviles */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 14px;
        background: 
            linear-gradient(to right, white 30%, rgba(255, 255, 255, 0)),
            linear-gradient(to right, rgba(255, 255, 255, 0), white 70%) 100% 0,
            radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
    }

    .table-custom {
        min-width: 720px !important;
        width: 100%;
    }

    .table-custom th {
        padding: 10px 12px;
        font-size: 12.5px;
        white-space: normal !important;
        line-height: 1.25;
        min-width: 85px;
        vertical-align: bottom;
    }

    .table-custom td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: normal;
        word-break: normal;
        vertical-align: middle;
    }

    .table-custom th:last-child,
    .table-custom td:last-child {
        white-space: nowrap !important;
        min-width: 90px;
    }

    /* Grupo de acciones en celdas de tabla */
    .table-actions {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
    }

    /* Chips de navegación rápida en móviles (desplazables horizontalmente tipo swipe) */
    .quick-nav-pills {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
        margin-bottom: 14px !important;
        gap: 8px;
        scrollbar-width: none;
    }
    .quick-nav-pills::-webkit-scrollbar {
        display: none;
    }
    .quick-nav-pills a {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .brand-title {
        font-size: 14.5px;
    }

    .brand-subtitle {
        max-width: 125px;
    }

    .brand-logo {
        height: 34px;
    }

    .table-custom {
        min-width: 680px !important;
    }

    .valora-options-grid.grid-7,
    .valora-options-grid.grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .valora-option-btn {
        min-height: 42px !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
    }
}

/* ==========================================================================
   Editor de Texto Enriquecido (WYSIWYG Nativo)
   ========================================================================== */
.rich-editor-wrapper {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #ffffff;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rich-editor-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.rich-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: #f8fafc;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
    user-select: none;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 5px 9px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.toolbar-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.toolbar-btn:active {
    background: #cbd5e1;
}

.toolbar-btn.active {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #0369a1;
    font-weight: 700;
    box-shadow: inset 0 1px 2px rgba(2, 132, 199, 0.2);
}

.toolbar-sep {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: #cbd5e1;
    margin: 0 4px;
}

.rich-editor-content {
    min-height: 180px;
    max-height: 500px;
    overflow-y: auto;
    padding: 14px 16px;
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--color-text-main);
    outline: none;
}

.rich-editor-content[placeholder]:empty:before {
    content: attr(placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.rich-editor-content p {
    margin-bottom: 8px;
}

.rich-editor-content ul, .rich-editor-content ol {
    margin: 8px 0 8px 24px;
}

.rich-editor-content blockquote {
    border-left: 4px solid var(--color-primary);
    background: #f0f9ff;
    padding: 8px 14px;
    margin: 10px 0;
    font-style: italic;
    color: #0369a1;
}

.rich-editor-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 12px 0 6px 0;
}

/* Barra inferior del editor y contador */
.rich-editor-statusbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: #f8fafc;
    border-top: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Botón y estado de Dictado por Voz */
.btn-dictar-voz {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-dictar-voz:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-dictar-voz.is-recording {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #dc2626 !important;
    animation: pulseDictado 1.5s infinite;
}

@keyframes pulseDictado {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.dictado-pulse-dot {
    display: inline-block;
    animation: blinkDot 1s infinite alternate;
}

@keyframes blinkDot {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

.dictado-live-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    background: #f0f9ff;
    border-bottom: 1.5px solid #bae6fd;
    font-size: 13.5px;
    color: #0369a1;
    animation: fadeInSlideDown 0.2s ease-out;
}

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

.dictado-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #dc2626;
    background: #ffffff;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #fecaca;
    font-size: 11.5px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dictado-live-phrase {
    color: #0f172a;
    font-style: italic;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Desplegable de Plantillas */
.dropdown-plantillas-container {
    position: relative;
    display: inline-block;
}

.dropdown-plantillas-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 250px;
    max-width: 320px;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding: 6px 0;
    display: flex;
    flex-direction: column;
}

.dropdown-plantillas-item {
    padding: 8px 14px;
    font-size: 13px;
    color: #1e293b;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background 0.12s;
}

.dropdown-plantillas-item:hover {
    background: #f0f9ff;
    color: #0284c7;
}

.dropdown-plantillas-footer {
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
    padding-top: 4px;
}

.dropdown-plantillas-manage-btn {
    width: 100%;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #0369a1;
    background: #f8fafc;
    border: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.dropdown-plantillas-manage-btn:hover {
    background: #e0f2fe;
}

/* Estilo para contenido de texto enriquecido en vistas de lectura (detalle del diario, informes) */
.diario-content-full > :first-child {
    margin-top: 0 !important;
}

.diario-content-full > :last-child {
    margin-bottom: 0 !important;
}

.diario-content-full p {
    margin-bottom: 10px;
}

.diario-content-full ul, .diario-content-full ol {
    margin: 8px 0 8px 24px;
}

.diario-content-full ul {
    list-style-type: disc;
}

.diario-content-full ol {
    list-style-type: decimal;
}

.diario-content-full li {
    margin-bottom: 3px;
    line-height: 1.5;
}

.diario-content-full blockquote {
    border-left: 4px solid var(--color-primary);
    background: #f0f9ff;
    padding: 8px 14px;
    margin: 10px 0;
    font-style: italic;
    color: #0369a1;
}

.diario-content-full h3 {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 12px 0 6px 0;
}

.diario-content-full h4 {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 10px 0 4px 0;
}

.diario-content-full strong, .diario-content-full b {
    font-weight: 700;
}

.diario-content-full em, .diario-content-full i {
    font-style: italic;
}

.diario-content-full u {
    text-decoration: underline;
}

/* ==========================================================================
   Línea de Tiempo Lateral y Navegación del Diario
   ========================================================================== */
.diario-detalle-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 24px;
    align-items: start;
    margin-bottom: 30px;
}

@media (max-width: 1080px) {
    .diario-detalle-layout {
        grid-template-columns: 1fr;
    }
}

.diario-timeline-sidebar {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.timeline-sidebar-header {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-sidebar-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-sidebar-count {
    font-size: 11px;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.timeline-items-scroll {
    overflow-y: auto;
    padding: 16px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.timeline-items-scroll::-webkit-scrollbar {
    width: 6px;
}

.timeline-items-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.timeline-item-wrapper {
    position: relative;
    padding-left: 18px;
    padding-bottom: 14px;
    border-left: 2px solid #e2e8f0;
}

.timeline-item-wrapper:last-child {
    border-left-color: transparent;
    padding-bottom: 2px;
}

.timeline-marker {
    position: absolute;
    left: -7px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #94a3b8;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px #cbd5e1;
    transition: all 0.2s ease;
}

.timeline-item-wrapper.is-current .timeline-marker {
    background: #0284c7;
    width: 14px;
    height: 14px;
    left: -8px;
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.3);
}

.timeline-item-wrapper.is-alerta-roja .timeline-marker {
    background: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.timeline-item-wrapper.is-alerta-ambar .timeline-marker {
    background: #d97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
}

.timeline-item-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.timeline-item-link:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
    transform: translateX(2px);
}

.timeline-item-wrapper.is-current .timeline-item-link {
    background: #f0f9ff;
    border-color: #bae6fd;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.08);
}

.timeline-item-date {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.timeline-item-wrapper.is-current .timeline-item-date {
    color: #0284c7;
}

.timeline-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.timeline-item-meta {
    font-size: 11.5px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Efecto de resaltado al regresar al listado */
@keyframes flashReturn {
    0% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.6);
        border-color: #0284c7;
    }
    50% {
        box-shadow: 0 0 0 8px rgba(2, 132, 199, 0.25);
        border-color: #0284c7;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0);
    }
}

.registro-resaltado-retorno {
    animation: flashReturn 2.2s ease !important;
    border-color: #0284c7 !important;
}

/* ==========================================================================
   Botón flotante "Volver arriba" (Scroll to Top)
   ========================================================================== */
.btn-scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #0f172a;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 990;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s, background-color 0.15s, box-shadow 0.15s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-scroll-top.visible {
    opacity: 0.85;
    visibility: visible;
    transform: translateY(0);
}

.btn-scroll-top:hover {
    opacity: 1;
    background: var(--color-primary, #0284c7);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
    transform: translateY(-2px);
}

.btn-scroll-top:active {
    transform: translateY(0);
}

@media (max-width: 640px) {
    .btn-scroll-top {
        bottom: 20px;
        right: 16px;
        width: 36px;
        height: 36px;
    }
}

/* ==========================================================================
   NAVEGACIÓN Y MENÚ PULIDO DE ENTRADA DEL DIARIO (DIARIO SHOW)
   ========================================================================== */
.diario-show-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.btn-volver-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: #1e293b;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-volver-link:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: var(--color-primary);
    text-decoration: none;
}

.btn-volver-link svg {
    color: var(--color-primary);
    transition: transform 0.15s ease;
}

.btn-volver-link:hover svg {
    transform: translateX(-2px);
}

.diario-show-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.diario-menu-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.btn-menu-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 0;
}

.btn-menu-dots:hover,
.btn-menu-dots.active {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.diario-popover-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 195px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.15), 0 4px 8px -2px rgba(15, 23, 42, 0.06);
    z-index: 1050;
    padding: 6px;
    animation: menuFadeIn 0.15s ease-out;
}

.diario-popover-menu.show {
    display: block;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popover-menu-header {
    padding: 6px 10px 4px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
}

.popover-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: #1e293b;
    border-radius: 6px;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.12s, color 0.12s;
}

.popover-menu-item:hover {
    background: #f0f9ff;
    color: var(--color-primary);
    text-decoration: none;
}

.popover-menu-item.danger {
    color: #dc2626;
}

.popover-menu-item.danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.diario-show-header-title {
    margin-bottom: 18px;
}

.diario-show-header-title .page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
}

@media (max-width: 640px) {
    .diario-show-header-title .page-title {
        font-size: 20px;
    }
    .btn-volver-link span {
        font-size: 13px;
    }
}




