/* ==========================================================
   DON MUCÍLAGO — Panel Admin (2026)
   Dashboard moderno: sidebar + contenido, misma identidad
   que el frontend (espresso / honey / pergamino).
   ========================================================== */

:root {
    --esp:     #0E1210;
    --esp-2:   #161C18;
    --esp-3:   #1E2621;
    --parch:   #F5F0E6;
    --parch-2: #ECE5D5;
    --honey:   #E3B457;
    --muc:     #C9973F;
    --leaf:    #2C4A3A;
    --chile:   #C0392B;
    --ink:     #1B201D;
    --smoke:   #6E786F;
    --line:    #E4DCCB;
    --line-d:  rgba(245, 240, 230, 0.12);
    --disp: 'Fraunces', Georgia, serif;
    --body: 'Outfit', 'Segoe UI', system-ui, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body { overflow-x: hidden; }

body.admin {
    margin: 0;
    font-family: var(--body);
    font-weight: 400;
    background: var(--parch);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; }

/* ----------------------------------------------------------
   Layout
   ---------------------------------------------------------- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--esp-3), var(--esp));
    color: var(--parch);
    display: flex;
    flex-direction: column;
    padding: 1.6rem 1.1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.side-logo { display: flex; align-items: baseline; gap: 0.3rem; font-size: 1.35rem; padding: 0.2rem 0.6rem 1.4rem; letter-spacing: 0.04em; }
.side-logo span { font-weight: 600; }
.side-logo em { font-style: normal; font-family: var(--disp); font-weight: 600; color: var(--honey); }

.admin-burger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 42px; height: 42px;
    flex-shrink: 0;
    border-radius: 999px;
    border: 1px solid var(--line-d);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}
.admin-burger:hover { border-color: var(--honey); background: rgba(255, 255, 255, 0.09); }
.admin-burger span { width: 20px; height: 2px; border-radius: 2px; background: var(--parch); transition: transform 0.3s var(--ease), opacity 0.3s; }
.admin-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.admin-burger.open span:nth-child(2) { opacity: 0; }
.admin-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.side-panel { display: flex; flex-direction: column; flex-grow: 1; }

.side-nav { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.4rem; }

.side-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.82rem 1rem;
    border-radius: 0.9rem;
    font-size: 0.88rem;
    color: rgba(245, 240, 230, 0.68);
    transition: background 0.3s, color 0.3s;
    border: 1px solid transparent;
}
.side-link svg { width: 19px; height: 19px; flex-shrink: 0; opacity: 0.85; }
.side-link:hover { background: rgba(255, 255, 255, 0.05); color: var(--parch); }
.side-link.active { background: rgba(227, 180, 87, 0.14); color: var(--honey); border-color: rgba(227, 180, 87, 0.3); }
.side-link .count {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    font-size: 0.72rem;
    color: rgba(245, 240, 230, 0.7);
}
.side-link.active .count { background: rgba(227, 180, 87, 0.25); color: var(--honey); }

.side-actions { margin-top: auto; display: flex; flex-direction: column; gap: 0.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line-d); }
.side-action {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.7rem 1rem;
    border-radius: 0.8rem;
    font-size: 0.82rem;
    color: rgba(245, 240, 230, 0.6);
    transition: background 0.3s, color 0.3s;
}
.side-action svg { width: 17px; height: 17px; }
.side-action:hover { background: rgba(255, 255, 255, 0.05); color: var(--parch); }
.side-action.danger { color: rgba(245, 120, 110, 0.8); }
.side-action.danger:hover { background: rgba(192, 57, 43, 0.15); color: #fff; }

.main { flex-grow: 1; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.7rem 2.2rem 0;
}
.topbar h1 { font-family: var(--disp); font-size: 1.9rem; margin: 0; font-weight: 600; }
.topbar .date { color: var(--smoke); font-size: 0.82rem; margin-top: 0.2rem; }

.content { padding: 1.4rem 2.2rem 3rem; max-width: 1400px; }

/* ----------------------------------------------------------
   Tablas genéricas
   ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 0.85rem; }
.table th { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 2px solid var(--line); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--smoke); }
.table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: rgba(227, 180, 87, 0.06); }

/* ----------------------------------------------------------
   Componentes base
   ---------------------------------------------------------- */
.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    padding: 1.6rem;
    box-shadow: 0 1px 3px rgba(20, 26, 22, 0.04);
}
.panel + .panel { margin-top: 1.4rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.panel-title { font-family: var(--disp); font-size: 1.3rem; margin: 0; font-weight: 600; }
.panel-sub { color: var(--smoke); font-size: 0.85rem; margin: 0.25rem 0 0; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
    border-radius: 0.8rem;
    padding: 0.7rem 1.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    transition: transform 0.25s var(--ease), background 0.25s, color 0.25s, border-color 0.25s;
}
.btn:hover { transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: linear-gradient(135deg, #EEC470, var(--honey) 60%, var(--muc)); color: #221803; }
.btn-primary:hover { box-shadow: 0 8px 20px -8px rgba(227, 180, 87, 0.6); }

.btn-dark { background: var(--esp); color: var(--parch); }
.btn-dark:hover { background: var(--leaf); }

.btn-danger { background: #fdf0ee; color: var(--chile); border-color: #f3d5d0; }
.btn-danger:hover { background: var(--chile); color: #fff; border-color: var(--chile); }

.btn-ghost { background: transparent; color: var(--smoke); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muc); }

/* Formularios */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--smoke); margin-bottom: 0.4rem; }
.field input[type="text"], .field input[type="url"], .field input[type="password"], .field input[type="file"],
.field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    padding: 0.68rem 0.9rem;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--muc); box-shadow: 0 0 0 3px rgba(201, 151, 63, 0.15); }
.field textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

