/* ==========================================================================
   La Cocinade · panel de administración
   ========================================================================== */

:root {
    --admin-bg: #f4efe7;
    --admin-paper: #fffdfa;
    --admin-sidebar: #211812;
    --admin-sidebar-soft: rgba(255, 250, 243, .58);
    --admin-line: rgba(63, 51, 44, .12);
    --admin-muted: #8a786c;
    --admin-accent: #c2410c;
    --admin-accent-soft: rgba(194, 65, 12, .1);
    --admin-shadow: 0 10px 30px rgba(63, 51, 44, .07);
    --admin-radius: 18px;
}

* { box-sizing: border-box; }

body {
    background: var(--admin-bg);
    color: #3f332c;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: #241a14; font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -.02em; }

a { color: var(--admin-accent); text-decoration: none; }
a:hover { color: color-mix(in srgb, var(--admin-accent) 80%, #000); }

[hidden] { display: none !important; }

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

.admin-sidebar {
    background:
        radial-gradient(500px 300px at 50% -10%, rgba(194, 65, 12, .2), transparent 60%),
        var(--admin-sidebar);
    border-right: 1px solid rgba(255, 255, 255, .06);
    color: #fffaf3;
    display: flex;
    flex-direction: column;
    flex: none;
    width: 268px;
}

@media (min-width: 992px) {
    .admin-sidebar { min-height: 100vh; position: sticky; top: 0; }
}

.admin-brand {
    align-items: center;
    color: #fffaf3;
    display: flex;
    gap: .75rem;
    padding: 1.5rem 1.35rem 1.25rem;
}
.admin-brand:hover { color: #fffaf3; }
.admin-brand-mark {
    align-items: center;
    background: linear-gradient(145deg, var(--admin-accent), color-mix(in srgb, var(--admin-accent) 60%, #5b1b00));
    border-radius: 13px;
    display: flex;
    font-family: "Fraunces", serif;
    font-size: 1.05rem;
    font-weight: 700;
    height: 42px;
    justify-content: center;
    width: 42px;
    flex: none;
}
.admin-brand-name { font-family: "Fraunces", serif; font-size: 1.05rem; font-weight: 600; line-height: 1.2; }
.admin-brand small { color: rgba(255, 250, 243, .45); display: block; font-family: "Inter", sans-serif; font-size: .62rem; font-weight: 700; letter-spacing: .12em; margin-top: .25rem; text-transform: uppercase; }

.admin-nav { display: flex; flex-direction: column; gap: .2rem; padding: .75rem; }
.admin-nav-label { color: rgba(255, 250, 243, .35); font-size: .62rem; font-weight: 800; letter-spacing: .15em; padding: .85rem .85rem .5rem; text-transform: uppercase; }
.admin-nav-link {
    align-items: center;
    border-radius: 11px;
    color: var(--admin-sidebar-soft);
    display: flex;
    font-size: .86rem;
    font-weight: 500;
    gap: .7rem;
    padding: .62rem .85rem;
    transition: background-color .15s ease, color .15s ease;
}
.admin-nav-link i { font-size: 1.02rem; width: 20px; text-align: center; }
.admin-nav-link:hover { background: rgba(255, 255, 255, .06); color: #fffaf3; }
.admin-nav-link.active { background: var(--admin-accent); color: #fff; box-shadow: 0 8px 20px rgba(0, 0, 0, .25); }
.admin-nav-link .nav-badge {
    background: rgba(255, 255, 255, .16);
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 700;
    margin-left: auto;
    padding: .1rem .4rem;
}
.admin-nav-link.active .nav-badge { background: rgba(0, 0, 0, .22); }

.admin-sidebar-footer { margin-top: auto; padding: 1rem .75rem 1.25rem; }
.admin-sidebar-footer .btn { border-radius: 10px; font-size: .8rem; }
.sidebar-user {
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    gap: .6rem;
    margin-top: .9rem;
    padding-top: 1rem;
}
.sidebar-avatar {
    align-items: center;
    background: rgba(255, 255, 255, .1);
    border-radius: 50%;
    color: #fffaf3;
    display: flex;
    font-size: .75rem;
    font-weight: 700;
    height: 34px;
    justify-content: center;
    width: 34px;
}
.sidebar-user-name { color: #fffaf3; font-size: .78rem; font-weight: 600; line-height: 1.2; }
.sidebar-user small { color: rgba(255, 250, 243, .4); font-size: .64rem; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    align-items: center;
    background: rgba(255, 253, 250, .88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--admin-line);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: .95rem clamp(1rem, 3vw, 2rem);
    position: sticky;
    top: 0;
    z-index: 1020;
}
.admin-topbar-title h1 { font-size: 1.2rem; line-height: 1.2; margin: 0; }
.admin-topbar-title p { color: var(--admin-muted); font-size: .72rem; margin: .15rem 0 0; }
.admin-topbar-actions { align-items: center; display: flex; gap: .5rem; }

.admin-content { padding: clamp(1rem, 2.5vw, 2rem); }

/* Componentes -------------------------------------------------------------- */
.admin-card {
    background: var(--admin-paper);
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow);
}

.admin-card-header {
    align-items: center;
    border-bottom: 1px solid var(--admin-line);
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}
.admin-card-header h2 { font-size: 1.02rem; margin: 0; }
.admin-card-body { padding: 1.25rem; }
.admin-card-body-p0 { padding: 0; }

.stat-card {
    background: var(--admin-paper);
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    box-shadow: var(--admin-shadow);
    padding: 1.1rem 1.2rem;
    height: 100%;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    background: var(--admin-accent-soft);
    border-radius: 50%;
    content: "";
    height: 80px;
    position: absolute;
    right: -25px;
    top: -25px;
    width: 80px;
}
.stat-icon {
    align-items: center;
    background: var(--admin-accent-soft);
    border-radius: 12px;
    color: var(--admin-accent);
    display: flex;
    font-size: 1.1rem;
    height: 40px;
    justify-content: center;
    margin-bottom: .8rem;
    width: 40px;
    position: relative;
    z-index: 1;
}
.stat-label { color: var(--admin-muted); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.stat-value { color: #241a14; font-family: "Fraunces", serif; font-size: 1.75rem; font-weight: 600; line-height: 1.1; margin-top: .2rem; }
.stat-hint { color: var(--admin-muted); font-size: .7rem; margin-top: .25rem; }

.btn {
    border-radius: 10px;
    font-size: .83rem;
    font-weight: 600;
}
.btn-brand { background: var(--admin-accent); border-color: var(--admin-accent); color: #fff; }
.btn-brand:hover { background: color-mix(in srgb, var(--admin-accent) 85%, #000); border-color: color-mix(in srgb, var(--admin-accent) 85%, #000); color: #fff; }
.btn-soft { background: var(--admin-accent-soft); border-color: transparent; color: var(--admin-accent); }
.btn-soft:hover { background: color-mix(in srgb, var(--admin-accent) 18%, transparent); color: var(--admin-accent); }
.btn-outline-secondary { border-color: var(--admin-line); color: #5b4a3e; }
.btn-outline-secondary:hover { background: #f3ebe1; border-color: #e0d3c5; color: #241a14; }
.btn-icon { align-items: center; display: inline-flex; gap: .35rem; }

.form-label { color: #3f332c; font-size: .76rem; font-weight: 700; margin-bottom: .35rem; }
.form-control, .form-select {
    background-color: #fff;
    border: 1px solid #dfd3c6;
    border-radius: 10px;
    color: #241a14;
    font-size: .86rem;
    padding: .55rem .75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--admin-accent) 12%, transparent);
}
.form-text { color: var(--admin-muted); font-size: .72rem; }
.form-check-input:checked { background-color: var(--admin-accent); border-color: var(--admin-accent); }

.badge-status {
    border-radius: 999px;
    display: inline-flex;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: .28rem .62rem;
    text-transform: uppercase;
}
.badge-pendiente { background: #fff1c9; color: #7a5300; }
.badge-asignado { background: #e3edff; color: #1e4b9e; }
.badge-en_camino { background: #dff4fb; color: #0d5c73; }
.badge-entregado { background: #e2f6eb; color: #14603c; }
.badge-cancelado { background: #fde8e6; color: #8a1c12; }

.table { font-size: .84rem; margin: 0; }
.table > :not(caption) > * > * { border-bottom-color: var(--admin-line); padding: .8rem 1rem; vertical-align: middle; }
.table thead th { background: #faf6f0; color: var(--admin-muted); font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.table tbody tr:hover { background: #fffaf4; }
.table a { font-weight: 600; }

.admin-empty { padding: 3rem 1.25rem; text-align: center; }
.admin-empty i { color: #cbb9a9; font-size: 2.2rem; }
.admin-empty h3 { font-size: 1.1rem; margin: .75rem 0 .3rem; }
.admin-empty p { color: var(--admin-muted); font-size: .82rem; margin: 0 auto; max-width: 26rem; }

.thumb {
    align-items: center;
    background: #f3ebe1;
    border-radius: 10px;
    display: flex;
    flex: none;
    height: 46px;
    justify-content: center;
    overflow: hidden;
    width: 58px;
    color: #b09b89;
}
.thumb img { height: 100%; object-fit: cover; width: 100%; }
.thumb-lg { height: 110px; width: 150px; border-radius: 12px; }

.menu-day-group + .menu-day-group { margin-top: 1.75rem; }
.menu-day-heading {
    align-items: center;
    display: flex;
    gap: .75rem;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .12em;
    margin-bottom: .75rem;
    text-transform: uppercase;
    color: var(--admin-muted);
}
.menu-day-heading::after { background: var(--admin-line); content: ""; flex: 1; height: 1px; }
.menu-day-heading .today-pill { background: var(--admin-accent-soft); border-radius: 999px; color: var(--admin-accent); font-size: .6rem; padding: .2rem .5rem; }

.admin-menu-row {
    align-items: center;
    border-top: 1px solid var(--admin-line);
    display: flex;
    gap: 1rem;
    padding: .9rem 1.25rem;
}
.admin-menu-row:first-child { border-top: 0; }
.admin-menu-info { flex: 1; min-width: 0; }
.admin-menu-info h3 { font-family: "Inter", sans-serif; font-size: .88rem; font-weight: 600; margin: 0 0 .15rem; }
.admin-menu-info p { color: var(--admin-muted); font-size: .74rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36rem; }
.admin-menu-price { font-family: "Fraunces", serif; font-size: 1rem; font-weight: 600; white-space: nowrap; }
.admin-menu-actions { align-items: center; display: flex; gap: .35rem; flex: none; }

/* Login -------------------------------------------------------------------- */
.login-page {
    align-items: stretch;
    background: var(--admin-bg);
    display: flex;
    min-height: 100vh;
}
.login-visual {
    background:
        radial-gradient(700px 400px at 80% 10%, rgba(251, 191, 36, .35), transparent 60%),
        radial-gradient(600px 500px at 10% 90%, rgba(194, 65, 12, .55), transparent 65%),
        linear-gradient(140deg, #7c2d12, #b45309 55%, #57200b);
    color: #fffaf3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    position: relative;
    width: 46%;
    overflow: hidden;
}
.login-visual::after {
    background-image: radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px);
    background-size: 22px 22px;
    content: "";
    inset: 0;
    mask-image: linear-gradient(to top, transparent, #000 40%);
    position: absolute;
}
.login-visual > * { position: relative; z-index: 1; }
.login-visual h1 { color: #fffaf3; font-size: clamp(2rem, 3.5vw, 3.2rem); line-height: 1.05; margin-top: auto; }
.login-visual p { color: rgba(255, 250, 243, .72); max-width: 28rem; }
.login-form-side { align-items: center; display: flex; flex: 1; justify-content: center; padding: 2rem; }
.login-card { background: var(--admin-paper); border: 1px solid var(--admin-line); border-radius: 22px; box-shadow: 0 30px 80px rgba(63, 51, 44, .14); max-width: 410px; padding: clamp(1.75rem, 4vw, 2.75rem); width: 100%; }
.login-card h2 { font-size: 1.65rem; margin-bottom: .3rem; }
.login-logo { max-height: 50px; max-width: 180px; margin-bottom: 1.1rem; object-fit: contain; }
.login-hint { background: #faf3e8; border-radius: 10px; color: var(--admin-muted); font-size: .72rem; padding: .65rem .8rem; }

/* Pedidos ------------------------------------------------------------------ */
.order-list-row { align-items: center; border-bottom: 1px solid var(--admin-line); color: #3f332c; display: flex; gap: .8rem; padding: .85rem 1.1rem; }
.order-list-row:last-child { border-bottom: 0; }
.order-list-row:hover, .order-list-row.active { background: #fff6ec; color: #3f332c; }
.order-list-row.active { box-shadow: inset 3px 0 0 var(--admin-accent); }
.order-list-main { flex: 1; min-width: 0; }
.order-list-main strong { display: block; font-size: .84rem; line-height: 1.3; }
.order-list-main span { color: var(--admin-muted); display: block; font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-list-meta { text-align: right; flex: none; }
.order-list-meta strong { display: block; font-family: "Fraunces", serif; font-size: .95rem; }
.order-list-meta span { color: var(--admin-muted); font-size: .66rem; }

.detail-section + .detail-section { border-top: 1px solid var(--admin-line); margin-top: 1rem; padding-top: 1rem; }
.detail-label { color: var(--admin-muted); font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .2rem; }
.detail-value { font-size: .87rem; font-weight: 500; overflow-wrap: anywhere; }
.detail-value a { color: var(--admin-accent); }
.detail-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.order-items-list { display: flex; flex-direction: column; gap: .55rem; }
.order-item-line { align-items: baseline; display: flex; gap: 1rem; justify-content: space-between; font-size: .82rem; }
.order-item-line .name { color: #3f332c; }
.order-item-line .meta { color: var(--admin-muted); font-size: .7rem; }
.order-total-line { align-items: baseline; display: flex; justify-content: space-between; padding-top: .75rem; border-top: 1px dashed var(--admin-line); }
.order-total-line strong { font-family: "Fraunces", serif; font-size: 1.35rem; }

.driver-live-card { background: #faf5ee; border: 1px solid var(--admin-line); border-radius: 14px; padding: .9rem 1rem; }
.live-indicator { align-items: center; color: #14603c; display: inline-flex; font-size: .7rem; font-weight: 700; gap: .35rem; }
.live-indicator::before { background: #1f9d64; border-radius: 50%; box-shadow: 0 0 0 4px rgba(31, 157, 100, .16); content: ""; height: 7px; width: 7px; }
.live-indicator.is-stale { color: var(--admin-muted); }
.live-indicator.is-stale::before { background: #b9a99b; box-shadow: none; }

#orderDetailMap, #liveDriversMap { height: 340px; width: 100%; border-radius: 14px; }
.map-wrap { border: 1px solid var(--admin-line); border-radius: 14px; overflow: hidden; }
.map-legend { align-items: center; display: flex; flex-wrap: wrap; gap: 1rem; color: var(--admin-muted); font-size: .68rem; margin-top: .5rem; }
.map-legend i { font-size: .8rem; }
.legend-dot { border-radius: 50%; display: inline-block; height: 8px; margin-right: .25rem; width: 8px; }

/* Repartidores ------------------------------------------------------------- */
.driver-card { display: flex; flex-direction: column; height: 100%; }
.driver-card .driver-head { align-items: center; display: flex; gap: .75rem; }
.driver-avatar-lg {
    align-items: center;
    background: linear-gradient(145deg, var(--admin-accent), color-mix(in srgb, var(--admin-accent) 65%, #5b1b00));
    border-radius: 14px;
    color: #fff;
    display: flex;
    font-family: "Fraunces", serif;
    font-size: 1.25rem;
    flex: none;
    height: 48px;
    justify-content: center;
    width: 48px;
}
.driver-link-box {
    align-items: center;
    background: #faf5ee;
    border: 1px dashed #dccbbc;
    border-radius: 10px;
    display: flex;
    gap: .5rem;
    padding: .5rem .65rem;
}
.driver-link-box input { background: transparent; border: 0; color: var(--admin-muted); flex: 1; font-size: .68rem; min-width: 0; outline: none; }
.driver-meta { color: var(--admin-muted); font-size: .72rem; }
.driver-meta i { color: var(--admin-accent); }

/* Configuración / vista previa -------------------------------------------- */
.preview-hero {
    border-radius: 18px;
    min-height: 280px;
    overflow: hidden;
    position: relative;
    background-color: #7c2d12;
    background-image:
        linear-gradient(var(--preview-overlay, rgba(20, 13, 8, .45)), var(--preview-overlay, rgba(20, 13, 8, .45))),
        var(--preview-bg, radial-gradient(400px 300px at 80% 10%, #d97706, transparent 60%), linear-gradient(135deg, #7c2d12, #b45309));
    background-position: center;
    background-size: cover;
    display: flex;
    align-items: center;
    padding: 1.5rem;
}
.preview-card {
    background: rgba(255, 250, 243, .95);
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .25);
    padding: 1.4rem;
    width: 100%;
}
.preview-eyebrow { color: var(--preview-accent, #c2410c); font-size: .58rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.preview-card h3 { color: var(--preview-heading, #241a14); font-size: 1.35rem; line-height: 1.1; margin: .35rem 0; }
.preview-card p { color: var(--preview-text, #3f332c); font-size: .76rem; margin-bottom: .9rem; }
.preview-btn { background: var(--preview-accent, #c2410c); border-radius: 999px; color: var(--preview-accent-text, #fff); display: inline-block; font-size: .7rem; font-weight: 700; padding: .4rem .9rem; }
.preview-logo { max-height: 40px; max-width: 140px; margin-bottom: .7rem; object-fit: contain; }

.color-input-row { align-items: center; display: flex; gap: .5rem; }
.color-input-row input[type="color"] { background: #fff; border: 1px solid #dfd3c6; border-radius: 8px; height: 36px; padding: .15rem; width: 44px; flex: none; }
.image-preview { background: #faf5ee; border: 1px dashed #dccbbc; border-radius: 12px; display: flex; align-items: center; justify-content: center; min-height: 90px; overflow: hidden; padding: .5rem; }
.image-preview img { max-height: 110px; max-width: 100%; object-fit: contain; }
.image-preview.is-bg img { max-height: 150px; width: 100%; object-fit: cover; }

/* Toasts ------------------------------------------------------------------- */
.toast-container { z-index: 1090; }
.toast { border: 0; border-radius: 12px; box-shadow: 0 16px 40px rgba(63, 51, 44, .18); }
.toast-body { font-size: .82rem; }

/* Utilidades --------------------------------------------------------------- */
.text-muted { color: var(--admin-muted) !important; }
.small, small { font-size: .76em; }
.fw-600 { font-weight: 600; }
.divider { background: var(--admin-line); height: 1px; margin: 1rem 0; }
.code-chip { background: #faf5ee; border-radius: 8px; color: #5b4a3e; display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; letter-spacing: .04em; padding: .2rem .45rem; }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .admin-offcanvas { width: 280px !important; background: var(--admin-sidebar) !important; color: #fffaf3; }
    .admin-offcanvas .btn-close { filter: invert(1); opacity: .6; }
    .admin-content { padding: 1rem; }
    .login-visual { display: none; }
    .login-page { align-items: center; }
    .login-form-side { padding: 1.25rem; }
}

@media (max-width: 575.98px) {
    .detail-grid { grid-template-columns: 1fr; }
    .admin-menu-row { flex-wrap: wrap; }
    .admin-menu-actions { margin-left: auto; }
    .admin-menu-info p { max-width: 100%; white-space: normal; }
    .admin-topbar-title p { display: none; }
    #orderDetailMap, #liveDriversMap { height: 280px; }
    .order-list-meta { display: none; }
}
