/* --- Variables Globales --- */
:root {
    --primary-color: #0a4a90;
    --primary-hover: #083b73;
    --primary-light: #e7f0fa;
    --secondary-color: #4b5563;
    --text-color: #1f2937;
    --bg-color: #f8fafc;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #dc2626;
    --font-main: 'Inter', sans-serif;
    --container-width: 1200px;
}

/* --- Reset Básico --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

ul { list-style: none; }
img { max-width: 100%; display: block; }

/* --- Utilidades --- */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1rem;
}

.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-hover); }

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent; /* Borde sutil */
    text-align: center;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

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

.btn-outline {
    background-color: var(--white);
    color: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-outline:hover { background-color: var(--bg-color); }

.btn-block { display: block; width: 100%; text-align: center; }

.btn-danger { background-color: var(--danger-color); color: var(--white); }
.btn-danger:hover { background-color: #b91c1c; }

/* --- Header (Reestructurado) --- */
.site-header {
    background-color: var(--white);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Parte Superior: Logo y Auth */
.header-top {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.header-top-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}
.logo span.icon {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 0.4rem;
    border-radius: 0.5rem;
    display: flex;
}
.logo span.light { font-weight: 300; }

/* Parte Inferior: Menú de Navegación */
.header-bottom {
    background-color: var(--primary-color); /* Fondo azul para el menú */
    color: var(--white);
}

.nav-main {
    display: none; /* Oculto en móvil */
}

@media (min-width: 1024px) {
    .nav-main {
        display: flex;
        gap: 0; /* Sin gap, usamos padding en los links */
    }
}

/* Enlaces del Menú Principal */
.nav-item {
    position: relative; /* Para posicionar el dropdown */
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1.25rem;
    color: var(--white);
    font-size: 0.95rem;
    font-weight: 500;
    border-right: 1px solid rgba(255,255,255,0.1); /* Separador sutil */
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: rgba(0,0,0,0.1); /* Oscurecer al pasar el mouse */
}

.nav-link svg {
    opacity: 0.7;
}

/* Dropdowns (Submenús) */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 280px;
    background-color: var(--white);
    color: var(--text-color);
    border-radius: 0 0 0.5rem 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    display: none;
    z-index: 110;
    border: 1px solid var(--border-color);
    border-top: none;
}

/* Mostrar dropdown al hover sobre el item padre */
.nav-item:hover .dropdown-menu {
    display: block;
}

.dropdown-scroll {
    max-height: 350px;
    overflow-y: auto;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-color);
    border-radius: 0.25rem;
}

.dropdown-item:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.dropdown-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    padding: 0.5rem 1rem 0.25rem;
    border-bottom: 1px solid var(--bg-color);
    margin-bottom: 0.25rem;
}

/* Botón Menú Móvil */
.btn-menu-mobile {
    display: block;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--secondary-color);
    padding: 0.5rem;
}

@media (min-width: 1024px) {
    .btn-menu-mobile { display: none; }
}

/* Menú Móvil Desplegable */
.nav-mobile-container {
    display: none;
    background-color: var(--white);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 99;
}
.nav-mobile-container.active { display: block; }
.nav-mobile-container a {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bg-color);
    color: var(--text-color);
}

