:root {
    /* Paleta de Colores Suaves y Elegantes (Earth Tones) */
    --primary-color: #A68A64; /* Oro viejo suave */
    --primary-hover: #8C7350;
    --primary-color-edit: #40a7f0bf; /* Oro viejo suave */
    --primary-hover-edit: #0ae2ff;
    --bg-color: #FDFCF8;      /* Blanco hueso / Crema muy suave */
    --card-bg: #FFFFFF;
    --text-main: #4A4A4A;     /* Gris oscuro suave, no negro puro */
    --text-muted: #888888;
    --border-color: #EAEAEA;
    --focus-ring: rgba(166, 138, 100, 0.2);
    --error-color: #D9534F;
    
    /* Variables dinámicas para Listas, Tablas y Menús */
    --input-bg: #FAFAFA;
    --table-header-bg: #f8f9fa;
    --table-hover-bg: #f9f9f9;
    --status-past: #ffebee;
    --status-today: #e3f2fd;
    --status-green: #e8f5e9;
    --status-yellow: #fffde7;
}

/* --- TEMAS PERSONALIZADOS --- */

/* Tema 1: Azul Brillante */
[data-theme="theme1"] {
    --primary-color: #00ABE4;
    --primary-hover: #008cba;
    --bg-color: #E9F1FA;
    --card-bg: #FFFFFF;
    --text-main: #2C3E50;
    --text-muted: #607D8B;
    --border-color: #D1E3F0;
    --focus-ring: rgba(0, 171, 228, 0.2);
}

/* Tema 2: Amarillo-Verde / Gris */
[data-theme="theme2"] {
    --primary-color: #8CBF28; /* Ajustado ligeramente para contraste de texto */
    --primary-hover: #7DA823;
    --bg-color: #F9F9F9;
    --card-bg: #FFFFFF;
    --text-main: #6E6E6E;
    --text-muted: #999999;
    --border-color: #E0E0E0;
    --focus-ring: rgba(186, 255, 57, 0.4);
}

/* Tema 3: Azul Marino / Eléctrico (Modo Oscuro) */
[data-theme="theme3"] {
    --primary-color: #00FFFF;
    --primary-hover: #00CCCC;
    --bg-color: #01257D;
    --card-bg: #001A57;
    --text-main: #FFFFFF;
    --text-muted: #A0B4F0;
    --border-color: #0236B0;
    --focus-ring: rgba(0, 255, 255, 0.3);
    
    /* Ajustes de fondo para Modo Oscuro (Tema 3) */
    --input-bg: #001240;
    --table-header-bg: #001240;
    --table-hover-bg: #002a8a;
    --status-past: #4a0d0d;
    --status-today: #0d2b4a;
    --status-green: #0d4a15;
    --status-yellow: #4a420d;
}

/* Color específico para las filas de la tabla en el Tema 3 */
[data-theme="theme3"] tbody tr {
    background-color: #2da7eb;
    color: #000000;
}

[data-theme="theme3"] tbody tr:hover {
    background-color: #004a99;
    color: #ffffff;
}
/* Tema 4: Gris Azulado */
[data-theme="theme4"] {
    --primary-color: #5D8AA8; /* Versión legible de #96C2DB */
    --primary-hover: #4B708A;
    --bg-color: #E5EDF1;
    --card-bg: #FFFFFF;
    --text-main: #455A64;
    --text-muted: #78909C;
    --border-color: #CFD8DC;
    --focus-ring: rgba(150, 194, 219, 0.2);
}

/* Tema 5: Azul / Dorado */
[data-theme="theme5"] {
    --primary-color: #957C3D;
    --primary-hover: #7A6530;
    --bg-color: #F4F6F8;
    --card-bg: #FFFFFF;
    --text-main: #002349;
    --text-muted: #536D88;
    --border-color: #DCE2E8;
    --focus-ring: rgba(149, 124, 61, 0.2);
}

/* --- FIN TEMAS --- */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 100px 20px 40px; /* Ajuste para la navbar fija */
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 750px;
    background: var(--card-bg);
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.04); /* Sombra más difusa y elegante */
    position: relative;
    z-index: 1;
}

.container-wide {
    max-width: 95%;
    padding: 30px;
}

h1 {
    color: var(--primary-color);
    margin-top: 0;
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 40px;
    font-weight: 300;
}

