/* =====================================================================
   RECETARIO — identidad visual
   Paleta: verde bosque #26392C · mostaza #DFA23B · papel crudo #F3ECDC
           terracota #C05A3A (acento puntual) · tinta #2A2620
   Tipografía: "Fraunces" (display, con carácter editorial) para títulos
               "Work Sans" para texto y formularios
   Firma: tarjetas de receta con borde troquelado (perforado) como
          fichas de recetario de cocina, y una cinta de categoría
          "grapada" en la esquina.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
    --green-deep: #26392C;
    --green-mid: #37503F;
    --mustard: #DFA23B;
    --mustard-dark: #B9822A;
    --paper: #F3ECDC;
    --paper-white: #FBF8F1;
    --terracotta: #C05A3A;
    --ink: #2A2620;
    --ink-soft: #5B5548;
    --line: #DCD2B8;
    --radius: 14px;
    --shadow: 0 6px 20px rgba(38, 57, 44, 0.12);
    --input-bg: #fff;
    --alt-bg: #FAF5E8;
    --on-dark: #FBF8F1; /* texto/iconos claros sobre fondos verdes, fijo en ambos temas */
    --on-light: #2A2620; /* texto oscuro sobre fondos mostaza, fijo en ambos temas */
    --btn-primary-bg: #26392C; /* fondo del botón principal; se aclara en modo oscuro para que no se funda con el fondo */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Work Sans', system-ui, sans-serif;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: 'Fraunces', Georgia, serif;
    color: var(--green-deep);
    margin: 0 0 0.4em;
    line-height: 1.15;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button, input, textarea, select { font-family: inherit; font-size: 1rem; }

:focus-visible {
    outline: 3px solid var(--mustard);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------
   Botones
   --------------------------------------------------------------- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 999px;
    padding: 0.65em 1.4em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--btn-primary-bg); color: var(--on-dark); }
