/* ==========================================================================
   Dulce Encanto · Panel de administración
   ========================================================================== */

:root {
    --adm-sidebar: #2b1815;
    --adm-sidebar-2: #3a221d;
    --adm-bg: #f6efe6;
    --adm-card: #fffdf9;
    --adm-line: #e7d9c8;
    --adm-text: #2a1c18;
    --adm-muted: #7d675b;
    --adm-accent: #c9a227;
    --adm-primary: #4a2b25;
    --adm-danger: #a63c2f;
    --adm-success: #2f6f4e;
    --adm-radius: 14px;
    --adm-font: 'Manrope', 'Segoe UI', system-ui, sans-serif;
    --adm-display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--adm-font);
    background: var(--adm-bg);
    color: var(--adm-text);
    font-size: 14.5px;
    line-height: 1.55;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--adm-display); font-weight: 600; margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
:focus-visible { outline: 2px solid var(--adm-accent); outline-offset: 2px; }

.admin-shell { display: grid; grid-template-columns: 254px minmax(0, 1fr); min-height: 100vh; }

/* --------------------------------------------------------------------------
   Barra lateral
   -------------------------------------------------------------------------- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background:
        radial-gradient(420px 260px at 100% 0%, rgba(201, 162, 39, .14), transparent 65%),
        var(--adm-sidebar);
    color: #d9c7b7;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    gap: 8px;
    overflow-y: auto;
    z-index: 100;
}
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.sidebar__mark {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255, 248, 236, .07);
    border: 1px solid rgba(201, 162, 39, .45);
    color: var(--adm-accent);
    display: grid; place-items: center;
    font-family: var(--adm-display);
    font-size: 18px;
    flex: none;
}
.sidebar__brand strong { display: block; color: #fbf3e4; font-family: var(--adm-display); font-size: 17px; line-height: 1.2; }
.sidebar__brand span { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: #9b8372; }

.sidebar__label {
    font-size: 9.5px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: #8a7262;
    padding: 16px 10px 6px;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 13.5px;
    color: #c6b2a2;
    transition: background .2s ease, color .2s ease;
}
.sidebar__nav a svg { width: 17px; height: 17px; opacity: .8; flex: none; }
.sidebar__nav a:hover { background: rgba(255, 248, 236, .06); color: #fbf3e4; }
.sidebar__nav a.is-active { background: rgba(201, 162, 39, .16); color: #f7e7c5; }
.sidebar__nav a.is-active svg { opacity: 1; color: var(--adm-accent); }
.sidebar__count {
    margin-left: auto;
    min-width: 20px; height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--adm-accent);
    color: #2b1815;
    font-size: 10.5px;
    font-weight: 700;
    display: grid; place-items: center;
}
.sidebar__foot { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255, 248, 236, .1); }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.sidebar__avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(201, 162, 39, .2);
    color: #f3dfae;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex: none;
}
.sidebar__user strong { display: block; font-size: 12.5px; color: #f0e2cf; line-height: 1.3; }
.sidebar__user span { font-size: 11px; color: #9b8372; }
.sidebar__logout {
    display: block;
    margin: 8px 10px 0;
    font-size: 12px;
    color: #b39d8c;
    text-decoration: underline;
}
.sidebar__logout:hover { color: #f3dfae; }

/* --------------------------------------------------------------------------
   Contenido
   -------------------------------------------------------------------------- */