/* Estilos de Inputs */
.input-group {
    margin-bottom: 24px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
}

input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background-color: var(--input-bg);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    color: var(--text-main);
}

input:focus {
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

input.input-error {
    border-color: var(--error-color);
    background-color: rgba(217, 83, 79, 0.1); /* Fondo rojo transparente adaptable */
}

.date-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* Sección de Diseños */
h3 {
    margin-top: 50px;
    margin-bottom: 10px;
    color: var(--text-main);
    font-weight: 600;
    font-size: 1.2rem;
}

.hint-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 25px;
    display: block;
}

.grid-designs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 25px;
}

.design-card {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: white;
    text-align: center;
}

.design-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-color);
}

.design-card img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.design-card:hover img {
    transform: scale(1.05);
}

.design-card span {
    display: block;
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

/* Vista Previa Flotante */
#previewOverlay {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background-color: white;
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#previewOverlay.show-preview {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#previewOverlay img {
    max-height: 80vh;
    max-width: 90vw;
    border-radius: 8px;
    display: block;
}

@media (max-width: 768px) {
    #previewOverlay { display: none !important; }
    .date-row { grid-template-columns: 1fr; gap: 15px; }
    .container { padding: 30px 20px !important; }
    .container-wide { padding: 20px 10px !important; }
    body { padding: 80px 10px 30px; }
    h1 { font-size: 1.6rem; }
    
    .grid-designs { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; }
    
    /* Arreglo para encabezados con flex en container-wide */
    .container-wide > div[style*="display: flex"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 15px;
    }
    
    /* Arreglo para el buscador */
    .search-container { justify-content: stretch; margin-bottom: 10px; }
    .search-container input { width: 100%; }
    .search-container input:focus { width: 100%; }
    
    /* Ajustes para modales en móvil */
    .modal-content { margin: 15% auto; padding: 20px !important; width: 95% !important; }
    
    /* Mejor visibilidad de botones en móvil */
    .btn-full { padding: 14px; font-size: 1rem; }
}

/* --- Nuevos Estilos: Navegación y Formulario de Registro --- */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--card-bg); /* Se adapta al tema (blanco o azul oscuro) */
    backdrop-filter: blur(10px);
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    z-index: 1000;
}

.nav-brand {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    gap: 30px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary-color);
}

/* --- Menú Hamburguesa (Móvil) --- */
.hamburger {
    display: none;
    cursor: pointer;
}

.bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    transition: all 0.3s ease-in-out;
    background-color: var(--primary-color);
}

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .hamburger.active .bar:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .hamburger.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 60px; /* Ajuste según altura del navbar */
        gap: 0;
        flex-direction: column;
        background-color: var(--card-bg); /* Fondo adaptable en móvil */
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 10px rgba(0,0,0,0.1);
        padding: 20px 0;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-link {
        margin: 16px 0;
        display: block;
    }
}

/* Botón de Configuración de Tema */
.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    display: flex;
    align-items: center;
    transition: transform 0.3s, color 0.3s;
}
.theme-btn:hover { transform: rotate(90deg); color: var(--primary-color); }