.btn-primary:hover { background: var(--green-mid); }
.btn-accent { background: var(--mustard); color: var(--on-light); }
.btn-accent:hover { background: var(--mustard-dark); }
.btn-danger { background: var(--terracotta); color: #fff; }
.btn-outline { background: transparent; color: var(--green-deep); border: 2px solid var(--green-deep); padding: 0.55em 1.3em; }
.btn-sm { padding: 0.35em 0.9em; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---------------------------------------------------------------
   Alertas
   --------------------------------------------------------------- */
.alert { padding: 0.8em 1em; border-radius: 10px; margin: 0 0 1em; font-size: 0.95rem; }
.alert-error { background: #F5DCD3; color: #7A2E17; }
.alert-success { background: #DCE9D8; color: #23431F; }
.alert-info { background: #E3E9E0; color: var(--green-deep); }

/* ---------------------------------------------------------------
   Página de acceso (login / instalación)
   --------------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #33492F 0%, var(--green-deep) 55%, #1D2B1F 100%);
    padding: 20px;
}
.auth-card {
    background: var(--paper-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.4em 2em;
    max-width: 380px;
    width: 100%;
    text-align: center;
}
.brand-mark { font-size: 2.6rem; margin-bottom: 0.1em; }
.auth-lang-switch { display: flex; justify-content: flex-end; gap: 0.4em; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.6em; }
.auth-lang-switch a { color: var(--ink-soft); padding: 0.15em 0.5em; border-radius: 5px; }
.auth-lang-switch a.active { color: var(--green-deep); background: var(--paper); }
.brand { font-size: 1.8rem; }
.auth-subtitle { color: var(--ink-soft); margin-bottom: 1.4em; font-size: 0.95rem; }
.auth-footnote { margin-top: 1.2em; font-size: 0.85rem; color: var(--ink-soft); }
.auth-card form { text-align: left; display: flex; flex-direction: column; gap: 0.9em; }
.auth-card label { font-size: 0.85rem; font-weight: 600; color: var(--green-deep); display: flex; flex-direction: column; gap: 0.35em; }

input[type=text], input[type=password], input[type=email], input[type=search],
textarea, select {
    border: 1.5px solid var(--line);
    border-radius: 8px;
    padding: 0.6em 0.75em;
    background: var(--input-bg);
    color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--mustard-dark); }
textarea { resize: vertical; min-height: 90px; }

.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 2.6em; }
.password-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 1.1rem;
    padding: 0.3em 0.5em; line-height: 1; border-radius: 6px;
}
.password-toggle:hover { background: var(--paper); }

/* ---------------------------------------------------------------
   Barra superior / navegación
   --------------------------------------------------------------- */
.topbar {
    background: var(--green-deep);
    color: var(--on-dark);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.8em 1.2em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand-link { color: var(--on-dark); font-family: 'Fraunces', serif; font-size: 1.3rem; font-weight: 600; }
.brand-link:hover { text-decoration: none; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    gap: 5px;
}
.nav-toggle span { width: 24px; height: 2px; background: var(--on-dark); display: block; }

.main-nav { display: flex; align-items: center; gap: 1.4em; flex-wrap: wrap; }
.main-nav a { color: var(--on-dark); font-weight: 500; opacity: 0.92; }
.main-nav a:hover { opacity: 1; text-decoration: none; border-bottom: 2px solid var(--mustard); }
.nav-user { font-size: 0.85rem; opacity: 0.8; }
.lang-switch { display: flex; gap: 0.3em; font-size: 0.8rem; font-weight: 700; }
.lang-switch a { color: var(--on-dark); opacity: 0.55; padding: 0.15em 0.35em; border-radius: 5px; }
.lang-switch a.active { opacity: 1; background: rgba(255,255,255,0.15); }
.lang-switch a:hover { opacity: 1; text-decoration: none; }
.nav-logout {
    background: var(--mustard);
    color: var(--on-light) !important;
    padding: 0.4em 1em;
    border-radius: 999px;
    font-weight: 600;
}
.nav-logout:hover { background: var(--mustard-dark); }

@media (max-width: 760px) {
    .nav-toggle { display: flex; }
    .main-nav {
        display: none;
        position: absolute;
        top: 100%; left: 0; right: 0;
        background: var(--green-deep);
        flex-direction: column;
        align-items: flex-start;
        padding: 1em 1.2em 1.4em;
        gap: 0.9em;
    }
    .main-nav.open { display: flex; }
}

/* ---------------------------------------------------------------
   Contenedor de página
   --------------------------------------------------------------- */
.page-container { max-width: 1100px; margin: 0 auto; padding: 1.8em 1.2em 4em; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 1em; margin-bottom: 1.4em;
}
.page-header p.subtitle { color: var(--ink-soft); margin: 0.2em 0 0; }

/* ---------------------------------------------------------------
   Filtros
   --------------------------------------------------------------- */
.filter-bar {
    display: flex; flex-direction: column; gap: 0.9em;
    background: var(--paper-white); border-radius: var(--radius);
    padding: 1em; margin-bottom: 1.6em; box-shadow: var(--shadow);
}
.filter-bar-row { display: flex; flex-wrap: wrap; gap: 0.7em; align-items: flex-end; }
.filter-bar-row label { font-size: 0.8rem; font-weight: 600; color: var(--green-deep); display: flex; flex-direction: column; gap: 0.3em; }
.filter-bar-row select, .filter-bar-row input { min-width: 160px; }
.filter-cat-group { display: flex; flex-direction: column; gap: 0.4em; }
.filter-cat-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--green-deep); }
.dark-theme .filter-cat-label { color: #8FC79A; }

/* ---------------------------------------------------------------
   Tarjetas de receta — "fichas de recetario" con borde troquelado
   --------------------------------------------------------------- */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.4em;
}
.recipe-card {
    position: relative;
    background: var(--paper-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease;
}
.recipe-card:hover { transform: translateY(-3px); }
.recipe-card-media {
    height: 160px;
    background: var(--line) center/cover no-repeat;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.2rem;
    color: var(--ink-soft);
    position: relative;
}
.recipe-card-media::after {
    content: '';
    position: absolute; left: 0; right: 0; bottom: -1px; height: 10px;
    background-image: radial-gradient(circle, var(--paper-white) 5px, transparent 5.5px);
    background-size: 16px 16px;
    background-position: 0 -6px;
    background-repeat: repeat-x;
}
.recipe-card-badge {
    position: absolute; top: 10px; left: 10px;
    background: var(--mustard); color: var(--on-light);
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    padding: 0.25em 0.7em; border-radius: 999px; letter-spacing: 0.03em;
}
.recipe-card-fav {
    position: absolute; top: 8px; right: 10px;
    color: var(--mustard-dark); font-size: 1.3rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.recipe-card-body { padding: 1em 1.1em 1.2em; display: flex; flex-direction: column; gap: 0.4em; flex: 1; }
.recipe-card-body h3 { font-size: 1.15rem; }
.recipe-card-meta { font-size: 0.8rem; color: var(--ink-soft); display: flex; gap: 0.8em; flex-wrap: wrap; }
.recipe-card-desc { font-size: 0.9rem; color: var(--ink-soft); flex: 1; }
.recipe-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4em; font-size: 0.8rem; color: var(--ink-soft); }

.empty-state {
    text-align: center; padding: 3em 1em; color: var(--ink-soft);
    background: var(--paper-white); border-radius: var(--radius);
}

/* ---------------------------------------------------------------
   Detalle de receta
   --------------------------------------------------------------- */
.recipe-detail {
    background: var(--paper-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.8em;
    margin-bottom: 1.6em;
}
.recipe-detail-header { display: flex; justify-content: space-between; gap: 1em; flex-wrap: wrap; align-items: flex-start; margin-bottom: 0.6em; }
.badge { display: inline-block; background: var(--mustard); color: var(--on-light); font-size: 0.72rem; font-weight: 700; padding: 0.25em 0.7em; border-radius: 999px; text-transform: uppercase; margin-right: 0.4em; }
.badge-outline { background: transparent; border: 1.5px solid var(--green-mid); color: var(--green-mid); }
.recipe-meta-row { display: flex; gap: 1.2em; flex-wrap: wrap; color: var(--ink-soft); font-size: 0.88rem; margin: 0.6em 0 1.2em; }

.media-gallery { display: flex; gap: 0.8em; flex-wrap: wrap; margin: 1em 0 1.6em; }
.media-photo { width: 150px; height: 150px; object-fit: cover; border-radius: 10px; cursor: zoom-in; box-shadow: var(--shadow); }
.media-video { width: 220px; border-radius: 10px; box-shadow: var(--shadow); }

.recipe-columns { display: grid; grid-template-columns: 1fr 1.5fr; gap: 2em; }
@media (max-width: 700px) { .recipe-columns { grid-template-columns: 1fr; } }
.recipe-columns h4 { border-bottom: 2px solid var(--mustard); display: inline-block; padding-bottom: 0.2em; }
.ingredient-list { list-style: none; padding: 0; margin: 0; }
.ingredient-list li { padding: 0.4em 0; border-bottom: 1px dashed var(--line); }
.steps-block { white-space: pre-line; }

.lightbox-overlay {
    position: fixed; inset: 0; background: rgba(20,20,15,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; cursor: zoom-out; padding: 2em;
}
.lightbox-overlay img { max-height: 90vh; max-width: 90vw; border-radius: 8px; }

/* ---------------------------------------------------------------
   Valoraciones por estrellas
   --------------------------------------------------------------- */
.recipe-card-rating { font-size: 0.85rem; color: var(--mustard-dark); display: flex; align-items: center; gap: 0.4em; }
.recipe-card-rating span { color: var(--ink-soft); }

.rating-block {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 1em; background: var(--alt-bg); border-radius: 10px; padding: 1em 1.2em; margin-bottom: 1.6em;
}
.rating-summary { display: flex; flex-direction: column; gap: 0.2em; font-size: 0.9rem; color: var(--ink); }
.stars-readonly { color: var(--mustard-dark); font-size: 1.3rem; letter-spacing: 2px; }
.rating-form { display: flex; align-items: center; gap: 1em; flex-wrap: wrap; }

.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 2px;
}
.star-rating input { position: absolute; opacity: 0; width: 0; height: 0; }
.star-rating label {
    font-size: 1.8rem;
    line-height: 1;
    color: var(--line);
    cursor: pointer;
    transition: color 0.1s ease;
}
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label {
    color: var(--mustard-dark);
}

/* ---------------------------------------------------------------
   Hilo de comentarios
   --------------------------------------------------------------- */
.comments-section { background: var(--paper-white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.8em; }
.comment {
    display: flex; gap: 0.8em; padding: 1em 0; border-bottom: 1px solid var(--line);
}
.comment:last-child { border-bottom: none; }
.comment-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--green-deep);
    color: var(--on-dark); display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-head { display: flex; gap: 0.6em; align-items: baseline; flex-wrap: wrap; }
.comment-author { font-weight: 700; color: var(--green-deep); }
.comment-time { font-size: 0.78rem; color: var(--ink-soft); }
.comment-text { margin: 0.3em 0 0.5em; }
.comment-media { display: flex; gap: 0.6em; flex-wrap: wrap; }
.comment-media img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }

.comment-form { margin-top: 1.4em; display: flex; flex-direction: column; gap: 0.6em; }
.comment-form textarea { min-height: 70px; }
.preview-row { display: flex; gap: 0.5em; flex-wrap: wrap; }
.preview-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }

/* ---------------------------------------------------------------
   Formularios de receta / admin
   --------------------------------------------------------------- */
.form-card { background: var(--paper-white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.8em; max-width: 760px; margin: 0 auto; }
.form-card--wide { max-width: none; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 0.35em; margin-bottom: 1em; }
.field label { font-weight: 600; font-size: 0.88rem; color: var(--green-deep); }
.field-hint { font-size: 0.78rem; color: var(--ink-soft); }
.form-actions { display: flex; gap: 0.8em; margin-top: 1em; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.5em; }
.checkbox-chip {
    display: inline-flex; align-items: center; gap: 0.4em;
    background: var(--paper); border: 1.5px solid var(--line); border-radius: 999px;
    padding: 0.35em 0.85em; font-size: 0.85rem; font-weight: 500; cursor: pointer;
    user-select: none; transition: background 0.12s ease, border-color 0.12s ease;
}
.checkbox-chip input { margin: 0; accent-color: var(--mustard-dark); }
.checkbox-chip.checked,
.checkbox-chip:has(input:checked) {
    background: var(--mustard); border-color: var(--mustard-dark); color: var(--on-light);
}

.tag-picker { display: flex; flex-direction: column; gap: 0.7em; }
.tag-picker-select { max-width: 320px; }
.tag-picker-chips { display: flex; flex-wrap: wrap; gap: 0.5em; min-height: 1px; }
.tag-chip {
    display: inline-flex; align-items: center; gap: 0.45em;
    background: var(--mustard); color: var(--on-light);
    border-radius: 999px; padding: 0.3em 0.4em 0.3em 0.9em;
    font-size: 0.85rem; font-weight: 600;
}
.tag-chip-remove {
    background: rgba(0, 0, 0, 0.15); border: none; border-radius: 50%;
    width: 1.5em; height: 1.5em; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: inherit; font-size: 1rem; line-height: 1; padding: 0;
}
.tag-chip-remove:hover { background: rgba(0, 0, 0, 0.28); }

/* ---------------------------------------------------------------
   Tablas de administración
   --------------------------------------------------------------- */
.table-card { background: var(--paper-white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4em; overflow-x: auto; margin-bottom: 1.8em; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { text-align: left; padding: 0.6em 0.7em; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th { color: var(--green-deep); font-family: 'Fraunces', serif; font-weight: 600; }
tr:hover td { background: var(--alt-bg); }
.role-pill { padding: 0.2em 0.7em; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.role-admin { background: var(--terracotta); color: #fff; }
.role-user { background: var(--green-mid); color: #fff; }
.status-off { opacity: 0.5; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1em; margin-bottom: 2em; }
.admin-tile {
    background: var(--paper-white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.4em; text-align: center;
}
.admin-tile .count { font-family: 'Fraunces', serif; font-size: 2.2rem; color: var(--green-deep); }
.admin-tile .label { color: var(--ink-soft); font-size: 0.85rem; }

.bar-chart { display: flex; align-items: flex-end; gap: 1em; height: 140px; padding-top: 1.4em; }
.bar-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart-bar {
    width: 60%; min-width: 24px; background: var(--mustard);
    border-radius: 6px 6px 0 0; position: relative; display: flex; justify-content: center;
}
.bar-chart-bar span { position: absolute; top: -1.4em; font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }
.bar-chart-label { margin-top: 0.5em; font-size: 0.75rem; color: var(--ink-soft); text-transform: capitalize; }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 2em 0 0.8em; }

/* ---------------------------------------------------------------
   Interruptor de modo oscuro
   --------------------------------------------------------------- */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.3em 0.5em;
    border-radius: 8px;
    color: var(--on-dark);
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); }

/* ---------------------------------------------------------------
   Modo oscuro — misma identidad, fondos y superficies invertidos
   --------------------------------------------------------------- */
.dark-theme {
    --paper: #1B1F19;
    --paper-white: #262B22;
    --ink: #EDE8DA;
    --ink-soft: #A79F8C;
    --line: #3B4136;
    --input-bg: #2E332A;
    --alt-bg: #2A2F24;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    --btn-primary-bg: #4C7057;
}

.dark-theme .btn-primary:hover { background: #5C8368; }

.dark-theme h1, .dark-theme h2, .dark-theme h3, .dark-theme h4,
.dark-theme .filter-bar-row label, .dark-theme .auth-card label,
.dark-theme .field label, .dark-theme th, .dark-theme .comment-author,
.dark-theme .admin-tile .count, .dark-theme .recipe-columns h4 {
    color: #8FC79A;
}

.dark-theme a { color: #9BCBA4; }
.dark-theme .btn-outline { color: #9BCBA4; border-color: #4F6B57; }
.dark-theme .badge-outline { border-color: #4F6B57; color: #9BCBA4; }
.dark-theme .alert-info { background: #2E3A2E; color: #C8E0CB; }
.dark-theme .recipe-card-media { background: var(--line); }
.dark-theme .password-toggle:hover { background: var(--alt-bg); }
.dark-theme .lightbox-overlay { background: rgba(0, 0, 0, 0.9); }
