/* --- 1. Variables de color y Tema --- */
:root {
    --primary-color: #4f46e5; /* Un azul/índigo más moderno */
    --primary-hover: #4338ca;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    
    /* Variables para el Header */
    --header-bg-start: #ffffff;
    --header-bg-end: #f3f4f6;
}

body.dark-mode {
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-color: #f9fafb;
    --border-color: #374151;
    
    --header-bg-start: #1f2937;
    --header-bg-end: #111827;
}

/* --- 2. Reseteo y Tipografía --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    /* ¡AQUÍ ESTÁ LA NUEVA FUENTE! */
    font-family: 'Poppins', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* --- 3. Cabecera (Header Estético) --- */
header {
    background: linear-gradient(135deg, var(--header-bg-start) 0%, var(--header-bg-end) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 1.2rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.header-content {
    max-width: 1000px; /* Igual que el main en escritorio */
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
}

.logo-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    padding: 0;
    border: none; /* Quitamos la línea de abajo que tenía antes */
}

/* --- SWITCH MODO NOCHE --- */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

/* Ocultamos el checkbox real */
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* El carril del switch */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1; /* Color gris en modo día */
    transition: 0.4s;
    border-radius: 34px;
}

/* El círculo que se mueve */
.slider:before {
    position: absolute;
    content: "☀️"; /* Emoji de sol por defecto */
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Cuando está activado (Modo Noche) */
input:checked + .slider {
    background-color: var(--primary-color);
}

/* Movemos el círculo a la derecha y cambiamos el emoji */
input:checked + .slider:before {
    transform: translateX(24px);
    content: "🌙";
}

.btn-theme:hover {
    transform: scale(1.1);
}

/* --- 4. Contenedor Principal (Main) --- */
main {
    padding: 20px;
    margin: 0 auto;
}

/* --- 5. Diseño de Tarjetas --- */
section {
    background-color: var(--card-bg);
    border-radius: 16px; /* Más redondeado, más moderno */
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 10px;
    color: var(--primary-color);
}

/* --- 6. Formulario --- */
form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

label {
    font-weight: 500;
    font-size: 0.95rem;
}

input, select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit; /* Hereda la fuente Poppins */
    width: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
}

button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s, transform 0.1s;
}

button[type="submit"]:hover {
    background-color: var(--primary-hover);
}

button[type="submit"]:active {
    transform: scale(0.98);
}

/* --- 7. Historial y Acordeón --- */
.month-header {
    background-color: var(--bg-color);
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: filter 0.2s;
}

.month-header:hover {
    filter: brightness(0.95);
}

.month-header::after {
    content: '▼';
    font-size: 0.8rem;
    color: #9ca3af;
    transition: transform 0.3s ease;
}

.month-details[open] .month-header::after {
    transform: rotate(180deg);
}

.records-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.records-list li {
    background-color: var(--card-bg);
    padding: 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    border-left: 4px solid var(--primary-color);
    border-top: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

#summary-section p {
    font-size: 1.2rem;
    text-align: center;
    margin-top: 10px;
}

#total-hours {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 700;
}

/* --- 8. Botones Acciones --- */
.btn-delete, .btn-edit {
    background: none;
    padding: 8px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-delete:hover { background-color: #fee2e2; }
.btn-edit:hover { background-color: #e0e7ff; }

/* --- 9. Modal --- */
dialog {
    margin: auto;
    padding: 30px;
    border: none;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 400px;
    background-color: var(--card-bg);
    color: var(--text-color);
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
}

#cancel-btn {
    background-color: #6b7280;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

#cancel-btn:hover { background-color: #4b5563; }

/* --- 10. FOOTER (Tu firma) --- */
footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 20px;
    color: #6b7280;
    font-size: 0.95rem;
    border-top: 1px solid var(--border-color);
}

body.dark-mode footer {
    color: #9ca3af;
}

footer strong {
    color: var(--primary-color);
}

/* --- 11. MAGIA PARA ESCRITORIO (2 Columnas) --- */
@media (min-width: 900px) {
    main {
        max-width: 1000px;
        display: grid;
        grid-template-columns: 350px 1fr;
        gap: 24px;
        align-items: start;
    }

    #summary-section {
        grid-column: 1 / -1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px 40px;
    }

    #summary-section h2 { margin: 0; border: none; padding: 0; }
    #summary-section p { margin: 0; }
}