label.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; letter-spacing: 0.02em; text-transform: none; color: var(--ink); font-weight: 500; margin-top: 1.35rem; cursor: pointer; }
label.check input { width: 17px; height: 17px; accent-color: var(--muc); }

/* Flash */
.flash {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    border-radius: 0.9rem;
    padding: 0.9rem 1.2rem;
    font-size: 0.9rem;
    margin-bottom: 1.4rem;
    border: 1px solid;
}
.flash.ok { background: #eef7ee; color: #2f6b3a; border-color: #d3ebd4; }
.flash.err { background: #fdf0ee; color: var(--chile); border-color: #f3d5d0; }
.flash button { background: none; border: 0; font-size: 1.1rem; line-height: 1; cursor: pointer; color: inherit; opacity: 0.6; }

/* ----------------------------------------------------------
   Resumen
   ---------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.1rem; margin-bottom: 1.4rem; }
.stat-card {
    background: var(--esp);
    color: var(--parch);
    border-radius: 1.2rem;
    padding: 1.4rem 1.5rem;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: "";
    position: absolute;
    right: -22px; top: -22px;
    width: 90px; height: 90px;
    border-radius: 50%;
    background: radial-gradient(var(--honey), transparent 70%);
    opacity: 0.16;
}
.stat-card .stat-value { font-family: var(--disp); font-size: 2.5rem; font-weight: 600; line-height: 1; }
.stat-card .stat-label { font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(245, 240, 230, 0.6); margin-top: 0.5rem; }
.stat-card.gold { background: linear-gradient(135deg, var(--esp), var(--leaf)); }

.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.quick-link {
    display: flex; align-items: center; gap: 0.9rem;
    background: #fff; border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1rem 1.2rem;
    transition: border-color 0.3s, transform 0.3s var(--ease);
}
.quick-link:hover { border-color: var(--muc); transform: translateY(-2px); }
.quick-link .ql-icon { width: 42px; height: 42px; border-radius: 0.8rem; background: var(--parch-2); color: var(--muc); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.quick-link .ql-icon svg { width: 20px; height: 20px; }
.quick-link b { display: block; font-size: 0.92rem; }
.quick-link small { color: var(--smoke); font-size: 0.78rem; }

/* ----------------------------------------------------------
   Productos
   ---------------------------------------------------------- */
.prod-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }

.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.3rem; }

.prod-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 1.3rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.prod-card:hover { border-color: rgba(201, 151, 63, 0.5); box-shadow: 0 16px 30px -18px rgba(20, 26, 22, 0.3); }

.prod-thumb { position: relative; aspect-ratio: 16 / 10; background: var(--parch-2); }
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-thumb .no-img { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--smoke); font-size: 0.8rem; }
.prod-badge {
    position: absolute; top: 0.8rem; left: 0.8rem;
    background: rgba(14, 18, 16, 0.82);
    color: var(--honey);
    font-size: 0.62rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
    padding: 0.32rem 0.8rem;
    border-radius: 999px;
}

.prod-body { padding: 1.2rem 1.3rem; flex-grow: 1; }
.prod-foot {
    display: flex; gap: 0.6rem;
    padding: 0 1.3rem 1.3rem;
}
.prod-foot .btn { flex: 1; justify-content: center; }

.cat-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cat-chip {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--smoke);
    border-radius: 999px;
    padding: 0.45rem 1.1rem;
    font-size: 0.76rem;
    font-weight: 600;
    transition: all 0.25s;
}
.cat-chip:hover { color: var(--ink); border-color: var(--muc); }
.cat-chip.active { background: var(--esp); color: var(--honey); border-color: var(--esp); }