.theme-modal {
    display: none;
    position: fixed;
    top: 60px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 2000;
    width: 220px;
    text-align: left;
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
}
.theme-option:hover { background-color: rgba(0,0,0,0.05); }
.color-preview {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Estilos para Select (Dropdown) */
select {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background-color: var(--input-bg);
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    color: var(--text-main);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A4A4A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    cursor: pointer;
}

select:focus {
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

/* Fix para el icono del select en modo oscuro (Tema 3) */
[data-theme="theme3"] select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* Estilo para las opciones del select */
select option {
    background-color: var(--card-bg);
    color: var(--text-main);
}

.btn-full {
    width: 100%;
    padding: 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 20px;
}

.btn-full:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-full:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* --- Spinner y Mensajes de Estado --- */

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 20px auto;
    display: none; /* Oculto por defecto */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message-box {
    padding: 15px;
    margin-top: 20px;
    border-radius: 10px;
    display: none; /* Oculto por defecto */
    text-align: center;
    font-weight: 500;
    font-size: 0.95rem;
}

.message-box.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-box.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- Estilos para Tabla de Eventos --- */
.table-responsive {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    min-width: 600px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--table-header-bg);
    color: var(--primary-color);
    font-weight: 600;
}

tr:hover {
    background-color: var(--table-hover-bg);
}

.btn-action {
    padding: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 5px;
    transition: background 0.3s;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit { background-color: var(--primary-color-edit); }
.btn-edit:hover { background-color: var(--primary-hover-edit); }

.btn-delete { background-color: var(--error-color); }
.btn-delete:hover { background-color: #c9302c; }

/* --- Estilos Modal de Edición --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0; top: 0;
    width: 100%; height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto; 
    padding: 30px;
    border-radius: 15px;
    width: 90%; max-width: 500px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
}

/* --- Notificaciones Flotantes (Toasts) --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    width: auto;
    height: auto;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;                 /* Permite clicks a través del fondo transparente */
}

.toast {
    min-width: 320px;
    max-width: 90%;
    padding: 20px 30px;
    border-radius: 16px;
    color: white;
    font-weight: 500;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    opacity: 0;
    transform: scale(0.8);
    animation: popInToast 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 1.1rem;
    border: 1px solid rgba(255,255,255,0.15);
    pointer-events: auto; /* Reactiva los clicks solo en la notificación */
}

.toast.success { background: linear-gradient(135deg, #00b09b, #96c93d); }
.toast.error { background: linear-gradient(135deg, #cb2d3e, #ef473a); }
.toast.info { background: linear-gradient(135deg, #36d1dc, #5b86e5); }

@keyframes popInToast {
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeOut {
    to { opacity: 0; transform: scale(0.8); }
}

.btn-secondary { background-color: #6c757d; color: white; }
.btn-secondary:hover { background-color: #5a6268; }

/* --- Alerta Centrada (Modal de Error) --- */
.message-box.centered-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3), 0 0 0 1000px rgba(0,0,0,0.5); /* Sombra + Backdrop */
    font-size: 1.1rem;
    padding: 30px;
    border: 2px solid #721c24;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* --- Colores de Estado para Filas de Tabla --- */
/* Importante: Usamos !important o selectores específicos para sobreescribir el hover base si es necesario */
tr.event-past { background-color: var(--status-past); }
tr.event-today { background-color: var(--status-today); }
tr.event-green { background-color: var(--status-green); }
tr.event-yellow { background-color: var(--status-yellow); }

/* --- Buscador Ajustado --- */
.search-container {
    display: flex;
    justify-content: flex-end; /* Alinea a la derecha */
    margin-bottom: 15px;
}

.search-container input {
    width: 250px; /* Ancho más pequeño */
    padding: 8px 15px;
    border-radius: 20px; /* Bordes redondeados estilo píldora */
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.search-container input:focus {
    width: 280px; /* Efecto de expansión al enfocar */
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

/* --- Footer Común --- */
.site-footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 20px;
    text-align: center;
    margin-top: auto;
    width: 100%;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.site-footer p {
    margin: 5px 0;
}

/* --- Toggle Password (Ojo) --- */
.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    padding-right: 45px; /* Espacio para el icono */
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.toggle-password:hover {
    color: var(--primary-color);
}
/* ... resto de estilos ... */
.toggle-password:hover {
    color: var(--primary-color);
}
/* --- Notificaciones Flotantes (Toasts) --- */
#toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Centrado perfecto */
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: auto;
    max-width: 90%;
}
/* ... resto de estilos ... */

/* --- Estilos para el Switch (Interruptor) --- */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    vertical-align: middle;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

/* --- Medidor de Fortaleza de Contraseña --- */
.strength-container {
    margin-top: 8px;
    margin-bottom: 15px;
}

.strength-bar {
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    transition: all 0.3s ease;
    width: 0%;
}

.strength-text {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    margin-top: 4px;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Segmented Controls (Radio Buttons) --- */
.segmented-control {
    display: flex;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.segmented-control label {
    flex: 1;
    margin: 0;
    cursor: pointer;
    border-right: 1px solid var(--border-color);
}
.segmented-control label:last-child {
    border-right: none;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control .radio-content {
    padding: 12px 10px;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.segmented-control .radio-content:hover {
    background-color: rgba(0,0,0,0.02);
}

.segmented-control input[type="radio"]:checked + .radio-content {
    background-color: var(--primary-color);
    color: white;
}
