/* ==========================================================
   Panel Administrativo — Sistema de diseño
   Inspirado en Stripe/Linear/Vercel, identidad propia.
   Todo mediante CSS variables para soportar dark mode nativo.
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f6;
    --border: #e5e5ea;
    --text: #14151a;
    --text-2: #6b6f76;
    --text-3: #9a9da3;

    --accent: #5b5bd6;
    --accent-hover: #4c4cc4;
    --accent-soft: #eef0ff;
    --accent-text: #ffffff;

    --success: #16a34a;
    --success-soft: #e8f7ee;
    --warning: #d97706;
    --warning-soft: #fdf3e7;
    --danger: #dc2626;
    --danger-soft: #fdeaea;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
    --shadow-md: 0 4px 16px rgba(16,24,40,.08);
    --shadow-lg: 0 12px 32px rgba(16,24,40,.12);

    --sidebar-w: 240px;
    --sidebar-w-collapsed: 72px;
    --header-h: 64px;
}

[data-theme="dark"] {
    --bg: #0d0e12;
    --surface: #16171c;
    --surface-2: #1c1e24;
    --border: #2a2c33;
    --text: #f2f2f5;
    --text-2: #a3a6ad;
    --text-3: #6f727a;

    --accent: #8b7ffb;
    --accent-hover: #9d92ff;
    --accent-soft: rgba(139,127,251,0.14);
    --accent-text: #14151a;

    --success-soft: rgba(22,163,74,0.14);
    --warning-soft: rgba(217,119,6,0.14);
    --danger-soft: rgba(220,38,38,0.14);

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

body.admin-shell {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background .2s ease, color .2s ease;
    overflow-x: hidden;
}

.admin-shell a { color: inherit; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ================= LAYOUT ================= */
.shell {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width .18s ease;
}
.shell.colapsado .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar__marca {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
}
.sidebar__marca-icono {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.sidebar__marca-nombre { font-weight: 700; font-size: 14px; }
.sidebar__marca-sub { font-size: 11px; color: var(--text-3); }

.sidebar__nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    transition: background .12s ease, color .12s ease;
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.activo { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.shell.colapsado .nav-item span.label { display: none; }
.shell.colapsado .sidebar__marca-nombre,
.shell.colapsado .sidebar__marca-sub { display: none; }

.sidebar__pie {
    border-top: 1px solid var(--border);
    padding: 12px;
}
.sidebar__usuario {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--text-2);
    flex-shrink: 0;
}
.sidebar__usuario-info { overflow: hidden; white-space: nowrap; }
.sidebar__usuario-nombre { font-size: 13px; font-weight: 600; }
.sidebar__usuario-rol { font-size: 11px; color: var(--text-3); }
.shell.colapsado .sidebar__usuario-info { display: none; }

.sidebar__toggle {
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    width: 100%; padding: 6px; margin-top: 8px; cursor: pointer;
    color: var(--text-2); font-size: 12px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.sidebar__toggle:hover { background: var(--surface-2); }

/* ---- Main / Header ---- */
.main-area { flex: 1; min-width: 0; }
.topbar {
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 16px;
}
.breadcrumb { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.breadcrumb strong { color: var(--text); font-weight: 600; }

.topbar__buscador { flex: 1; max-width: 360px; position: relative; }
.topbar__buscador input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 32px;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
}
.topbar__buscador svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 15px; height: 15px; }
.topbar__buscador-resultados {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); overflow: hidden; display: none; z-index: 20;
}
.topbar__buscador-resultados.visible { display: block; }
.topbar__buscador-resultados a {
    display: block; padding: 9px 12px; font-size: 13px; text-decoration: none; color: var(--text);
}
.topbar__buscador-resultados a:hover { background: var(--surface-2); }

.topbar__acciones { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar__fecha { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.topbar__estado { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.topbar__estado-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

.icon-btn {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-2); position: relative;
    text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn__badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

.dropdown { position: relative; }
.dropdown__panel {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md); min-width: 220px; padding: 6px; display: none; z-index: 30;
}
.dropdown__panel.visible { display: block; }
.dropdown__item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px;
    text-decoration: none; color: var(--text); cursor: pointer; background: none; border: none; width: 100%; text-align: left;
    font-family: inherit;
}
.dropdown__item:hover { background: var(--surface-2); }
.dropdown__titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 6px 10px 4px; }
.dropdown__separador { height: 1px; background: var(--border); margin: 6px 0; }

main.contenido { padding: 24px; max-width: 1200px; }

