:root {
    --primary-color: #e53e3e;    /* Rojo Torpedo de Salvamento */
    --secondary-color: #c53030;  /* Rojo Profundo */
    --accent-color: #ecc94b;     /* Amarillo de Bandera de Mar Calmo / Precaución */
    --accent-hover: #d69e2e;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-color: #1a202c;
    --success-color: #2f855a;
    --border-color: #e2e8f0;
    --miel-blue: #1a365d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   ESTILO DE INICIO DE SESIÓN
   ========================================================================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 30px 20px;
    background: linear-gradient(135deg, rgba(26,54,93,0.92) 0%, rgba(197,48,48,0.88) 100%), 
                url('https://images.unsplash.com/photo-1519046904884-53103b34b206?auto=format&fit=crop&w=1200&q=80');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.auth-card {
    background: rgba(255, 255, 255, 0.96);
    padding: 50px 45px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35), 
                inset 0 0 0 2px rgba(236, 201, 75, 0.4);
    width: 100%;
    max-width: 520px; 
    backdrop-filter: blur(8px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-top: 8px solid var(--primary-color);
}

.auth-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.45), 
                inset 0 0 0 3px rgba(236, 201, 75, 0.6);
}

.auth-header { 
    text-align: center; 
    margin-bottom: 35px; 
}

.logo-container { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    margin-bottom: 20px; 
}

.auth-logo { 
    max-height: 110px;
    width: auto; 
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.auth-header h2 { 
    color: var(--miel-blue); 
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-top: 10px; 
}

.auth-header p { 
    font-size: 0.95rem; 
    color: #4a5568; 
    font-weight: 500;
    margin-top: 4px;
}

.auth-form h3 {
    font-size: 1.4rem;
    color: var(--secondary-color);
    margin-bottom: 25px;
    font-weight: 700;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 6px;
    display: inline-block;
}

.form-instructions {
    font-size: 0.9rem;
    color: #4a5568;
    margin-bottom: 15px;
}

.form-group { 
    margin-bottom: 22px; 
}

.form-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-weight: 700; 
    font-size: 0.9rem; 
    color: var(--miel-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    color: #2d3748;
    background-color: #ffffff;
    transition: all 0.25s ease;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus { 
    outline: none; 
    border-color: var(--primary-color); 
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.2);
    background-color: #fff;
}

.auth-form-helpers {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 10px;
    flex-wrap: wrap;
}

.remember-me-container { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}
.remember-me-container input { 
    width: 18px; 
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer; 
}
.remember-me-container label { 
    margin-bottom: 0; 
    cursor: pointer; 
    font-weight: 600; 
    color: #4a5568; 
    font-size: 0.9rem;
}

.forgot-link {
    color: var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}
.forgot-link:hover {
    color: var(--miel-blue);
    text-decoration: underline;
}

.btn-guardavidas {
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 14px !important;
    font-size: 1.05rem !important;
    box-shadow: 0 4px 10px rgba(229, 62, 62, 0.3);
}

.auth-switch { 
    text-align: center; 
    margin-top: 25px; 
    font-size: 0.95rem; 
    color: #4a5568;
}
.auth-switch a { 
    color: var(--primary-color); 
    text-decoration: none; 
    font-weight: bold; 
}
.auth-switch a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   MODAL OLVIDÉ MI CONTRASEÑA
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 54, 93, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeInModal 0.25s ease-out;
}

.modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 460px;
    padding: 35px;
    border-radius: 16px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    border-top: 6px solid var(--accent-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.modal-header h3 {
    color: var(--miel-blue);
    font-size: 1.35rem;
    font-weight: 700;
}
.btn-close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.2s;
}
.btn-close-modal:hover { color: var(--primary-color); }