/* --- Hero Section --- */
.hero-section {
    background-color: var(--white);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

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

@media (min-width: 768px) {
    .search-form { flex-direction: row; }
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}
.form-control:focus { outline: none; border-color: var(--primary-color); }

/* --- Estadísticas --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}
@media (min-width: 768px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }

.stat-card {
    background-color: var(--white);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex; align-items: center; gap: 1rem;
}
.stat-card.primary { background-color: var(--primary-color); color: var(--white); }
.stat-icon {
    background-color: var(--primary-light); color: var(--primary-color); padding: 0.75rem; border-radius: 50%; display: flex;
}
.stat-card.primary .stat-icon { background-color: rgba(255,255,255,0.2); color: var(--white); }
.stat-number { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.9rem; color: #6b7280; }
.stat-card.primary .stat-label { color: #bfdbfe; }

/* --- Grid Layout --- */
.grid-layout {
    display: grid; grid-template-columns: 1fr; gap: 1.5rem;
}
@media (min-width: 768px) { .grid-layout { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { 
    .grid-layout { grid-template-columns: repeat(3, 1fr); } 
    .grid-layout-sidebar { grid-template-columns: 2fr 1fr; }
}

/* --- Tarjetas de Convocatoria --- */
.card {
    background-color: var(--white);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    transition: transform 0.3s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
.card-body { padding: 1.5rem; flex-grow: 1; }
.card-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.card-logo { width: 80px; height: 80px; object-fit: contain; border: 1px solid var(--border-color); border-radius: 0.5rem; padding: 0.25rem; background: var(--white); }
.card-title { font-size: 1.1rem; font-weight: 700; color: var(--text-color); margin-bottom: 0.25rem; }
.card-title a:hover { color: var(--primary-color); }
.card-subtitle { font-size: 0.9rem; color: var(--secondary-color); }
.detail-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 0.9rem; color: #4b5563; }
.card-footer { background-color: #f9fafb; padding: 1rem; border-top: 1px solid var(--border-color); display: flex; justify-content: center; gap: 0.5rem; }
.share-icon { color: #9ca3af; transition: color 0.3s; }
.share-icon:hover { color: var(--primary-color); }

/* --- Páginas de Detalle (Convocatoria/Plaza) --- */
.detail-container { background: var(--white); padding: 2rem; border-radius: 1rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); margin-bottom: 2rem; }
.breadcrumb { font-size: 0.9rem; color: #6b7280; margin-bottom: 1rem; }
.breadcrumb a { color: var(--primary-color); }
.alert { padding: 1rem; border-radius: 0.5rem; margin-bottom: 1.5rem; }
.alert-warning { background-color: #fef3c7; border-left: 4px solid #f59e0b; color: #92400e; }
.alert-success { background-color: #d1fae5; border-left: 4px solid #10b981; color: #065f46; }

.content-html h3 { color: var(--primary-color); font-size: 1.25rem; margin-bottom: 0.5rem; margin-top: 1.5rem; border-bottom: 1px solid #eee; padding-bottom: 0.25rem; }
.content-html ul { list-style: disc; margin-left: 1.5rem; margin-bottom: 1rem; }
.content-html p { margin-bottom: 1rem; }

.plaza-card { border: 1px solid var(--border-color); border-radius: 0.5rem; margin-bottom: 1.5rem; overflow: hidden; }
.plaza-header { background: #f3f4f6; padding: 1rem; border-bottom: 1px solid var(--border-color); }
.plaza-body { padding: 1.5rem; }

/* --- Footer Mejorado --- */
.site-footer {
    background-color: #111827; /* Un tono más oscuro y elegante */
    color: #9ca3af;
    padding-top: 4rem;
    padding-bottom: 2rem;
    border-top: 4px solid var(--primary-color);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .footer-grid {
        grid-template-columns: 1.5fr 1fr 1fr 1.2fr; /* Columnas asimétricas */
    }
}

/* Columna Marca */
.footer-logo {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    text-decoration: none;
}

.footer-logo span.icon {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 0.3rem;
    border-radius: 0.5rem;
    display: flex;
}

.footer-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: #d1d5db;
}

/* Redes Sociales */
.social-links {
    display: flex;
    gap: 1rem;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--white);
    transition: all 0.3s ease;
}

.social-link:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
}

/* Títulos y Listas */
.footer-title {
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.footer-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40px;
    height: 2px;
    background-color: var(--primary-color);
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: #9ca3af;
    font-size: 0.95rem;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
}

.footer-links a:hover {
    color: var(--white);
    transform: translateX(5px);
}

.footer-links a::before {
    content: '›';
    margin-right: 0.5rem;
    color: var(--primary-color);
    font-weight: bold;
}

/* Formulario Newsletter */
.newsletter-text {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.newsletter-input-group {
    position: relative;
    display: flex;
}

.newsletter-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 3rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--white);
    outline: none;
    transition: border-color 0.3s;
}

.newsletter-input:focus {
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-subscribe {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-top: 0.5rem;
    width: 100%;
}

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

/* Footer Bottom */
.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: #6b7280;
}

@media (min-width: 768px) {
    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
    }
}

/* --- Iconos SVG --- */
.icon-svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-lg { width: 2rem; height: 2rem; }


/* --- ESTILOS ADMIN --- */
.admin-container {
    padding: 2rem;
    background-color: var(--white);
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-top: 2rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--bg-color);
}

.admin-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

/* Tablas de Admin */
.table-responsive {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 800px;
}

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

.admin-table th {
    background-color: #f3f4f6;
    color: var(--secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.admin-table tr:hover {
    background-color: #f9fafb;
}

/* Botones de Acción en Tabla */
.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

/* Formularios Admin */
.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .admin-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .full-width {
        grid-column: span 2;
    }
}

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

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

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

/* Tabs de Navegación Admin */
.admin-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    color: var(--secondary-color);
    transition: all 0.3s;
}

.admin-tab:hover {
    color: var(--primary-color);
}

.admin-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}


/* --- EDITOR DE TEXTO (WYSIWYG) --- */
.editor-container {
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--white);
    overflow: hidden;
    margin-bottom: 1rem;
}

.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f3f4f6;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    flex-wrap: wrap;
}

.editor-btn {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--secondary-color);
    font-weight: 600;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-btn:hover {
    background: #e5e7eb;
    color: var(--primary-color);
}

.editor-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.editor-mode-switch {
    margin-left: auto;
    display: flex;
    gap: 0;
    border: 1px solid var(--primary-color);
    border-radius: 0.25rem;
    overflow: hidden;
}

.mode-btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    background: var(--white);
    color: var(--primary-color);
    border: none;
}

.mode-btn.active {
    background: var(--primary-color);
    color: var(--white);
}

.editor-content-area {
    position: relative;
    min-height: 150px;
}

/* Área Visual */
.editor-visual {
    min-height: 150px;
    padding: 1rem;
    outline: none;
    overflow-y: auto;
}

.editor-visual:focus {
    background-color: #fcfcfc;
}

/* Estilos dentro del editor visual para que se parezca al resultado final */
.editor-visual ul { list-style: disc; margin-left: 1.5rem; }
.editor-visual p { margin-bottom: 0.5rem; }
.editor-visual h3, .editor-visual h4 { color: var(--primary-color); margin-top: 1rem; margin-bottom: 0.5rem; font-weight: 700; }
.editor-visual a { color: var(--primary-color); text-decoration: underline; }

/* Área Código (Textarea original) */
.editor-code {
    width: 100%;
    height: 100%;
    min-height: 150px;
    border: none;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.9rem;
    background: #1f2937;
    color: #e5e7eb;
    resize: vertical;
    outline: none;
    display: none; /* Oculto por defecto */
}

.editor-code.active {
    display: block;
}


.card[style*="flex-direction: row"] {
    display: flex;
    align-items: center;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.card[style*="flex-direction: row"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}