/* ----------------------------------------------------------
   Modal
   ---------------------------------------------------------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 12, 11, 0.6);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4%;
}
.modal-overlay.open { display: flex; }
.modal {
    width: min(560px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 1.4rem;
    padding: 1.8rem;
    animation: modalIn 0.35s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.4rem; }
.modal-head h2 { font-family: var(--disp); font-size: 1.5rem; margin: 0; font-weight: 600; }
.modal-close { background: none; border: 0; font-size: 1.4rem; color: var(--smoke); cursor: pointer; transition: color 0.25s, transform 0.25s; }
.modal-close:hover { color: var(--chile); transform: rotate(90deg); }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.7rem; margin-top: 1.5rem; }

.img-preview { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 0.8rem; border: 1px solid var(--line); margin-bottom: 0.8rem; }
.hint { font-size: 0.78rem; color: var(--smoke); margin-top: 0.4rem; }

/* ----------------------------------------------------------
   Galería
   ---------------------------------------------------------- */
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.gal-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 1rem;
    overflow: hidden;
}
.gal-item-media { aspect-ratio: 1; background: var(--parch-2); }
.gal-item-media img, .gal-item-media video { width: 100%; height: 100%; object-fit: cover; }
.gal-item-body { padding: 0.8rem; }
.gal-item-body input, .gal-item-body select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    font-family: inherit;
    margin-bottom: 0.5rem;
}
.gal-del { width: 100%; border: 1px solid #f3d5d0; background: #fdf0ee; color: var(--chile); border-radius: 0.6rem; padding: 0.5rem; font-size: 0.72rem; font-weight: 600; transition: all 0.25s; }
.gal-del:hover { background: var(--chile); color: #fff; }

/* ----------------------------------------------------------
   Perfil
   ---------------------------------------------------------- */
.prep-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 0.7rem; align-items: center; margin-bottom: 0.7rem; }
.prep-row input { width: 100%; border: 1px solid var(--line); border-radius: 0.8rem; padding: 0.62rem 0.85rem; font-size: 0.88rem; font-family: inherit; }
.prep-row input:focus { outline: none; border-color: var(--muc); }
.prep-rm { background: none; border: 0; color: var(--chile); cursor: pointer; padding: 0.4rem; }
.prep-rm:hover { opacity: 0.7; }

/* ----------------------------------------------------------
   Login
   ---------------------------------------------------------- */
.login-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5%;
    font-family: var(--body);
    background:
        radial-gradient(70% 60% at 50% 0%, rgba(44, 74, 58, 0.4), transparent 70%),
        linear-gradient(160deg, var(--esp-3), var(--esp));
    color: var(--parch);
}
.login-card { width: min(400px, 100%); text-align: center; }
.login-logo { font-size: 1.9rem; margin-bottom: 0.5rem; }
.login-logo span { font-weight: 600; }
.login-logo em { font-style: normal; font-family: var(--disp); font-weight: 600; color: var(--honey); }
.login-sub { font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase; color: rgba(245, 240, 230, 0.55); margin-bottom: 2rem; }
.login-form {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line-d);
    border-radius: 1.4rem;
    padding: 2rem;
    backdrop-filter: blur(10px);
    text-align: left;
}
.login-form label { display: block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(245, 240, 230, 0.6); margin-bottom: 0.5rem; }
.login-form input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line-d);
    border-radius: 0.9rem;
    padding: 0.85rem 1rem;
    color: var(--parch);
    font-size: 1rem;
    margin-bottom: 1.2rem;
}
.login-form input:focus { outline: none; border-color: var(--honey); box-shadow: 0 0 0 3px rgba(227, 180, 87, 0.15); }
.login-error { color: #ff8d80; font-size: 0.82rem; text-align: center; margin: 0 0 1rem; }
.login-back { display: block; margin-top: 1.4rem; color: rgba(245, 240, 230, 0.45); font-size: 0.82rem; text-decoration: underline; }
.login-back:hover { color: var(--honey); }

/* ----------------------------------------------------------
   Responsive
   ---------------------------------------------------------- */
@media (max-width: 900px) {
    .admin-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        gap: 0.8rem;
        padding: 0.9rem 1rem;
    }
    .side-logo { padding: 0; margin-right: auto; font-size: 1.2rem; }
    .admin-burger { display: inline-flex; order: -1; }
    .side-panel {
        position: fixed;
        top: var(--panel-top, 72px);
        left: 0; right: 0; bottom: 0;
        background: linear-gradient(180deg, var(--esp-3), var(--esp));
        border-top: 1px solid var(--line-d);
        padding: 1.1rem 1.2rem 2.4rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0.25s;
        z-index: 950;
    }
    .side-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }
    .side-nav { flex-direction: column; align-items: stretch; gap: 0.45rem; margin: 0; }
    .side-link { padding: 1rem 1.1rem; white-space: normal; font-size: 1rem; border-radius: 0.9rem; }
    .side-link .count { display: inline-flex; }
    .side-actions { display: flex; margin-top: 1.2rem; padding-top: 1.2rem; gap: 0.6rem; border-top: 1px solid var(--line-d); }
    .side-action { padding: 1rem 1.1rem; font-size: 0.95rem; border-radius: 0.9rem; }
    .topbar, .content { padding-left: 1.1rem; padding-right: 1.1rem; }
    .field-row, .prep-row { grid-template-columns: 1fr 1fr; }
    .prep-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr; }
    .prep-row { grid-template-columns: 1fr; }
}
