/* ============================================================
   Turnos SaaS — UI moderna estilo SaaS
   ============================================================ */

:root {
    --primary:        #1f73f1;
    --primary-dark:   #1559c6;
    --primary-soft:   #eaf3ff;
    --success:        #16a34a;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #06b6d4;
    --bg:             #f6f8fb;
    --surface:        #ffffff;
    --border:         #e5e9f0;
    --text:           #1f2937;
    --text-muted:     #6b7280;
    --sidebar-bg:     #0f172a;
    --sidebar-text:   #cbd5e1;
    --sidebar-active: rgba(255,255,255,.12);
    --shadow-sm:      0 1px 3px rgba(15,23,42,.08);
    --shadow-md:      0 4px 12px rgba(15,23,42,.10);
    --shadow-lg:      0 12px 40px rgba(15,23,42,.18);
    --radius:         12px;
    --radius-lg:      16px;
}

[data-bs-theme="dark"] {
    --bg:        #0b1220;
    --surface:   #131c2f;
    --border:    #21304a;
    --text:      #e5e9f2;
    --text-muted:#94a3b8;
    --primary-soft: #16243d;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------- Sidebar ----------- */
.layout-app {
    min-height: 100vh;
    padding-left: 256px;
}
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 256px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex; flex-direction: column;
    z-index: 1040;
    box-shadow: var(--shadow-lg);
}
.sidebar-brand {
    padding: 22px 18px;
    display: flex; gap: 12px; align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff; font-weight: 700; font-size: 18px;
    display: grid; place-items: center;
    box-shadow: 0 6px 20px rgba(31,115,241,.35);
}
.brand-mark.large { width: 56px; height: 56px; font-size: 26px; border-radius: 14px; }
.brand-name { color: #fff; font-weight: 600; font-size: 15px; }
.brand-subtitle { font-size: 11px; color: #94a3b8; }
.sidebar-nav {
    padding: 10px 8px;
    flex: 1;
    overflow-y: auto;
}
.sidebar-section {
    color: #64748b;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .04em;
    padding: 14px 12px 6px;
}
.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    border-radius: 10px;
    margin-bottom: 2px;
    font-weight: 500;
    transition: background .12s;
    text-decoration: none;
}
.sidebar-nav .nav-item:hover {
    background: var(--sidebar-active);
    color: #fff;
}
.sidebar-nav .nav-item i { width: 18px; }
.sidebar-footer {
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex; justify-content: space-between;
}
.theme-toggle {
    background: none; border: 0; color: #94a3b8;
    width: 38px; height: 38px; border-radius: 50%;
    transition: background .12s;
    cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ----------- Topbar ----------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 1030;
}
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-icon {
    background: none; border: 0; font-size: 22px;
    width: 40px; height: 40px; border-radius: 8px;
    color: var(--text); cursor: pointer;
}
.btn-icon:hover { background: var(--bg); }

/* User chip */
.user-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 999px;
    cursor: pointer; transition: background .12s;
    color: var(--text);
}
.user-chip:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6f9eff);
    color: #fff; display: grid; place-items: center;
    font-weight: 600; font-size: 14px;
}
.user-name  { font-size: 13px; font-weight: 600; line-height: 1.1; }
.user-role  { font-size: 11px; color: var(--text-muted); }

/* ----------- Main ----------- */
.main-content { padding: 26px; }
.page-header {
    display: flex; justify-content: space-between; align-items: end;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 22px;
}
.page-title {
    font-size: 24px; font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, var(--text), var(--text-muted));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.page-subtitle { color: var(--text-muted); font-size: 14px; margin: 4px 0 0; }

