/* ==========================================================================
   Jornada — sistema de disseny
   Lleuger, modern, responsive. Sense dependències de build.
   ========================================================================== */

:root {
    /* Marca */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-200: #c7d2fe;
    --brand-400: #818cf8;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-800: #3730a3;

    --accent:   #06b6d4;
    --success:  #10b981;
    --success-bg: #ecfdf5;
    --warning:  #f59e0b;
    --warning-bg: #fffbeb;
    --danger:   #ef4444;
    --danger-bg: #fef2f2;

    /* Neutres */
    --bg:       #f6f7fb;
    --surface:  #ffffff;
    --surface-2:#f9fafb;
    --text:     #0f172a;
    --muted:    #64748b;
    --muted-2:  #94a3b8;
    --border:   #e7e9f0;
    --border-2: #eef0f5;

    --radius-sm: 8px;
    --radius:    14px;
    --radius-lg: 20px;

    --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
    --shadow:    0 4px 16px rgba(15,23,42,.06);
    --shadow-lg: 0 12px 40px rgba(15,23,42,.12);

    --sidebar-w: 264px;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* --- Botons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .62rem 1.05rem; border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; transition: all .15s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: .8rem 1.2rem; font-size: 1rem; }

/* --- Formularis ----------------------------------------------------------- */
.field { margin-bottom: 1.1rem; }
.label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: .4rem; }
.input {
    width: 100%; padding: .7rem .85rem; font-size: .95rem; font-family: inherit;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus {
    outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.checkbox-row { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); }

/* --- Targetes ------------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.4rem; }

/* --- Badges --------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .55rem; border-radius: 999px;
    font-size: .72rem; font-weight: 600; line-height: 1.4;
}
.badge-soon { background: var(--brand-50); color: var(--brand-700); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* --- Alertes -------------------------------------------------------------- */
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 1rem; }
.alert-danger { background: var(--danger-bg); color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: #047857; border: 1px solid #a7f3d0; }

/* ==========================================================================
   Login (panell partit)
   ========================================================================== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand {
    position: relative; overflow: hidden; color: #fff;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 55%, var(--accent) 130%);
    padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand::after {
    content: ""; position: absolute; right: -120px; top: -120px;
    width: 360px; height: 360px; border-radius: 50%;
    background: rgba(255,255,255,.08);
}
.auth-brand .logo { display: flex; align-items: center; gap: .6rem; font-weight: 750; font-size: 1.3rem; }
.auth-brand h1 { font-size: 2.1rem; line-height: 1.15; margin-bottom: 1rem; max-width: 16ch; }
.auth-brand p { color: rgba(255,255,255,.85); max-width: 38ch; }
.auth-points { list-style: none; padding: 0; margin: 1.6rem 0 0; display: grid; gap: .7rem; }
.auth-points li { display: flex; align-items: center; gap: .6rem; color: rgba(255,255,255,.92); font-size: .95rem; }
.auth-points .dot { width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.18);
    display: grid; place-items: center; flex: none; }

.auth-form-side { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .head { margin-bottom: 1.6rem; }
.auth-card .head h2 { font-size: 1.5rem; }
.auth-card .head p { color: var(--muted); margin: .35rem 0 0; }

/* ==========================================================================
   Shell de l'app (sidebar + topbar)
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
    display: flex; align-items: center; gap: .65rem; padding: 1.15rem 1.25rem;
    font-weight: 750; font-size: 1.15rem; border-bottom: 1px solid var(--border-2);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    background: linear-gradient(135deg, var(--brand-600), var(--accent));
    display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm);
}
.nav { padding: .9rem .75rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; flex: 1; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted-2); font-weight: 700; padding: .9rem .75rem .35rem; }
.nav-link {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem;
    border-radius: 10px; color: var(--muted); font-weight: 550; font-size: .92rem;
    transition: background .12s, color .12s;
}
.nav-link svg { width: 19px; height: 19px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand-50); color: var(--brand-700); font-weight: 650; }
.nav-link.disabled { color: var(--muted-2); cursor: default; }
.nav-link.disabled:hover { background: transparent; }
.nav-link .soon { margin-left: auto; }

.sidebar .foot { border-top: 1px solid var(--border-2); padding: .85rem; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.4rem; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 1.05rem; font-weight: 650; }
.topbar .spacer { flex: 1; }
.hamburger { display: none; background: none; border: 0; cursor: pointer; padding: .3rem; color: var(--muted); }

.content { padding: 1.8rem; max-width: 1240px; width: 100%; }

/* Avatar + dropdown (natiu, sense JS) */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: var(--brand-100); color: var(--brand-700);
    display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .55rem; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown[open] > summary ~ .dropdown-menu { display: block; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: calc(100% + .5rem);
    min-width: 190px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50;
}
.dropdown-menu a, .dropdown-menu button {
    display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
    padding: .55rem .65rem; border-radius: 8px; font-size: .9rem; color: var(--text);
    background: none; border: 0; cursor: pointer; font-family: inherit;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .sep { height: 1px; background: var(--border-2); margin: .3rem 0; }
.menu-label { padding: .4rem .65rem; font-size: .72rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }

/* --- Stats / graella ------------------------------------------------------ */
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.55rem; }
.page-head .sub { color: var(--muted); margin-top: .25rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.8rem; }
.stat { padding: 1.2rem 1.3rem; }
.stat .ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; margin-bottom: .9rem; }
.stat .ico svg { width: 21px; height: 21px; }
.ico-brand { background: var(--brand-50); color: var(--brand-600); }
.ico-success { background: var(--success-bg); color: var(--success); }
.ico-accent { background: #ecfeff; color: var(--accent); }
.ico-warning { background: var(--warning-bg); color: var(--warning); }
.stat .num { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; }
.stat .lbl { color: var(--muted); font-size: .88rem; margin-top: .15rem; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.module { padding: 1.3rem; display: flex; flex-direction: column; gap: .7rem; }
.module .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
    background: var(--brand-50); color: var(--brand-600); }
.module .ico svg { width: 20px; height: 20px; }
.module h3 { font-size: 1rem; }
.module p { color: var(--muted); font-size: .88rem; margin: 0; flex: 1; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 980px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 60; width: var(--sidebar-w);
        transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open::after {
        content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 55;
    }
    .hamburger { display: inline-flex; }
    .content { padding: 1.2rem; }
}

/* ==========================================================================
   CRUD: barra d'accions, taules, formularis
   ========================================================================== */
.page-head.with-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn-icon { padding: .45rem; }
.btn-icon svg { width: 17px; height: 17px; }

.toolbar { display: flex; gap: .7rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); font-weight: 700; padding: .85rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
table.data td { padding: .8rem 1rem; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); font-size: .85rem; }
.actions-cell { display: flex; gap: .4rem; justify-content: flex-end; }

