/* ============================================
   BimPos - Panel Admin
   Colores: Azul / Rojo / Blanco
   ============================================ */

:root {
    --blue: #1565C0;
    --blue-dark: #0D47A1;
    --blue-light: #E3F2FD;
    --red: #D32F2F;
    --gray-bg: #F5F7FA;
    --text: #212121;
    --text-muted: #757575;
    --border: #E0E0E0;
    --green: #2E7D32;
    --orange: #EF6C00;
    --sidebar-w: 230px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--gray-bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.text-muted { color: var(--text-muted); }

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

.admin-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--blue-dark), var(--blue));
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px;
    font-size: 1.15rem;
    font-weight: 800;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background 0.15s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav-item.active { background: #fff; color: var(--blue-dark); }
.nav-item .icon { font-size: 1.1rem; }

.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, 0.15); }

.admin-main { margin-left: var(--sidebar-w); flex: 1; padding: 26px; min-width: 0; }
.admin-content { max-width: 1200px; }

@media (max-width: 760px) {
    .admin-sidebar { width: 62px; }
    .sidebar-brand { font-size: 0; padding: 16px 0; text-align: center; justify-content: center; }
    .sidebar-brand span { font-size: 1.5rem; }
    .nav-item { justify-content: center; font-size: 0; padding: 12px 0; }
    .nav-item .icon { font-size: 1.2rem; }
    .admin-main { margin-left: 62px; padding: 16px; }
}

/* ---------- Cabecera ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0; }
.live-date { color: var(--text-muted); font-size: 0.9rem; text-transform: capitalize; }

/* ---------- Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border-top: 4px solid var(--blue);
}

.stat-card.blue { border-top-color: var(--blue); }
.stat-card.orange { border-top-color: var(--orange); }
.stat-card.green { border-top-color: var(--green); }
.stat-card.dark { border-top-color: #37474F; }
.stat-card.red { border-top-color: var(--red); }

.stat-icon { font-size: 1.4rem; }
.stat-value { font-size: 1.7rem; font-weight: 800; margin: 6px 0 2px; }
.stat-label { color: var(--text-muted); font-size: 0.82rem; font-weight: 600; }

/* ---------- Paneles ---------- */
.panel {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 20px;
    margin-bottom: 18px;
    overflow-x: auto;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.panel-head h2 { font-size: 1.05rem; font-weight: 800; margin: 0; }

.btn-link { color: var(--blue); font-weight: 700; text-decoration: none; font-size: 0.9rem; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Tablas ---------- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 10px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.admin-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tbody tr:hover { background: var(--blue-light); }

.table-total td { border-top: 2px solid var(--border); font-weight: 600; }

/* ---------- Badges ---------- */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.status-recibido { background: var(--blue); }
.status-en-preparación { background: var(--orange); }
.status-en-camino { background: #7B1FA2; }
.status-entregado { background: var(--green); }
.status-cancelado { background: #9E9E9E; }

.pill { display: inline-block; padding: 4px 12px; border-radius: 30px; font-size: 0.75rem; font-weight: 700; }
.pill-green { background: #E8F5E9; color: var(--green); }
.pill-gray { background: #ECEFF1; color: var(--text-muted); }

/* ---------- Formularios ---------- */
.form-input {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
}

.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12); }

.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: flex-end; }

.submit-btn {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.submit-btn:active { filter: brightness(0.9); }
.w-100 { width: 100% !important; }

/* ---------- Detalle pedido ---------- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.detail-info { display: flex; flex-direction: column; gap: 8px; }

.detail-info > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.detail-info span { color: var(--text-muted); }
.link-phone { color: var(--blue); text-decoration: none; font-weight: 600; }

.status-panel .status-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.status-btn {
    border: 2px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.15s;
}

.status-btn.selected { color: #fff; border-color: transparent; }
.status-btn.status-recibido.selected { background: var(--blue); }
.status-btn.status-en-preparación.selected { background: var(--orange); }
.status-btn.status-en-camino.selected { background: #7B1FA2; }
.status-btn.status-entregado.selected { background: var(--green); }
.status-btn.status-cancelado.selected { background: #9E9E9E; }

.danger-zone { margin-top: 14px; }

.delivery-form { margin-top: 16px; padding: 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; }
.delivery-form label { font-weight: 700; font-size: 0.85rem; display: block; margin-bottom: 8px; }
.delivery-row { display: flex; gap: 8px; }
.delivery-row .form-input { flex: 1; }
.btn-primary {
    background: var(--blue);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.btn-primary:hover { background: var(--blue-dark); }

.wa-client-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    margin-top: 16px;
    font-size: 0.9rem;
}
.wa-client-btn:hover { background: #1EBE5A; color: #fff; }

.qr-mini { width: 110px; height: 110px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; margin-top: 6px; }
.qr-mini-key { display: block; font-weight: 700; color: var(--blue-dark); background: var(--blue-light, #E3F2FD); padding: 4px 10px; border-radius: 6px; font-size: 0.85rem; margin-top: 6px; }

.danger-btn {
    background: #fff;
    color: var(--red);
    border: 1.5px solid var(--red);
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}

.danger-btn:hover { background: var(--red); color: #fff; }

/* ---------- Productos ---------- */
.row-actions { display: flex; gap: 6px; align-items: center; }

.mini-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.mini-btn.danger { color: var(--red); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 16px;
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-box h3 { margin: 0 0 16px; font-size: 1.2rem; font-weight: 800; }

.modal-actions { display: flex; justify-content: flex-end; gap: 14px; align-items: center; margin-top: 14px; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 14px; }
.alert-success { background: #E8F5E9; color: var(--green); }
.alert-danger { background: #FFEBEE; color: var(--red); }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue-dark), var(--blue) 55%, var(--red));
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    padding: 36px 30px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    font-size: 3rem;
    width: 84px; height: 84px;
    background: var(--blue-light);
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
}

.login-card h1 { font-size: 1.4rem; font-weight: 800; margin: 0 0 4px; }
.login-card p { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 18px; }
.login-card .form-input { margin-bottom: 12px; text-align: center; }

.login-hint { color: var(--text-muted); font-size: 0.78rem; text-decoration: none; display: inline-block; margin-top: 14px; }
.login-hint:hover { text-decoration: underline; }
