/* ==========================================
   FUENTES LOCALES
   ========================================== */
@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter_18pt-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter_18pt-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}
@font-face {
    font-family: 'Playfair Display';
    src: url('../fonts/PlayfairDisplay-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Playfair Display';
    src: url('../fonts/PlayfairDisplay-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}

/* ==========================================
   1. VARIABLES Y RESET BÁSICO (Soporte Modo Oscuro)
   ========================================== */
:root {
    /* Paleta de Colores Institucional (Claro) */
    --primary: #1e3a8a;
    --primary-hover: #1e40af;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    
    /* Fondos y Superficies */
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    
    /* Textos */
    --text-main: #1f2937;
    --text-muted: #6b7280;
    
    /* Bordes y Botones Secundarios */
    --border-color: #d1d5db;
    --border-light: #e5e7eb;
    --btn-sec-bg: #e5e7eb;
    --btn-sec-hover: #d1d5db;
    --btn-light-bg: #f1f5f9;
    --btn-light-text: #475569;
    --btn-light-border: #cbd5e1;
    --btn-light-hover: #e2e8f0;
}

/* Paleta de Colores (Oscuro) */
body.dark-mode {
    /* Aclaramos un poco el azul para que contraste bien en fondo oscuro */
    --primary: #3b82f6; 
    --primary-hover: #60a5fa;
    
    /* Superficies oscuras estilo "Slate" de Tailwind */
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    
    /* Textos claros */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Bordes y Botones adaptados a la oscuridad */
    --border-color: #334155;
    --border-light: #1e293b;
    --btn-sec-bg: #334155;
    --btn-sec-hover: #475569;
    --btn-light-bg: #1e293b;
    --btn-light-text: #cbd5e1;
    --btn-light-border: #334155;
    --btn-light-hover: #475569;
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
    transition: background-color 0.3s ease, color 0.3s ease; /* Transición suave al cambiar de modo */
}

.serif-title {
    font-family: 'Playfair Display', serif;
    color: var(--primary);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* ==========================================
   2. BOTONES Y FORMULARIOS (Global)
   ========================================== */
button, .btn-primary, .btn-secondary, .btn-light, .btn-logout {
    height: 42px;
    padding: 0 20px;
    border-radius: 6px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

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

.btn-secondary { background-color: var(--btn-sec-bg); color: var(--text-main); }
.btn-secondary:hover { background-color: var(--btn-sec-hover); }

.btn-light { background-color: var(--btn-light-bg); color: var(--btn-light-text); border: 1px solid var(--btn-light-border); }
.btn-light:hover { background-color: var(--btn-light-hover); }

input[type="text"], input[type="password"], input[type="date"], select {
    width: 100%;
    height: 42px;
    padding: 0 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-input);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, background-color 0.3s, color 0.3s;
    box-sizing: border-box;
}

.search-date-group input[type="date"] {
    color-scheme: light;
}

body.dark-mode .search-date-group input[type="date"] {
    color-scheme: dark;
}

textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-input);
    color: var(--text-main);
    resize: vertical;
    transition: border-color 0.2s, background-color 0.3s, color 0.3s;
}

/* ==========================================
   3. LAYOUT DEL LOGIN (Split-Layout)
   ========================================== */
.split-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
}

/* Nota: La barra lateral se mantiene azul institucional incluso en modo oscuro */
.sidebar {
    flex: 0 0 50%;
    width: 50%;
    max-width: 50%;
    background: linear-gradient(180deg, #1e3a8a 0%, #173578 100%);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 52px;
    min-width: 0;
}

.sidebar-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-content {
    flex: 0 0 50%;
    width: 50%;
    max-width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-card);
    position: relative;
    padding: 40px 32px;
    min-width: 0;
}

.theme-switcher-login{
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.theme-switcher-login .theme-selector{
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.theme-switcher-login .theme-selector option{
    background: var(--bg-input);
    color: var(--text-main);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 0;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    body:not(.topbar-layout) {
        overflow-x: hidden;
    }

    .split-layout {
        width: 100%;
        min-height: 100vh;
        flex-direction: column;
        overflow-x: hidden;
    }

    .sidebar {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        min-height: 280px;
        padding: 28px 24px 22px;
        text-align: center;
        justify-content: center;
    }

    .sidebar-content {
        flex: 0 1 auto;
        display: block;
    }

    .sidebar .brand {
        max-width: 460px;
        margin: 0 auto;
    }

    .sidebar .logo-placeholder {
        margin-bottom: 16px !important;
    }

    .sidebar .logo-placeholder img {
        max-width: 76px !important;
    }

    .sidebar .serif-title {
        font-size: 1.8rem !important;
        line-height: 1.15 !important;
        margin-bottom: 10px !important;
    }

    .sidebar .brand-subtitle {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
        margin: 0;
    }

    .sidebar-footer {
        width: 100%;
        max-width: 460px;
        margin: 18px auto 0;
        padding-top: 12px !important;
        font-size: 0.75rem !important;
    }

    .main-content {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        min-height: 0;
        padding: 68px 24px 32px;
        align-items: flex-start;
    }

    .theme-switcher-login {
        top: 16px;
        right: 24px;
    }

    .theme-switcher-login .theme-selector {
        width: 116px;
        min-width: 0;
        height: 40px;
        padding: 0 8px;
        font-size: 0.85rem;
    }

    .login-card {
        width: 100%;
        max-width: 420px;
        margin: 0 auto;
        padding: 0;
    }

    .login-card .serif-title {
        font-size: 2rem !important;
        line-height: 1.2;
    }

    .login-card .subtitle {
        margin-bottom: 24px !important;
        line-height: 1.45;
    }

    .login-card input[type="text"],
    .login-card input[type="password"] {
        width: 100%;
    }

    .login-card button[type="submit"] {
        width: 100% !important;
        min-height: 46px;
        margin-top: 4px !important;
    }
}

@media (max-width: 375px) {
    .sidebar {
        min-height: 260px;
        padding: 22px 18px 18px;
    }

    .sidebar .logo-placeholder img {
        max-width: 68px !important;
    }

    .sidebar .serif-title {
        font-size: 1.6rem !important;
    }

    .sidebar .brand-subtitle {
        font-size: 0.84rem !important;
    }

    .main-content {
        padding-left: 20px;
        padding-right: 20px;
    }

    .login-card .serif-title {
        font-size: 1.8rem !important;
    }
}

/* ==========================================
   4. LAYOUT DEL SISTEMA (Topbar Compacto)
   ========================================== */
body.topbar-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* El Topbar principal se mantiene oscuro institucional */
.topbar {
    background-color: #1e3a8a;
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.topbar-container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-header-row {
    display: contents;
}

.topbar-brand img {
    height: 64px;
    width: auto;
}

.brand-titles h1 {
    margin: 0;
    font-size: 1.35rem;
    font-family: 'Playfair Display', serif;
    font-weight: 600;
}

.brand-titles span, .subtitle-desktop {
    font-size: 0.7rem;
    color: #93c5fd;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Selector de tema */
.theme-selector{
    background: rgba(255,255,255,.15);
    color: white;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 6px;
    padding: 6px 10px;
    margin-right: 10px;
    cursor: pointer;
    font-size: .9rem;
    width: auto; /* importante */
    min-width: 120px;
}

.theme-selector option{
    color: #111827;
    background: white;
}

.theme-selector{
    font-family: 'Inter', sans-serif;
    text-align: left;
    padding-left: 12px;
}

.theme-selector option{
    font-family: 'Inter', sans-serif;
}

.nav-link {
    color: #e2e8f0;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 6px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background-color: var(--bg-card); /* Adaptable */
    color: var(--primary); /* Adaptable */
    font-weight: 600;
}

@media (max-width: 900px) {
    .topbar-container {
        padding: 0 15px;
    }
    .subtitle-desktop {
        display: none;
    }
    .topbar-nav {
        gap: 2px;
    }
    .nav-link {
        font-size: 0.85rem;
        padding: 6px 8px;
    }
}

@media (max-width: 600px) {
    .topbar-container {
        flex-direction: column;
        height: auto;
        min-height: 60px;
        padding: 10px 12px;
        gap: 10px;
        align-items: stretch;
    }

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

    .topbar-brand {
        flex: 1 1 auto;
        min-width: 0;
        gap: 8px;
    }

    .topbar-brand img {
        height: 32px;
    }

    .brand-titles h1 {
        font-size: 1.15rem;
        white-space: nowrap;
    }

    .topbar-nav {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 4px;
    }

    .theme-selector {
        margin-right: 0;
        flex: 0 0 116px;
        min-width: 0;
        max-width: 116px;
        padding-left: 8px;
        padding-right: 4px;
    }

    .nav-link {
        font-size: 0.8rem;
        min-height: 40px;
        flex: 1 1 auto;
        text-align: center;
        padding: 6px 8px;
    }

    .topbar #btn-logout {
        margin-left: 0 !important;
    }

    .main-container {
        width: 100%;
        margin-top: 24px;
        margin-bottom: 24px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .search-panel-inline {
        width: 100%;
        padding: 16px;
        gap: 14px;
        align-items: stretch;
    }

}

@media (max-width: 380px) {
    .topbar-container {
        padding-left: 8px;
        padding-right: 8px;
    }

    .nav-link {
        padding-left: 7px;
        padding-right: 7px;
    }

    .search-panel-inline {
        padding: 14px 12px;
    }

}

/* ==========================================
   5. CONTENEDORES PRINCIPALES Y BUSCADOR
   ========================================== */
.main-container {
    max-width: 1000px;
    width: 100%;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
}

.search-panel-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background: var(--bg-card); /* Adaptable */
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 30px;
    align-items: flex-end;
    border: 1px solid var(--border-light);
    transition: background-color 0.3s, border-color 0.3s;
}

.search-group { display: flex; flex-direction: column; }
.search-text-group { flex: 3; min-width: 250px; }
.search-date-group { flex: 1; min-width: 140px; }
.search-status-group { flex: 1; min-width: 140px; }
.search-btn-group { display: flex; gap: 10px; }

.search-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

@media (max-width: 600px) {
    .main-container {
        width: 100%;
        margin-top: 24px;
        margin-bottom: 24px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .search-panel-inline {
        width: 100%;
        padding: 16px;
        gap: 12px;
        align-items: stretch;
    }

    .search-group,
    .search-text-group,
    .search-date-group,
    .search-status-group {
        width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    .search-btn-group {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .search-btn-group button {
        width: 100%;
        min-height: 42px;
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 380px) {
    .search-panel-inline {
        padding: 14px 12px;
        gap: 10px;
    }

    .search-btn-group {
        gap: 8px;
    }

    .search-btn-group button {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* ==========================================
   5. CONTENEDORES PRINCIPALES Y BUSCADOR
   ========================================== */
.upload-zone{
    background: var(--bg-input);
    border: 3px dashed var(--border-color);
    border-radius: 18px;
    min-height: 280px;
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:40px;
    transition:.3s;
    cursor:pointer;
}

.upload-zone:hover{
    border-color:var(--primary);
}

.upload-zone.dragover{
    border-color:var(--primary);
    transform:scale(1.01);
    background:rgba(37,99,235,.08);
}

.upload-content h3{
    margin-top:15px;
    color:var(--text-main);
}

.upload-content p{
    color:var(--text-muted);
    margin:10px 0;
}

.upload-icon{
    font-size:4rem;
}

.upload-select-btn{
    margin-top:20px;
}

.upload-server-btn{
    width:100%;
    margin-top:20px;
}
/* Contenedor de previsualización de imágenes */
#preview-container{
    margin-top:25px;
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(180px,1fr));
    gap:15px;
}

.preview-card{
    background:var(--bg-input);
    border:1px solid var(--border-light);
    border-radius:10px;
    overflow:hidden;
}

.preview-card img{
    width:100%;
    height:160px;
    object-fit:cover;
    display:block;
}

.preview-name{
    padding:10px;
    font-size:.85rem;
    color:var(--text-main);
    word-break:break-word;
}

.preview-card{
    position:relative;
    background:var(--bg-input);
    border:1px solid var(--border-light);
    border-radius:10px;
    overflow:hidden;
}

.remove-preview{
    position:absolute;
    top:8px;
    right:8px;
    width:28px;
    height:28px;
    border:none;
    border-radius:50%;
    background:#ef4444;
    color:white;
    cursor:pointer;
    font-weight:bold;
    z-index:5;
}

.remove-preview:hover{
    transform:scale(1.1);
}


/* ==========================================
   6. TARJETAS DE RESULTADOS (Index)
   ========================================== */
.results-header {
    margin-bottom: 25px;
}

.news-list { list-style: none; }

.result-card {
    background: var(--bg-card); /* Adaptable */
    padding: 18px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid var(--border-light); /* Adaptable */
    margin-bottom: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s, border-color 0.3s;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08);
}

.card-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 8px; 
}

.card-title { 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: var(--primary); /* Adaptable */
    text-decoration: none; 
}
.card-title:hover { text-decoration: underline; }

.card-meta { 
    display: flex; 
    align-items: center; 
    font-size: 0.85rem; 
    color: var(--text-muted); 
}

/* ==========================================
   7. PROGRESS BAR (Publicar)
   ========================================== */
.step-dark-left { color: var(--primary); font-weight: bold; }
.step-light-left { color: var(--text-muted); } /* Ahora adaptable */
.step-dark-left a { color: var(--primary); text-decoration: none; }
.step-dark-left a:hover { text-decoration: underline; }

/* ==========================================
   8. SISTEMA DE DIALOGOS DINAMICOS
   ========================================== */
#custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.custom-dialog-box {
    background: #ffffff;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    text-align: center;
    color: var(--text-main);
}

/* Soporte automatico para tu Modo Oscuro */
body.dark-mode .custom-dialog-box {
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
}
body.dark-mode #custom-dialog-overlay {
    background: rgba(0, 0, 0, 0.8);
}

/* ==========================================
   9. TARJETAS DE FOTOS (GALERÍA)
   ========================================== */
.foto-card {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: background 0.3s ease, border 0.3s ease;
}
.foto-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: zoom-in;
}
.foto-card input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-main);
    transition: background 0.3s ease, color 0.3s ease;
}
.foto-card .foto-actions {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}
.btn-foto-save {
    background: var(--success); /* Toma el color verde que antes era del texto */
    border: 1px solid var(--success); 
    border-radius: 4px;
    padding: 5px 10px;
    color: #ffffff; /* El texto ahora es blanco */
    cursor: pointer;
    font-weight: 600;
}

.btn-foto-delete {
    background: var(--danger); /* Toma el color rojo que antes era del texto */
    border: 1px solid var(--danger); 
    border-radius: 4px;
    padding: 5px 10px;
    color: #ffffff; /* El texto ahora es blanco */
    cursor: pointer;
    font-weight: 600;
}