/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --gold: #D4AF37;
    --gold-dim: rgba(212,175,55,.12);
    --bg: #080809;
    --surface: #111113;
    --surface2: #18181b;
    --border: rgba(255,255,255,.07);
    --text: #f0f0f0;
    --muted: #666;
    --green: #22c55e;
    --amber: #f59e0b;
    --blue: #3b82f6;
    --red: #ef4444;
    --font: 'Inter', system-ui, sans-serif;
    --radius: 14px;
    --sidebar-w: 220px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; }

/* ===== LOGIN SCREEN ===== */
#login-screen {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.login-box {
    width: 100%; max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
}

.login-box h2 { font-size: 1.4rem; margin-bottom: .3rem; }
.login-box .sub { color: var(--muted); font-size: .88rem; margin-bottom: 2rem; }

/* ===== BRAND ===== */
.brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: .05em;
    margin-bottom: 1.5rem;
    color: var(--text);
}
.brand span { color: var(--gold); }

/* ===== FORM FIELDS ===== */
.field { margin-bottom: 1.2rem; }
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .sel-dark {
    width: 100%;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    padding: .8rem 1rem;
    color: var(--text);
    font-size: .92rem;
    font-family: var(--font);
    transition: border-color .2s;
}
.field input:focus, .field select:focus, .sel-dark:focus { outline: none; border-color: var(--gold); }
.field input::placeholder { color: var(--muted); }
.err-msg { color: var(--red); font-size: .83rem; margin-bottom: .8rem; min-height: 1rem; }

/* Login button */
#login-btn {
    width: 100%;
    background: linear-gradient(135deg, #D4AF37, #b8952a);
    color: #000; border: none; border-radius: 12px;
    padding: 1rem; font-weight: 700; font-size: .95rem;
    cursor: pointer; transition: opacity .2s, transform .2s;
}
#login-btn:hover { opacity: .9; transform: translateY(-1px); }
#login-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== APP LAYOUT ===== */
#app { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform .3s ease, width .3s ease;
    overflow: hidden;
}

.sidebar-brand {
    padding: 1.4rem 1.2rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar nav { flex: 1; padding: .8rem 0; overflow-y: auto; }

.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1.2rem;
    color: var(--muted);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    border-right: 3px solid transparent;
    transition: all .2s;
    white-space: nowrap;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--gold); background: var(--gold-dim); border-right-color: var(--gold); }

.sidebar-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: .5rem;
    overflow: hidden;
}
.user-email { font-size: .72rem; color: var(--muted); word-break: break-all; white-space: normal; }

#logout-btn {
    background: none; border: 1px solid rgba(255,255,255,.08);
    color: var(--muted); padding: .5rem; border-radius: 8px;
    cursor: pointer; font-size: .82rem; transition: all .2s;
    white-space: nowrap;
}
#logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ===== MOBILE SIDEBAR OVERLAY ===== */
#sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 150;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(2px);
}

/* ===== TOP MOBILE BAR ===== */
.mobile-topbar {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .9rem 1.2rem;
    align-items: center;
    gap: 1rem;
}
#menu-toggle {
    background: none; border: none; color: var(--text);
    cursor: pointer; padding: .2rem; line-height: 0;
    flex-shrink: 0;
}
.mobile-brand { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 1rem; }
.mobile-brand span { color: var(--gold); }

/* ===== MAIN ===== */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 1.8rem 2rem;
    min-height: 100vh;
    transition: margin-left .3s ease;
}