.row-id { display: flex; align-items: center; gap: .7rem; }

.status-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.status-active { background: var(--success-bg); color: #047857; }
.status-active::before { background: var(--success); }
.status-inactive, .status-suspended { background: var(--surface-2); color: var(--muted); }
.status-inactive::before, .status-suspended::before { background: var(--muted-2); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .ico { width: 54px; height: 54px; border-radius: 14px; background: var(--brand-50); color: var(--brand-600);
    display: grid; place-items: center; margin: 0 auto 1rem; }
.empty .ico svg { width: 26px; height: 26px; }

.pagination-wrap { padding: 1rem; display: flex; justify-content: center; }
.pagination-wrap nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.pagination-wrap a, .pagination-wrap span { padding: .4rem .7rem; border-radius: 8px; font-size: .85rem; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.pagination-wrap a:hover { background: var(--surface-2); }
.pagination-wrap [aria-current] span { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

/* Formularis */
.form-card { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.form-grid .col-span { grid-column: 1 / -1; }
.form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2);
    font-weight: 700; margin: 1.4rem 0 .9rem; grid-column: 1 / -1; padding-top: 1rem; border-top: 1px solid var(--border-2); }
.form-section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
select.input, textarea.input { width: 100%; }
.help { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.form-actions { display: flex; gap: .7rem; margin-top: 1.6rem; padding-top: 1.3rem; border-top: 1px solid var(--border-2); }

.switch-row { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .55rem; }
.check-item { display: flex; align-items: center; gap: .55rem; padding: .6rem .75rem; border: 1px solid var(--border);
    border-radius: 10px; font-size: .9rem; cursor: pointer; }
.check-item:hover { background: var(--surface-2); }
.check-item input { margin: 0; }

.field-error { color: var(--danger); font-size: .8rem; margin-top: .3rem; }
.input.has-error { border-color: var(--danger); }

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

/* Barra d'impersonació (operador veient com una empresa) */
.impersonate-bar {
    display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap;
    background: var(--warning); color: #3a2a00; font-size: .85rem; font-weight: 600; padding: .5rem 1rem;
}
.impersonate-bar form { margin: 0; }
.impersonate-bar button {
    background: rgba(0,0,0,.18); color: inherit; border: 0; border-radius: 6px;
    padding: .3rem .7rem; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.impersonate-bar button:hover { background: rgba(0,0,0,.28); }

/* Demo (entorn de demostració) */
.demo-bar {
    display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap;
    background: #0E1012; color: #fff; font-size: .85rem; padding: .55rem 1rem;
    border-bottom: 2px solid #C2E812;
}
.demo-bar-tag {
    background: #C2E812; color: #0E1012; font-weight: 800; font-size: .7rem; letter-spacing: .08em;
    padding: .15rem .5rem; border-radius: 5px;
}
.demo-bar-text { font-weight: 500; }
.demo-bar-btn {
    background: #C2E812; color: #0E1012; border: 0; border-radius: 7px;
    padding: .35rem .85rem; font-size: .82rem; font-weight: 700; cursor: pointer;
}
.demo-bar-btn:hover { filter: brightness(1.06); }

/* Modal "Solicitar más información" */
.demo-modal {
    border: 0; border-radius: 14px; padding: 0; width: min(440px, 92vw);
    box-shadow: 0 24px 60px rgba(0,0,0,.35); color: var(--text, #1a1a1a);
}
.demo-modal::backdrop { background: rgba(8,10,12,.55); }
.demo-modal form { padding: 1.4rem 1.5rem 1.5rem; }
.demo-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .3rem; }
.demo-modal-head strong { font-size: 1.1rem; }
.demo-modal-x { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted, #888); }
.demo-modal-intro { color: var(--muted, #666); font-size: .88rem; margin: 0 0 1rem; }
.demo-field { display: block; margin-bottom: .85rem; }
.demo-field span { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .25rem; }
.demo-field input, .demo-field textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border, #d8dade); border-radius: 8px;
    font: inherit; box-sizing: border-box; background: #fff;
}
.demo-field textarea { resize: vertical; }
.demo-modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.1rem; }
.demo-btn-ghost { background: none; border: 1px solid var(--border, #d8dade); border-radius: 8px; padding: .5rem 1rem; font-weight: 600; cursor: pointer; }
.demo-btn-primary { background: #0E1012; color: #fff; border: 0; border-radius: 8px; padding: .5rem 1.2rem; font-weight: 700; cursor: pointer; }
.demo-btn-primary:hover { background: #000; }

/* Presència */
.presence-legend { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1.2rem; font-size: .85rem; color: var(--muted); }
.presence-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.dot.pstat-working { background: var(--success); } .dot.pstat-break { background: var(--warning); }
.dot.pstat-absence { background: var(--brand-500); } .dot.pstat-out { background: var(--muted-2); }
.presence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.presence-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--muted-2);
    border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); }
.presence-card .pc-name { font-weight: 650; }
.presence-card .pc-status { font-size: .85rem; font-weight: 600; margin-top: .1rem; }
.presence-card .pc-meta { color: var(--muted); font-size: .82rem; margin-top: .4rem; min-height: 1em; }
.presence-card.pstat-working { border-left-color: var(--success); } .presence-card.pstat-working .pc-status { color: #047857; }
.presence-card.pstat-break { border-left-color: var(--warning); } .presence-card.pstat-break .pc-status { color: #b45309; }
.presence-card.pstat-absence { border-left-color: var(--brand-500); } .presence-card.pstat-absence .pc-status { color: var(--brand-700); }
.presence-card.pstat-out { border-left-color: var(--muted-2); opacity: .75; } .presence-card.pstat-out .pc-status { color: var(--muted); }

/* Pestanyes (informes) */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.3rem; }
.tabs .tab { padding: .6rem .9rem; font-weight: 600; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }

/* Calendari de centres (informe per persona) */
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; margin-top: 1rem; }
.cal-day { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .65rem; }
.cal-day .cal-date { font-weight: 650; font-size: .85rem; }
.cal-day .cal-center { color: var(--muted); font-size: .78rem; margin-top: .2rem; }