.modal-desc {
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
}
.modal-actions .btn { width: auto; padding: 10px 20px; }
.btn-cancel { background: #edf2f7; color: #4a5568; font-weight: bold; border: none; border-radius: 6px; cursor: pointer; }
.btn-cancel:hover { background: #e2e8f0; }

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.form-group input[type=number]::-webkit-inner-spin-button, 
.form-group input[type=number]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
.form-group input[type=number] { -moz-appearence: textfield; }

/* ==========================================================================
   DASHBOARD GENERAL
   ========================================================================== */
.role-badge {
    margin-left: 12px;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--secondary-color); }
.btn-success { background-color: var(--success-color); color: white; }
.btn-success:hover { background-color: #225e3b; }
.btn-sm { width: auto; padding: 6px 12px; font-size: 0.85rem; background-color: #edf2f7; color: var(--secondary-color); }
.btn-sm:hover { background-color: var(--border-color); }
.btn-pdf { background-color: #2b6cb0; color: white; width: auto; padding: 8px 16px; font-size: 0.9rem; border: none; border-radius: 6px; cursor: pointer;}
.btn-pdf:hover { background-color: #1a446c; }

.btn-action { background: none; border: 1px solid transparent; padding: 4px 8px; font-size: 0.85rem; border-radius: 4px; cursor: pointer; font-weight: 500; transition: all 0.2s; margin: 0 2px; }
.btn-edit { color: #2b6cb0; border-color: #edf2f7; background-color: #f7fafc; }
.btn-edit:hover { background-color: #ebf8ff; border-color: #bee3f8; }
.btn-delete { color: var(--primary-color); border-color: #edf2f7; background-color: #f7fafc; }
.btn-delete:hover { background-color: #fff5f5; border-color: #fed7d7; }

.navbar { background-color: var(--secondary-color); color: white; padding: 15px 40px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.navbar-brand { display: flex; align-items: center; font-size: 1.3rem; font-weight: bold; }
.navbar-logo { height: 40px; width: auto; margin-right: 12px; object-fit: contain; }
.navbar-user { color: #edf2f7; font-weight: normal; font-size: 1rem; background: rgba(255,255,255,0.15); padding: 4px 10px; border-radius: 20px; margin-left: 5px;}
.navbar-menu { display: flex; gap: 15px; }
.nav-link { background: none; border: none; color: #cbd5e0; padding: 8px 16px; font-size: 1rem; cursor: pointer; border-radius: 6px; transition: all 0.2s; font-weight: 500; }
.nav-link:hover, .nav-link.active { background-color: rgba(255, 255, 255, 0.2); color: white; }
.btn-logout { background: none; border: 1px solid rgba(255,255,255,0.4); color: white; padding: 8px 14px; cursor: pointer; border-radius: 6px; transition: background 0.2s; }
.btn-logout:hover { background-color: var(--primary-color); border-color: var(--primary-color); }

.miel-container { display: flex; gap: 25px; min-height: 550px; background: var(--card-bg); border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); overflow: hidden; padding: 20px; }
.miel-sidebar { width: 280px; border-right: 1px solid var(--border-color); padding-right: 20px; flex-shrink: 0; }
.miel-sidebar h3 { color: var(--miel-blue); font-size: 1.1rem; margin-bottom: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
.miel-subjects-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.miel-subject-item { padding: 12px 16px; background: #f7fafc; border-radius: 8px; cursor: pointer; font-weight: 600; border-left: 4px solid transparent; transition: all 0.2s; font-size: 0.95rem; }
.miel-subject-item:hover { background: #edf2f7; color: var(--secondary-color); }
.miel-subject-item.selected { background: #eef2f7; border-left-color: var(--miel-blue); color: var(--miel-blue); }

.miel-main-panel { flex-grow: 1; display: flex; flex-direction: column; position: relative; }
.miel-main-panel.placeholder-active { justify-content: center; align-items: center; text-align: center; background: #fafafa; border: 2px dashed var(--border-color); border-radius: 8px; }
.miel-placeholder { color: #718096; font-size: 1.1rem; padding: 40px; }
.miel-subject-title { color: var(--miel-blue); font-size: 1.5rem; margin-bottom: 20px; border-bottom: 2px solid #edf2f7; padding-bottom: 10px; }

.miel-tabs { display: flex; border-bottom: 2px solid var(--border-color); gap: 5px; margin-bottom: 20px; overflow-x: auto; }
.miel-tab-link { background: #f7fafc; border: 1px solid var(--border-color); border-bottom: none; padding: 10px 18px; font-weight: bold; border-radius: 6px 6px 0 0; cursor: pointer; color: #4a5568; font-size: 0.9rem; transition: all 0.2s; white-space: nowrap; }
.miel-tab-link:hover { background: #edf2f7; }
.miel-tab-link.active { background: var(--card-bg); color: var(--secondary-color); border-top: 3px solid var(--secondary-color); height: calc(100% + 2px); position: relative; z-index: 2; margin-bottom: -2px; }

.miel-tab-body { padding: 5px 0; }
.miel-subtab-content { display: none; }
.miel-subtab-content.active-subtab { display: block; animation: fadeIn 0.3s ease; }
.no-data { color: #a0aec0; font-style: italic; font-size: 0.95rem; }

.miel-eval-item { background: #fffaf0; border: 1px solid #feebc8; border-left: 4px solid #dd6b20; padding: 15px; border-radius: 6px; }
.eval-date { font-size: 0.85rem; color: #dd6b20; font-weight: bold; margin-top: 4px; }

.forum-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.forum-form-container { background: #f7fafc; padding: 20px; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 20px; }
.forum-form-actions { display: flex; gap: 10px; margin-top: 10px; }
.forum-threads-list { display: flex; flex-direction: column; gap: 20px; margin-top: 15px; }
.forum-thread-card { background: #fff; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.thread-main { padding: 15px 20px; background: #fafafa; border-bottom: 1px solid #edf2f7; }
.thread-main h4 { color: var(--miel-blue); font-size: 1.1rem; }
.thread-meta { font-size: 0.8rem; color: #718096; margin: 4px 0 10px 0; }
.thread-body-text { font-size: 0.95rem; line-height: 1.5; color: #2d3748; }

.thread-replies-box { padding: 15px 20px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.thread-replies-box h5 { font-size: 0.85rem; text-transform: uppercase; color: #a0aec0; }
.forum-reply-item { background: #f7fafc; padding: 10px 14px; border-radius: 6px; font-size: 0.9rem; border-left: 2px solid var(--border-color); }
.reply-input-row { display: flex; gap: 10px; margin-top: 8px; }
.reply-input-row input { flex-grow: 1; padding: 6px 12px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 0.9rem; }

.messaging-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-top: 15px; }
.info-text { font-size: 0.9rem; color: #718096; margin-bottom: 15px; }
.messages-history-panel { background: #f7fafc; border-radius: 8px; padding: 15px; border: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 15px; max-height: 320px; overflow-y: auto; }
.messages-history-panel h4 { font-size: 0.95rem; color: var(--miel-blue); border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.outbox-message-item { background: #fff; border: 1px solid var(--border-color); padding: 12px; border-radius: 6px; }
.msg-meta { font-size: 0.8rem; color: #4a5568; margin-bottom: 6px; display: flex; justify-content: space-between; }
.msg-time { color: #a0aec0; }
.msg-body-p { font-size: 0.9rem; color: #2d3748; line-height: 1.4; white-space: pre-line; }

.main-content { padding: 40px; max-width: 1200px; margin: 0 auto; }
.content-header { margin-bottom: 30px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }
.content-header h2 { color: var(--secondary-color); font-size: 1.8rem; }

.tab-content { display: none; }
.tab-content.active-tab { display: block; animation: fadeIn 0.4s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.carousel-container { position: relative; width: 100%; height: 400px; border-radius: 12px; overflow: hidden; margin-bottom: 40px; box-shadow: 0 6px 15px rgba(0,0,0,0.1); }
.carousel-slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.6s ease-in-out; }
.carousel-slide.active { opacity: 1; position: relative; }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel-caption { position: absolute; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,0.85)); color: white; width: 100%; padding: 30px; box-sizing: border-box; }
.carousel-caption h3 { font-size: 1.6rem; margin-bottom: 8px; }
.carousel-caption p { font-size: 1rem; color: #e2e8f0; }
.carousel-control { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,0.4); color: white; border: none; font-size: 1.5rem; padding: 12px 16px; cursor: pointer; border-radius: 50%; z-index: 10; }
.carousel-control:hover { background: rgba(0,0,0,0.7); }
.carousel-control.prev { left: 20px; }
.carousel-control.next { right: 20px; }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 30px; }
.panel { background: var(--card-bg); padding: 25px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-bottom: 25px; }
.panel h3 { margin-bottom: 15px; color: var(--secondary-color); border-left: 4px solid var(--primary-color); padding-left: 10px; }

.inline-form { display: flex; gap: 10px; margin-bottom: 20px; }
.inline-form input { flex-grow: 1; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; }
.inline-form .btn { width: auto; }

.announcements-list { display: flex; flex-direction: column; gap: 10px; }
.announcement-item { background: #f7fafc; padding: 12px; border-radius: 6px; border-left: 3px solid var(--primary-color); font-size: 0.95rem; line-height: 1.4; }

.download-list { list-style: none; }
.download-list li { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border-color); }

.grades-form .form-row { display: flex; gap: 15px; margin-bottom: 15px; flex-wrap: wrap; }
.grades-form .form-row .form-group { flex: 1; min-width: 200px; }
.grades-form .btn { width: auto; }

.table-header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.table-header-actions h3 { margin-bottom: 0; }
.table-container { margin-top: 30px; overflow-x: auto; }
.grades-table { width: 100%; border-collapse: collapse; text-align: left; }
.grades-table th, .grades-table td { padding: 12px; border-bottom: 1px solid var(--border-color); }
.grades-table th { background-color: #f7fafc; color: var(--secondary-color); }

.pass-grade { color: var(--success-color); font-weight: bold; background: #e6fffa; padding: 3px 8px; border-radius: 4px; }
.fail-grade { color: var(--primary-color); font-weight: bold; background: #fff5f5; padding: 3px 8px; border-radius: 4px; }

.timeline { display: flex; flex-direction: column; gap: 20px; }
.timeline-item { border-left: 2px solid var(--border-color); padding-left: 20px; position: relative; }
.timeline-item::before { content: ''; width: 12px; height: 12px; background: var(--border-color); border-radius: 50%; position: absolute; left: -7px; top: 4px; }
.timeline-item.highlight::before { background: var(--primary-color); }
.timeline-item .date { font-size: 0.85rem; font-weight: bold; color: var(--primary-color); }
.timeline-item h4 { margin: 4px 0; color: var(--secondary-color); }
.timeline-item p { font-size: 0.9rem; color: #4a5568; }

.sede-card { background: #edf2f7; padding: 15px; border-radius: 6px; margin-bottom: 10px; border-left: 4px solid var(--secondary-color); }

/* ==========================================================================
   INTERFAZ DE MENSAJERÍA COMPLETA Y FLUIDA
   ========================================================================== */
.msg-system-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 20px;
    margin-top: 15px;
}

.panel-send-message {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
}

.panel-mailbox-system {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mailbox-tabs {
    display: flex;
    background: #edf2f7;
    border-bottom: 2px solid var(--border-color);
}

.btn-mailbox-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    font-weight: bold;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 0.9rem;
}

.btn-mailbox-tab:hover {
    background: #e2e8f0;
}

.btn-mailbox-tab.active {
    background: #ffffff;
    color: var(--secondary-color);
    border-bottom: 3px solid var(--primary-color);
}

.mailbox-content-display {
    padding: 15px;
    max-height: 380px;
    overflow-y: auto;
    background: #fafafa;
    flex-grow: 1;
}

.mailbox-message-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 4px solid #3182ce; /* Azul para entrantes estándar */
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.mail-header-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #718096;
    margin-bottom: 4px;
}

.mail-actor {
    color: var(--miel-blue);
}

.mail-subject-text {
    font-weight: 700;
    font-size: 0.9rem;
    color: #2d3748;
    margin-bottom: 6px;
}

.mail-body-content {
    font-size: 0.88rem;
    color: #4a5568;
    line-height: 1.4;
    white-space: pre-wrap;
}

.no-data-mailbox {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    margin-top: 40px;
    font-size: 0.95rem;
}

@media (max-width: 900px) {
    .miel-container { flex-direction: column; }
    .miel-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); padding-right: 0; padding-bottom: 15px; }
    .messaging-grid { grid-template-columns: 1fr; }
    .msg-system-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .navbar { flex-direction: column; gap: 15px; padding: 15px; }
    .navbar-menu { width: 100%; justify-content: center; flex-wrap: wrap; }
    .main-content { padding: 20px; }
    .carousel-container { height: 280px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 35px 25px; }
    .auth-form-helpers { flex-direction: column; align-items: flex-start; gap: 15px; }
}