/* ===== TOP BAR ===== */
.top-bar {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.8rem; padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem; flex-wrap: wrap;
}
.top-bar h1 { font-family: 'Outfit', sans-serif; font-size: 1.6rem; font-weight: 800; }
.page-sub { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

.top-bar-right { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.toggle-pill {
    display: flex; align-items: center; gap: .6rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: .5rem .9rem; border-radius: 50px;
    font-size: .8rem; color: var(--muted);
}
.link-back { color: var(--muted); text-decoration: none; font-size: .82rem; }
.link-back:hover { color: var(--text); }

/* ===== SECTIONS ===== */
.sec { display: none; }
.sec.active { display: block; }

/* ===== KPI ROW ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
    display: flex; align-items: center; gap: .9rem;
    transition: border-color .2s;
}
.kpi-card:hover { border-color: rgba(212,175,55,.3); }

.kpi-icon {
    width: 44px; height: 44px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.kpi-icon.gold  { background: rgba(212,175,55,.12); }
.kpi-icon.amber { background: rgba(245,158,11,.12); }
.kpi-icon.green { background: rgba(34,197,94,.12); }
.kpi-icon.blue  { background: rgba(59,130,246,.12); }

.kpi-label { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; font-weight: 500; }
.kpi-val { font-size: 1.8rem; font-weight: 800; font-family: 'Outfit', sans-serif; line-height: 1; }

/* ===== CARD ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    margin-bottom: 1.4rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.1rem; flex-wrap: wrap; gap: .6rem; }
.card-head h2 { font-size: 1rem; font-weight: 700; }

/* ===== TABLE ===== */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th { text-align: left; padding: .65rem .9rem; color: var(--muted); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .85rem .9rem; border-bottom: 1px solid rgba(255,255,255,.03); font-size: .85rem; vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.015); }
.empty-td { text-align: center; color: var(--muted); padding: 2.5rem; font-size: .88rem; }

/* ===== BADGES ===== */
.badge {
    padding: .18rem .6rem; border-radius: 20px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge.pending  { background: rgba(245,158,11,.12); color: var(--amber); }
.badge.approved { background: rgba(34,197,94,.12);  color: var(--green); }
.badge.rejected { background: rgba(239,68,68,.12);  color: var(--red); }
.badge.completed{ background: rgba(59,130,246,.12); color: var(--blue); }

/* ===== ACTION BUTTONS ===== */
.act-btn {
    padding: .22rem .55rem; border-radius: 6px; font-size: .73rem; font-weight: 600;
    cursor: pointer; border: 1px solid; background: none; transition: all .2s;
    margin-right: 3px;
}
.act-btn.approve { border-color: var(--green); color: var(--green); }
.act-btn.approve:hover { background: rgba(34,197,94,.12); }
.act-btn.reject  { border-color: var(--red); color: var(--red); }
.act-btn.reject:hover  { background: rgba(239,68,68,.12); }
.act-btn.edit    { border-color: var(--gold); color: var(--gold); }
.act-btn.edit:hover    { background: var(--gold-dim); }
.act-btn.deact   { border-color: var(--muted); color: var(--muted); }
.act-btn.deact:hover   { border-color: var(--red); color: var(--red); }

/* ===== BUTTONS ===== */
.btn-gold {
    background: linear-gradient(135deg,#D4AF37,#b8952a);
    color: #000; border: none; padding: .6rem 1.2rem;
    border-radius: 10px; font-weight: 700; font-size: .83rem;
    cursor: pointer; transition: opacity .2s, transform .2s;
    white-space: nowrap;
}
.btn-gold:hover { opacity: .9; transform: translateY(-1px); }
.btn-ghost {
    background: none; border: 1px solid var(--border);
    color: var(--muted); padding: .6rem 1.2rem;
    border-radius: 10px; font-size: .83rem; cursor: pointer; transition: all .2s;
}
.btn-ghost:hover { border-color: rgba(255,255,255,.2); color: var(--text); }

/* ===== FILTERS ===== */
.filters { display: flex; gap: .35rem; flex-wrap: wrap; }
.f-btn {
    background: none; border: 1px solid var(--border); color: var(--muted);
    padding: .32rem .75rem; border-radius: 8px; font-size: .76rem; cursor: pointer; transition: all .2s;
}
.f-btn.active, .f-btn:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

/* ===== CALENDAR ===== */
.cal-nav { display: flex; align-items: center; gap: .8rem; }
.cal-btn {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); width: 32px; height: 32px; border-radius: 8px;
    cursor: pointer; font-size: .9rem; transition: all .2s;
}
.cal-btn:hover { border-color: var(--gold); color: var(--gold); }

.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; margin-top: .8rem; }
.cal-hdr { text-align: center; padding: .45rem; font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.cal-cell {
    min-height: 70px; border: 1px solid rgba(255,255,255,.05);
    border-radius: 9px; padding: .4rem .45rem; cursor: pointer;
    transition: all .2s; position: relative; background: rgba(255,255,255,.01);
}
.cal-cell:hover { border-color: rgba(212,175,55,.3); background: var(--gold-dim); }
.cal-cell.today { border-color: var(--gold); }
.cal-cell.other { opacity: .2; cursor: default; }
.cal-cell.has-appt { border-color: rgba(212,175,55,.35); }
.cal-num { font-size: .78rem; font-weight: 600; color: var(--text); margin-bottom: .25rem; }
.cal-cell.today .cal-num { color: var(--gold); }
.cal-ev { font-size: .6rem; background: var(--gold-dim); color: var(--gold); border-radius: 4px; padding: 1px 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cal-detail { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: 1.1rem; }
.cal-detail h3 { margin-bottom: .8rem; font-size: .92rem; color: var(--gold); }
.cal-det-row { display: flex; align-items: center; gap: .9rem; padding: .65rem 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: .85rem; flex-wrap: wrap; }

/* ===== BARBERS GRID ===== */
.barbers-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: .9rem; margin-top: .5rem; }
.barber-card {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.2rem; text-align: center;
    transition: all .2s; position: relative;
}
.barber-card:hover { border-color: rgba(212,175,55,.3); transform: translateY(-2px); }
.b-dot { position: absolute; top: .8rem; right: .8rem; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.b-dot.off { background: var(--muted); }
.b-avatar { width: 50px; height: 50px; border-radius: 50%; background: linear-gradient(135deg,#D4AF37,#7a5c0f); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 700; color: #000; margin: 0 auto .8rem; }
.b-name { font-weight: 700; font-size: .92rem; margin-bottom: .2rem; }
.b-spec { font-size: .75rem; color: var(--muted); margin-bottom: .8rem; }
.b-actions { display: flex; gap: .35rem; justify-content: center; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .7rem; margin-top: 1rem; flex-wrap: wrap; }

/* ===== AVAILABILITY ===== */
.avail-week { display: grid; grid-template-columns: repeat(7,1fr); gap: .6rem; margin-top: .8rem; }
.avail-col { background: var(--surface2); border: 1px solid var(--border); border-radius: 11px; padding: .8rem .6rem; }
.avail-day-name { font-size: .68rem; font-weight: 700; color: var(--gold); text-align: center; text-transform: uppercase; margin-bottom: .5rem; }
.avail-slot { background: var(--gold-dim); border: 1px solid rgba(212,175,55,.2); border-radius: 7px; padding: .35rem .45rem; margin-bottom: .35rem; font-size: .68rem; text-align: center; position: relative; }
.avail-del { position: absolute; top: 1px; right: 3px; background: none; border: none; color: var(--red); cursor: pointer; font-size: .65rem; padding: 0; line-height: 1; }
.avail-empty { color: var(--muted); font-size: .72rem; text-align: center; padding: .3rem 0; }

.avail-form-inline { display: flex; gap: .9rem; align-items: flex-end; flex-wrap: wrap; }
.avail-form-inline .field { margin: 0; flex: 1; min-width: 120px; }

/* ===== TOGGLE ===== */
.toggle { position: relative; display: inline-block; width: 42px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.knob {
    position: absolute; cursor: pointer; inset: 0;
    background: #333; border-radius: 34px; transition: .3s;
}
.knob:before {
    content: ""; position: absolute;
    height: 16px; width: 16px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: .3s;
}
.toggle input:checked + .knob { background: var(--gold); }
.toggle input:checked + .knob:before { transform: translateX(20px); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: .9rem 0; border-bottom: 1px solid var(--border); margin-bottom: .5rem; gap: 1rem; }

/* ===== API SECTION ===== */
.api-row { display: flex; align-items: center; gap: .7rem; background: #0d0d0e; border: 1px solid rgba(255,255,255,.08); border-radius: 9px; padding: .65rem .9rem; margin-top: .4rem; flex-wrap: wrap; }
.api-row code { font-family: monospace; color: var(--gold); font-size: .85rem; flex: 1; word-break: break-all; }
.btn-copy { background: var(--gold-dim); border: 1px solid rgba(212,175,55,.3); color: var(--gold); padding: .28rem .65rem; border-radius: 6px; cursor: pointer; font-size: .75rem; white-space: nowrap; }
.btn-copy:hover { background: rgba(212,175,55,.2); }
.ep { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: .8rem; flex-wrap: wrap; }
.m { font-size: .65rem; font-weight: 700; padding: .14rem .42rem; border-radius: 4px; min-width: 44px; text-align: center; }
.m.get   { background: rgba(59,130,246,.12); color: var(--blue); }
.m.post  { background: rgba(34,197,94,.12);  color: var(--green); }
.m.patch { background: rgba(245,158,11,.12); color: var(--amber); }
.ep code { color: #ccc; word-break: break-all; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ===== RESPONSIVE — TABLET (max 1024px) ===== */
@media (max-width: 1024px) {
    :root { --sidebar-w: 200px; }
    .kpi-row { grid-template-columns: repeat(2,1fr); }
    .main { padding: 1.4rem 1.4rem; }
    #sec-ajustes > div { grid-template-columns: 1fr !important; }
    .avail-week { grid-template-columns: repeat(4,1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .cal-cell { min-height: 58px; }
    .kpi-val { font-size: 1.5rem; }
}

/* ===== RESPONSIVE — TABLET PORTRAIT & MOBILE (max 768px) ===== */
@media (max-width: 768px) {
    /* Show mobile topbar */
    .mobile-topbar { display: flex; }

    /* Sidebar becomes a drawer */
    .sidebar {
        transform: translateX(-100%);
        width: 240px !important;
        box-shadow: 4px 0 20px rgba(0,0,0,.5);
    }
    .sidebar.open { transform: translateX(0); }
    #sidebar-overlay.show { display: block; }

    /* Main takes full width */
    .main { margin-left: 0; padding: 5rem 1rem 1.5rem; }

    /* KPIs 2x2 */
    .kpi-row { grid-template-columns: repeat(2,1fr); gap: .8rem; }
    .kpi-card { padding: 1rem; gap: .7rem; }
    .kpi-val { font-size: 1.4rem; }
    .kpi-icon { width: 38px; height: 38px; font-size: 1rem; }

    /* Top bar stacks */
    .top-bar { flex-direction: column; gap: .8rem; margin-bottom: 1.2rem; }
    .top-bar-right { width: 100%; justify-content: space-between; }
    .top-bar h1 { font-size: 1.3rem; }

    /* Cards */
    .card { padding: 1.1rem; }
    .card-head { flex-direction: column; align-items: flex-start; }

    /* Calendar compact */
    .cal-hdr { font-size: .6rem; padding: .3rem .1rem; }
    .cal-cell { min-height: 44px; padding: .25rem .2rem; }
    .cal-ev { display: none; }
    .cal-num { font-size: .72rem; }

    /* Barbers */
    .barbers-grid { grid-template-columns: repeat(2,1fr); }
    .form-grid { grid-template-columns: 1fr; }

    /* Availability week — 2 per row on mobile */
    .avail-week { grid-template-columns: repeat(2,1fr); }

    /* Availability form stacked */
    .avail-form-inline { flex-direction: column; }
    .avail-form-inline .field { width: 100%; }

    /* Table scroll hint */
    .tbl-wrap::before {
        content: '← desliza →';
        display: block;
        text-align: center;
        color: var(--muted);
        font-size: .7rem;
        padding: .2rem 0 .5rem;
    }

    /* Form actions stacked */
    .form-actions { flex-direction: column; }
    .form-actions .btn-gold, .form-actions .btn-ghost { width: 100%; text-align: center; }

    /* Filters wrap */
    .filters { gap: .3rem; }
    .f-btn { font-size: .72rem; padding: .28rem .6rem; }

    /* Settings grid */
    #sec-ajustes > div { grid-template-columns: 1fr !important; }
}

/* ===== RESPONSIVE — SMALL MOBILE (max 480px) ===== */
@media (max-width: 480px) {
    .kpi-row { grid-template-columns: repeat(2,1fr); gap: .6rem; }
    .kpi-val { font-size: 1.25rem; }
    .kpi-label { font-size: .68rem; }
    .barbers-grid { grid-template-columns: 1fr; }
    .avail-week { grid-template-columns: repeat(2,1fr); }
    .cal-grid { gap: 2px; }
}