/* ==========================================================
   Compatibilidad temporal con clases del panel viejo.
   Se retira a medida que cada pantalla se migra al nuevo
   sistema de diseño (empleados, servicios, horarios,
   configuración, galería, reservas, login).
   ========================================================== */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.flash.success { background: var(--success-soft); color: var(--success); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
table:not(.tabla-moderna) { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
table:not(.tabla-moderna) th, table:not(.tabla-moderna) td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text); }
table:not(.tabla-moderna) th { background: var(--surface-2); font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--text-2); }
a.btn, button.btn:not([class*="btn-"]) {
    display: inline-block; padding: 9px 16px; background: var(--accent); color: var(--accent-text);
    border: none; border-radius: var(--radius-sm); text-decoration: none; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.card:not(.card-pad) { background: var(--surface); border-radius: var(--radius-md); padding: 16px 20px; margin-bottom: 16px; border: 1px solid var(--border); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.grid-cards .card h3 { margin: 0 0 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.grid-cards .card p { margin: 0; font-size: 26px; font-weight: 700; }
form.formulario label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--text); }
form.formulario input[type=text], form.formulario input[type=number],
form.formulario input[type=email], form.formulario input[type=tel],
form.formulario input[type=time], form.formulario input[type=date],
form.formulario textarea, form.formulario select {
    width: 100%; padding: 9px; margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-family: inherit;
}
h1:not(.titulo-pagina) { font-size: 20px; font-weight: 700; margin: 0 0 16px; }

/* ---- Horario semanal (filas, mejor que tabla para móvil) ---- */
.horario-semanal { display: flex; flex-direction: column; }
.horario-semanal__fila {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.horario-semanal__fila:last-child { border-bottom: none; }
.horario-semanal__dia { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; min-width: 140px; }
.horario-semanal__horas { display: flex; align-items: center; gap: 8px; }
.horario-semanal__horas input { max-width: 120px; }
.horario-semanal__separador { color: var(--text-3); }
@media (max-width: 480px) {
    .horario-semanal__fila { flex-direction: column; align-items: stretch; }
    .horario-semanal__horas { width: 100%; }
    .horario-semanal__horas input { max-width: none; flex: 1; }
}

/* ================= COMPONENTES ================= */

h1.titulo-pagina { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
p.subtitulo-pagina { color: var(--text-2); font-size: 13.5px; margin: 0 0 24px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
    font-family: inherit; transition: background .12s ease, border-color .12s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-hover { transition: box-shadow .15s ease, transform .15s ease; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.form-grupo { margin-bottom: 16px; }
.form-grupo label {
    display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text);
}
.form-grupo .ayuda { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-control {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 13.5px;
    color: var(--text);
    font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.form-control { resize: vertical; min-height: 70px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .rail {
    position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background .15s ease;
}
.switch .rail::before {
    content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: var(--shadow-sm);
}
.switch input:checked + .rail { background: var(--accent); }
.switch input:checked + .rail::before { transform: translateX(16px); }
.switch-linea { display: flex; align-items: center; gap: 10px; }
.switch-linea label { font-size: 13.5px; font-weight: 500; margin: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
    padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
    text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.activo { color: var(--accent); border-color: var(--accent); }

table.tabla-moderna { width: 100%; border-collapse: collapse; }
.tabla-moderna thead th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.tabla-moderna tbody td {
    padding: 13px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); color: var(--text);
}
.tabla-moderna tbody tr { transition: background .1s ease; }
.tabla-moderna tbody tr:hover { background: var(--surface-2); }
.tabla-moderna tbody tr:last-child td { border-bottom: none; }

.estado-vacio {
    text-align: center; padding: 48px 20px; color: var(--text-3);
}
.estado-vacio svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .5; }
.estado-vacio p { font-size: 13.5px; margin: 0 0 16px; }

.toast-contenedor {
    position: fixed; top: 20px; right: 20px; z-index: 100;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); padding: 12px 16px; font-size: 13.5px; min-width: 260px;
    display: flex; align-items: center; gap: 10px;
    animation: toast-in .2s ease;
}
.toast.exito { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
    background-size: 400px 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--radius-sm);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
    .shell.sidebar-abierta .sidebar { transform: translateX(0); }
    .shell.sidebar-abierta::after {
        content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39;
    }
    .topbar__buscador { display: none; }
    #btn-menu-movil { display: flex !important; }
    main.contenido { padding: 16px; }
}

@media (max-width: 480px) {
    .topbar__fecha, .topbar__estado { display: none; }
    .topbar { padding: 0 12px; gap: 8px; }
}

@media (max-width: 640px) {
    /* Botones: área táctil mínima cómoda */
    .btn, a.btn, button.btn:not([class*="btn-"]) { min-height: 42px; padding: 10px 16px; }
    .btn-sm { min-height: 36px; padding: 8px 12px; }

    /* Tarjetas de estadísticas: 2 por fila en vez de apretadas */
    div[style*="grid-template-columns:repeat(auto-fit,minmax(180px,1fr))"] { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }

    /* Formularios a ancho completo, campos en columna */
    .card-pad { padding: 16px; }
    div[style*="display:flex; gap:12px"] { flex-direction: column; gap: 0 !important; }

    /* Header de página: apilar título y botón de acción */
    div[style*="justify-content:space-between; align-items:flex-end"] {
        flex-direction: column; align-items: stretch !important; gap: 12px;
    }
    div[style*="justify-content:space-between; align-items:flex-end"] > a.btn { width: 100%; text-align: center; }

    /* ---- Tablas -> tarjetas ---- */
    table.tabla-moderna, table:not(.tabla-moderna) {
        border: none; background: none; box-shadow: none;
    }
    table.tabla-moderna thead, table:not(.tabla-moderna) thead { display: none; }
    table.tabla-moderna tbody tr, table:not(.tabla-moderna) tbody tr {
        display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
        margin-bottom: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm);
    }
    table.tabla-moderna tbody td, table:not(.tabla-moderna) tbody td {
        display: flex; justify-content: space-between; align-items: center; gap: 10px;
        padding: 7px 0; border-bottom: 1px dashed var(--border); text-align: right;
    }
    table.tabla-moderna tbody td:last-child, table:not(.tabla-moderna) tbody td:last-child { border-bottom: none; }
    table.tabla-moderna tbody td::before, table:not(.tabla-moderna) tbody td::before {
        content: attr(data-label); font-size: 11px; font-weight: 600; text-transform: uppercase;
        letter-spacing: .03em; color: var(--text-3); text-align: left; flex-shrink: 0;
    }
    table.tabla-moderna tbody td[data-label=""]::before,
    table.tabla-moderna tbody td:not([data-label])::before { content: none; }
    table.tabla-moderna tbody td form, table:not(.tabla-moderna) tbody td form { display: inline-flex; }
}