.admin-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(246, 239, 230, .9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--adm-line);
    padding: 14px clamp(18px, 3vw, 34px);
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar__toggle {
    display: none;
    width: 38px; height: 38px;
    border-radius: 9px;
    border: 1px solid var(--adm-line);
    background: var(--adm-card);
    align-items: center;
    justify-content: center;
}
.topbar__title { min-width: 0; }
.topbar__title h1 { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title p { font-size: 12px; color: var(--adm-muted); margin: 2px 0 0; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.admin-content { padding: clamp(18px, 3vw, 34px); max-width: 1320px; width: 100%; }

/* --------------------------------------------------------------------------
   Tarjetas y utilidades
   -------------------------------------------------------------------------- */
.card {
    background: var(--adm-card);
    border: 1px solid var(--adm-line);
    border-radius: var(--adm-radius);
    margin-bottom: 22px;
    overflow: hidden;
}
.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--adm-line);
    flex-wrap: wrap;
}
.card__head h2 { font-size: 18px; }
.card__head p { font-size: 12px; color: var(--adm-muted); margin: 3px 0 0; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }
.card__foot { padding: 14px 20px; border-top: 1px solid var(--adm-line); display: flex; gap: 10px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
    background: var(--adm-card);
    border: 1px solid var(--adm-line);
    border-radius: var(--adm-radius);
    padding: 18px 20px;
}
.stat-card__label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--adm-muted); font-weight: 700; }
.stat-card__value { font-family: var(--adm-display); font-size: 30px; line-height: 1.2; margin: 6px 0 2px; color: var(--adm-primary); }
.stat-card__hint { font-size: 11.5px; color: var(--adm-muted); }
.stat-card--accent { background: var(--adm-primary); border-color: var(--adm-primary); }
.stat-card--accent .stat-card__label { color: #d9bfa0; }
.stat-card--accent .stat-card__value { color: #fff8ec; }
.stat-card--accent .stat-card__hint { color: #cdb6a3; }

.muted { color: var(--adm-muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 20px; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.right { margin-left: auto; }

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 9px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
    white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn--primary { background: var(--adm-primary); color: #fff8ec; }
.btn--primary:hover { background: #38201b; }
.btn--gold { background: var(--adm-accent); color: #2b1815; }
.btn--gold:hover { background: #b8912a; }
.btn--ghost { border-color: var(--adm-line); background: var(--adm-card); color: var(--adm-primary); }
.btn--ghost:hover { border-color: #c9b49e; background: #fff; }
.btn--danger { background: #f7e6e3; color: var(--adm-danger); border-color: #eccfc9; }
.btn--danger:hover { background: #f0d5cf; }
.btn--sm { padding: 7px 12px; font-size: 12px; border-radius: 7px; }
.btn--block { width: 100%; }

/* --------------------------------------------------------------------------
   Tablas
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left;
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--adm-muted);
    font-weight: 700;
    padding: 12px 16px;
    border-bottom: 1px solid var(--adm-line);
    background: #fbf6ee;
    white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--adm-line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fdf9f2; }
.table .thumb { width: 46px; height: 40px; border-radius: 7px; object-fit: cover; border: 1px solid var(--adm-line); }
/* La celda de acciones debe seguir siendo una celda real de tabla.
   Poner display:flex directamente en el <td> rompe el layout de la fila
   (el borde inferior queda más arriba que el del resto de columnas).
   Por eso el flex se aplica a los hijos, no al <td>. */
.table td.table__actions { display: table-cell; text-align: right; white-space: nowrap; }
.table td.table__actions > * { display: inline-flex; vertical-align: middle; }
.table td.table__actions > * + * { margin-left: 6px; }
.table__title { font-weight: 600; color: var(--adm-primary); }
.table__sub { font-size: 11.5px; color: var(--adm-muted); }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: #f0e7da;
    color: #6f5a4c;
    white-space: nowrap;
}
.badge--pendiente { background: #fbf0d8; color: #8a6a12; }
.badge--confirmado { background: #e8f0f9; color: #2c5d8a; }
.badge--en_proceso { background: #fdf0e3; color: #9a5a1f; }
.badge--listo { background: #e9f4ec; color: #2f6f4e; }
.badge--entregado { background: #e6f3ea; color: #25603f; }
.badge--cancelado { background: #f7e6e3; color: #9a3428; }
.badge--on { background: #e9f4ec; color: #2f6f4e; }
.badge--off { background: #f2ece4; color: #8a7365; }

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 15px; }
.field label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; color: #5c473b; }
.field label .req { color: var(--adm-danger); }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dccbb6;
    border-radius: 8px;
    background: #fff;
    font-size: 13.5px;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 0;
    border-color: var(--adm-accent);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, .16);
}
.field textarea { resize: vertical; min-height: 100px; }
.field__hint { font-size: 11.5px; color: var(--adm-muted); }
.field--inline { flex-direction: row; align-items: center; gap: 9px; }
.field--inline label { font-size: 13px; font-weight: 500; }
.field--inline input[type="checkbox"] { width: auto; accent-color: var(--adm-primary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .field--full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; }

.image-field { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.image-field__preview {
    width: 96px; height: 84px;
    border-radius: 10px;
    border: 1px dashed #d3bfa8;
    background: #fbf6ee;
    object-fit: cover;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: none;
    color: #a48b7c;
    font-size: 10.5px;
    text-align: center;
}
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field__body { flex: 1; min-width: 180px; }
.image-field input[type="file"] { font-size: 12px; padding: 8px; }

/* --------------------------------------------------------------------------
   Alertas y estados vacíos
   -------------------------------------------------------------------------- */
.alert { padding: 11px 15px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert--success { background: #eaf5ee; color: #255c3d; border-color: #c6e3d1; }
.alert--error { background: #fbeae7; color: #8c2f24; border-color: #f0c9c1; }
.alert--info { background: #f4eee4; color: #6a533f; border-color: #e4d5c2; }

.empty { text-align: center; padding: 46px 22px; }
.empty h3 { font-size: 19px; margin-bottom: 6px; }
.empty p { font-size: 13px; color: var(--adm-muted); margin-bottom: 16px; }

/* --------------------------------------------------------------------------
   Galería del panel
   -------------------------------------------------------------------------- */
.admin-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.admin-gallery__item { border: 1px solid var(--adm-line); border-radius: 10px; overflow: hidden; background: #fff; }
.admin-gallery__item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.admin-gallery__body { padding: 10px 12px; }
.admin-gallery__body strong { display: block; font-size: 12.5px; }
.admin-gallery__body span { font-size: 11px; color: var(--adm-muted); }
.admin-gallery__actions { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(800px 500px at 85% 0%, rgba(201, 162, 39, .18), transparent 60%),
        radial-gradient(600px 400px at 0% 100%, rgba(74, 43, 37, .16), transparent 60%),
        var(--adm-bg);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--adm-card);
    border: 1px solid var(--adm-line);
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: 0 30px 70px -40px rgba(43, 24, 21, .5);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .sidebar__mark { background: var(--adm-primary); color: #f6e6c6; }
.login-brand strong { font-family: var(--adm-display); font-size: 19px; display: block; line-height: 1.2; }
.login-brand span { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--adm-muted); }
.login-card h1 { font-size: 25px; margin-bottom: 6px; }
.login-card > p { font-size: 13px; color: var(--adm-muted); margin-bottom: 22px; }
.login-card .btn { margin-top: 8px; }
.login-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--adm-muted); }
.login-foot a { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform .3s ease;
        box-shadow: 20px 0 50px -30px rgba(0, 0, 0, .6);
    }
    .sidebar-open .sidebar { transform: none; }
    .sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(30, 18, 15, .45);
        z-index: 90;
    }
    .topbar__toggle { display: inline-flex; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .stat-grid, .grid-4 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .admin-content { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .topbar__title h1 { font-size: 18px; }
    .table th, .table td { padding: 10px 12px; }
}