/* ----------- Cards / Stat ----------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: transparent; border-bottom: 1px solid var(--border);
    padding: 14px 18px; font-weight: 600;
}
.chart-card { min-height: 240px; }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: grid; place-items: center;
    color: #fff; font-size: 22px;
    flex-shrink: 0;
}
.stat-card.stat-primary  .stat-icon { background: linear-gradient(135deg, var(--primary), #6f9eff); }
.stat-card.stat-success  .stat-icon { background: linear-gradient(135deg, var(--success), #4ade80); }
.stat-card.stat-warning  .stat-icon { background: linear-gradient(135deg, var(--warning), #fbbf24); }
.stat-card.stat-info     .stat-icon { background: linear-gradient(135deg, var(--info),    #67e8f9); }
.stat-card.stat-danger   .stat-icon { background: linear-gradient(135deg, var(--danger),  #fca5a5); }
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; margin-top: 4px; }

/* ----------- Auth (login + install) ----------- */
.layout-plain { min-height: 100vh; background: #0b1220; }
.auth-shell {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px;
}
.auth-card {
    width: 100%; max-width: 1000px;
    display: grid; grid-template-columns: 1fr 1fr;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(15,23,42,.35);
    overflow: hidden;
}
.auth-card-side {
    background: #0f172a;
    color: #fff;
    padding: 42px;
    display: flex; flex-direction: column; gap: 18px; justify-content: center;
}
.auth-brand h1 { font-size: 28px; margin: 16px 0 6px; font-weight: 700; }
.auth-brand p  { color: rgba(255,255,255,.85); margin: 0; }
.auth-features { list-style: none; padding: 0; margin: 0; }
.auth-features li { padding: 8px 0; color: #ecf2ff; }
.auth-features i  { margin-right: 8px; }
.auth-card-form {
    padding: 48px 40px;
    display: flex; flex-direction: column; justify-content: center;
}
.auth-card-form h2 { font-weight: 700; margin-bottom: 4px; }
.password-field { position: relative; }
.password-field .btn-toggle-pwd {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: 0; font-size: 16px;
    width: 38px; height: 38px; border-radius: 50%;
    color: var(--text-muted); z-index: 5;
    cursor: pointer;
}
.password-field .btn-toggle-pwd:hover { background: var(--bg); }
.auth-help { text-align: center; margin-top: 18px; color: var(--text-muted); }

@media (max-width: 768px) {
    .auth-card { grid-template-columns: 1fr; max-width: 480px; }
    .auth-card-side { display: none; }
}

.install-shell { background: #0b1220; }
.install-card {
    width: 100%; max-width: 560px;
    background: #fff; border-radius: 18px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
}
.install-header { text-align: center; margin-bottom: 20px; }
.install-header .brand-mark { margin: 0 auto 12px; }
.install-checks td { padding: 10px 0; border-color: var(--border); }

/* ----------- Reception ----------- */
.reception-card { border-top: 4px solid var(--primary); }
.reception-title { font-size: 18px; font-weight: 600; color: var(--primary-dark); margin-bottom: 18px; }
.dni-input-group input { font-size: 18px; letter-spacing: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.last-ticket-card { min-height: 280px; }
.ticket-status { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.ticket-preview-empty { padding: 30px 10px; }
.ticket-preview {
    margin-top: 14px;
    padding: 22px;
    background: #0f172a;
    color: #fff; border-radius: 14px;
    box-shadow: var(--shadow-md);
}

/* ============================================================
   Tema corporativo (sin degradados) + colores suaves
   ============================================================ */
.bg-success{
    background-color: hsl(167, 82%, 96%) !important;
    border: 1px solid hsl(168, 88%, 77%) !important;
    color: hsl(175, 61%, 19%) !important;
}
.bg-warning{
    background-color: hsl(358, 100%, 95%) !important;
    border: 1px solid hsl(357, 81%, 89%) !important;
    color: hsl(358, 100%, 45%) !important;
}
.bg-info{
    background-color: hsl(200, 86%, 95%) !important;
    border: 1px solid hsl(198, 100%, 73%) !important;
    color: hsl(201, 95%, 23%) !important;
}
/* Asegura legibilidad en badges con bg-* */
.badge.bg-success, .badge.bg-warning, .badge.bg-info { font-weight: 700; }
.ticket-preview .code { font-size: 64px; font-weight: 800; letter-spacing: 4px; }
.ticket-preview .name { font-size: 16px; opacity: .9; margin-top: 4px; }
.ticket-preview .service { display: inline-block; background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 999px; margin-top: 12px; font-size: 12px; letter-spacing: .04em; }

/* Quiosco táctil — recepción */
.reception-kiosk .service-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.reception-kiosk .service-tile {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 14px;
    text-align: left;
    background: var(--surface);
    transition: transform .12s, box-shadow .12s, border-color .12s;
    min-height: 88px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}
.reception-kiosk .service-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.reception-kiosk .service-tile.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,115,241,.2);
    background: var(--primary-soft);
}
.reception-kiosk .service-tile-name { font-weight: 600; font-size: 15px; color: var(--text); }
.reception-kiosk .service-tile-prefix { font-size: 12px; color: var(--text-muted); letter-spacing: .06em; }

.dni-keypad {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: flex-end; justify-content: center;
    padding: 16px;
    pointer-events: none;
}
.dni-keypad:not(.d-none) { pointer-events: auto; }
.dni-keypad-backdrop {
    position: absolute; inset: 0; background: rgba(15,23,42,.45);
    backdrop-filter: blur(2px);
}
.dni-keypad-panel {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px 16px 24px;
    box-shadow: var(--shadow-lg);
}
.dni-keypad-head { margin-bottom: 10px; }
.dni-keypad-display {
    font-family: ui-monospace, monospace;
    font-size: 32px;
    letter-spacing: 6px;
    text-align: center;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 12px;
    color: var(--text);
}
.dni-keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.dni-keypad-grid .btn {
    min-height: 52px;
    font-size: 20px;
    font-weight: 600;
}
.reception-kiosk-header .btn-lg { min-height: 48px; }

/* Recepción / quiosco: pantalla completa sin sidebar ni barra superior */
html:fullscreen body.page-reception-kiosk.layout-app {
    padding-left: 0 !important;
}
html:fullscreen body.page-reception-kiosk .sidebar,
html:fullscreen body.page-reception-kiosk .topbar {
    display: none !important;
}
html:fullscreen body.page-reception-kiosk .main-content {
    padding: 1rem 1.25rem;
    max-width: 100%;
}

/* ----------- Operator ----------- */
.operator-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}
.op-status { color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
.op-current {
    text-align: center;
    padding: 30px 10px;
    background: linear-gradient(135deg, #f1f5ff, #e9efff);
    border-radius: 14px;
    margin: 12px 0 22px;
}
.op-current .ticket-code-big {
    font-size: 92px; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #4d36e0);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    line-height: 1;
}
.op-current .client-name { font-size: 22px; margin-top: 8px; font-weight: 600; }
.op-current .meta { color: var(--text-muted); font-size: 14px; }
.op-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

/* ----------- Errores ----------- */
.error-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card {
    background: #fff; border-radius: 18px;
    padding: 38px; text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 540px; width: 100%;
}
.error-code {
    font-size: 72px; font-weight: 900;
    background: linear-gradient(135deg, #1f73f1, #4d36e0);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    line-height: 1;
    margin-bottom: 8px;
}

/* ----------- Botones / Inputs ----------- */
.btn { font-weight: 500; border-radius: 10px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border: 0; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,115,241,.15); }

/* ----------- Tablas ----------- */
.table { color: var(--text); }
.table > :not(caption) > * > * { border-color: var(--border); }
.table thead th { font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .04em; font-weight: 600; }

/* ----------- Responsive ----------- */
@media (max-width: 991.98px) {
    .layout-app { padding-left: 0; }
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
}

/* Scrollbars sutiles */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,.18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,.35); }
