/* =========================================================================
 * style.css — Design modern 2026 pentru aplicația de reuniune.
 * Paletă: alb / verde / scris negru. Curat, plat, spațios, responsive,
 * accesibil (focus vizibil, tap targets ≥44px, prefers-reduced-motion).
 * ========================================================================= */

:root {
    --green:       #16a34a;   /* verde principal */
    --green-dark:  #15803d;
    --green-700:   #166534;
    --green-light: #dcfce7;   /* fundal verde deschis */
    --green-50:    #f0fdf4;

    --ink:    #0f172a;        /* scris (negru-albăstrui) */
    --muted:  #64748b;        /* text secundar */
    --line:   #e6eaef;        /* borduri fine */
    --bg:     #f5f7f6;        /* fundal pagină */
    --card:   #ffffff;
    --danger: #dc2626;
    --warn-bg:#fef9c3;
    --warn-ink:#854d0e;

    --radius:    16px;
    --radius-sm: 10px;
    --shadow:    0 1px 2px rgba(2, 6, 23, .04), 0 10px 30px rgba(2, 6, 23, .06);
    --shadow-sm: 0 1px 3px rgba(2, 6, 23, .08);

    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Atributul HTML `hidden` are mereu prioritate (ascunde view-uri/pași/toast). */
[hidden] { display: none !important; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .9rem; margin: .25rem 0 1rem; }
a { color: var(--green-dark); }

/* ------------------------------- Butoane --------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 600; font-size: .95rem;
    min-height: 44px; padding: .6rem 1.15rem;
    border: 1px solid transparent; border-radius: 999px;
    cursor: pointer; transition: background .15s, box-shadow .15s, transform .04s, border-color .15s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--green-light); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--green); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--green-dark); }

.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--green-50); border-color: var(--green-light); }

/* ------------------------------- Layout ---------------------------------- */
.container { max-width: 920px; margin: 0 auto; padding: 1.1rem 1rem 3rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem 1.25rem;
    margin-bottom: 1.1rem;
}
.section-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: .6rem; flex-wrap: wrap; margin-bottom: .3rem;
}
.updated { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.badge-count { color: var(--muted); font-weight: 500; font-size: .9rem; }

/* ------------------------------- Topbar ---------------------------------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
    box-shadow: var(--shadow-sm);
}
.topbar-inner {
    max-width: 920px; margin: 0 auto; padding: .7rem 1rem;
    display: flex; justify-content: space-between; align-items: center; gap: .6rem;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { color: var(--green-dark); font-size: 1.1rem; }
.brand-sub-top { color: var(--muted); font-size: .72rem; }

/* ----------------------------- Meniu (tabs) ------------------------------ */
.menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    color: var(--ink); font-size: 1.25rem; cursor: pointer;
}
.mainmenu {
    display: none; flex-direction: column;
    max-width: 920px; margin: 0 auto; padding: .4rem .6rem .6rem;
    gap: .15rem;
}
.mainmenu.open { display: flex; }
.menu-item {
    background: transparent; border: none; color: var(--ink);
    font: inherit; font-weight: 600; cursor: pointer; text-align: left;
    padding: .7rem .9rem; border-radius: 10px;
}
.menu-item:hover { background: var(--green-50); }
.menu-item.is-active { background: var(--green-light); color: var(--green-700); }
.menu-logout { color: var(--muted); }

/* -------------------------------- Gate ----------------------------------- */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.gate-card { width: 100%; max-width: 400px; text-align: center; }
.gate-card h1 { color: var(--green-dark); }
.brand-sub { color: var(--muted); font-weight: 600; margin: .15rem 0 1rem; }
.gate-card label { display: block; text-align: left; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.gate-card input { width: 100%; margin-bottom: .6rem; }
.gate-card .btn { width: 100%; margin-top: .3rem; }

/* ------------------------------ Formulare -------------------------------- */
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="file"] {
    width: 100%; font: inherit; font-size: 1rem;
    padding: .7rem .85rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
input[type="file"] { padding: .5rem; }

.form-grid { display: grid; gap: .9rem; }
.form-row label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.field-error { color: var(--danger); font-size: .8rem; display: block; min-height: 1em; margin-top: .25rem; font-weight: 600; }
.enroll-status {
    background: var(--green-50); border: 1px solid var(--green-light); color: var(--green-700);
    border-radius: 10px; padding: .55rem .75rem; font-size: .85rem; font-weight: 600; margin: 0 0 1rem;
}

/* ------------------------------- Wizard ---------------------------------- */
.stepper { list-style: none; display: flex; gap: .5rem; margin: 0 0 1.1rem; padding: 0; }
.step-pill {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: .45rem;
    background: var(--card); border: 1px solid var(--line); border-radius: 999px;
    padding: .5rem .5rem; font-size: .8rem; font-weight: 600; color: var(--muted);
    cursor: pointer; text-align: center; transition: background .15s, border-color .15s, color .15s;
}
.step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
    background: #e2e8f0; color: #fff; font-size: .8rem; font-weight: 700;
}
.step-pill.is-current { border-color: var(--green); color: var(--green-700); background: var(--green-50); }
.step-pill.is-current .step-num { background: var(--green); }
.step-pill.is-done { color: var(--green-700); }
.step-pill.is-done .step-num { background: var(--green); }

.step-actions {
    display: flex; align-items: center; justify-content: space-between; gap: .8rem;
    margin-top: 1.2rem; flex-wrap: wrap;
}
.counter { font-weight: 700; color: var(--green-dark); }
.counter.is-full { color: var(--danger); }

/* Zilele alese (chips cu buton de renunțare) */
.chosen-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.chosen-title { font-weight: 600; font-size: .85rem; color: var(--muted); }
.chosen-chips { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.chosen-chips .muted { font-size: .82rem; margin: 0; }
.chosen-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--green); color: #fff; border-radius: 999px;
    padding: .25rem .35rem .25rem .75rem; font-size: .82rem; font-weight: 600;
}
.chip-remove {
    background: rgba(255, 255, 255, .25); color: #fff; border: none;
    width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
    font-size: 1.05rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.chip-remove:hover { background: rgba(255, 255, 255, .5); }

/* ------------------------------- Avatar ---------------------------------- */
.avatar {
    width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%;
    background: var(--green-light); color: var(--green-700);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; overflow: hidden; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 88px; height: 88px; font-size: 1.6rem; }

.photo-uploader { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.photo-controls { flex: 1; min-width: 220px; display: grid; gap: .6rem; }

/* ------------------------------- Roster ---------------------------------- */
.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.roster-item {
    display: flex; align-items: center; gap: .8rem;
    padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.roster-info { display: flex; flex-direction: column; }
.roster-name { font-weight: 600; }
.roster-sub { font-size: .8rem; color: var(--muted); }
.roster-contact { font-size: .8rem; color: var(--green-dark); text-decoration: none; word-break: break-all; }
.roster-contact:hover { text-decoration: underline; }
.roster-item { align-items: flex-start; }

/* ------------------------------- Admin ----------------------------------- */
.admin-card { border: 1px solid var(--line); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; background: #fff; box-shadow: var(--shadow-sm); }
.admin-card-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.admin-grid { display: grid; gap: .7rem; }
.admin-actions { display: flex; gap: .5rem; margin-top: .9rem; }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
@media (min-width: 768px) { .admin-grid { grid-template-columns: 1fr 1fr; } }

/* ---------------------------- Prezentare grid ---------------------------- */
.overview-grid { display: grid; gap: 1.1rem; }

/* ------------------------------ Calendar --------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7rem; }
.cal-title { font-weight: 700; text-transform: capitalize; font-size: 1.05rem; }
.cal-nav { min-height: 40px; min-width: 40px; padding: .3rem .8rem; font-size: 1.2rem; border-radius: 10px; }

/* minmax(0, 1fr) (NU doar 1fr): lasă coloanele să scadă sub lățimea conținutului,
   ca cele 7 zile să încapă mereu în ecran — altfel aspect-ratio + min-height pe
   celule forțează coloane prea late și calendarul iese din ecran pe mobil. */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
/* Pe mobil, cardul de calendar are padding lateral redus ca zilele să fie mai
   late (mai mult loc pentru număr + contoare). Restaurat la desktop mai jos. */
.cal-card { padding-left: .5rem; padding-right: .5rem; }
.cal-weekday { text-align: center; font-size: .72rem; color: var(--muted); padding: .2rem 0; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
/* Celulele: pătrate când e loc (desktop), dar cu o înălțime minimă pe mobil
   ca să încapă numărul + rândul de contoare fără înghesuială/suprapuneri. */
.cal-cell { aspect-ratio: 1 / 1; min-height: 3.1rem; }
.cal-empty { background: transparent; }

.cal-day {
    position: relative; border: 1px solid var(--line); border-radius: 12px;
    background: #fff; cursor: pointer; padding: 3px 2px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: .95rem; font-weight: 500; color: var(--ink);
    transition: box-shadow .12s, background .12s, transform .04s;
    /* Elimină întârzierea de ~300ms și zoom-ul la dublu-tap pe mobil. */
    touch-action: manipulation;
}
.cal-day:hover:not(.is-past) { box-shadow: 0 0 0 2px var(--green); }
.cal-day:active:not(.is-past) { transform: translateY(1px); }
.cal-day:focus-visible { outline: 3px solid var(--green-light); outline-offset: 1px; }
.cal-day.is-past { opacity: .35; cursor: not-allowed; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--green-light); }
.cal-num { pointer-events: none; line-height: 1; font-size: .9rem; }

/* Telefoane înguste: strânge spațiile ca să rămână 7 coloane lizibile. */
@media (max-width: 380px) {
    .cal-grid { gap: 2px; }
    .cal-cell { min-height: 2.8rem; }
    .cal-num { font-size: .82rem; }
    .cal-badge, .cal-ubadge { font-size: .56rem; min-width: 13px; padding: 0 3px; }
}

/* heatmap pe nuanțe de verde */
.cal-day.has-votes.s1 { background: #e3f7ea; }
.cal-day.has-votes.s3 { background: #86efac; }
.cal-day.has-votes.s5 { background: var(--green); color: #fff; }

.cal-day.is-selected {
    background: var(--green) !important; color: #fff;
    border-color: var(--green-dark); box-shadow: 0 0 0 2px var(--green-light);
}

/* Rândul de contoare de sub numărul zilei (nu se mai suprapune peste număr). */
.cal-meta {
    display: flex; align-items: center; justify-content: center;
    flex-wrap: wrap; gap: 3px; min-height: .95rem; pointer-events: none;
}
.cal-badge, .cal-ubadge {
    font-size: .62rem; font-weight: 700; line-height: 1.45;
    color: #fff; border-radius: 999px;
    min-width: 15px; text-align: center; padding: 0 4px;
}
.cal-badge { background: var(--green-dark); }   /* disponibili (verde) */
.cal-ubadge { background: #b91c1c; }            /* indisponibili (roșu) */

/* Contrast când fundalul celulei e deja colorat (pastila ar deveni invizibilă). */
.cal-day.has-votes.s5 .cal-badge,
.cal-day.is-selected .cal-badge { background: rgba(255, 255, 255, .32); color: #fff; }
.cal-day.is-unavailable .cal-ubadge { background: rgba(255, 255, 255, .32); color: #fff; }

/* ------------------------------- Legenda --------------------------------- */
.legend { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: 1rem; font-size: .78rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.swatch.s1 { background: #e3f7ea; }
.swatch.s3 { background: #86efac; }
.swatch.s5 { background: var(--green); }
.swatch.sel { background: var(--green-dark); }

/* Panoul „cine e disponibil în ziua apăsată" (sub calendarul de vot) */
.day-info { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.day-info h3 { font-size: 1rem; margin-bottom: .7rem; color: var(--green-dark); }

/* -------------------------------- Toast ---------------------------------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--ink); color: #fff; padding: .8rem 1.2rem; border-radius: 12px;
    box-shadow: var(--shadow); z-index: 60; max-width: 92vw; text-align: center;
    font-size: .92rem; font-weight: 500;
}
.toast-success { background: var(--green-dark); }
.toast-error { background: var(--danger); }

/* ------------------------------ Rezultate -------------------------------- */
.winner-box { background: var(--green-50); border: 1px solid var(--green-light); border-radius: 14px; padding: 1rem; margin: 0 0 1.2rem; }
.winner-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--green-700); font-weight: 700; margin-bottom: .45rem; }
.winner-chip { font-size: 1.15rem; font-weight: 700; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.date-block { border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem; background: #fff; }
.date-block.is-winner { border-color: var(--green); background: var(--green-50); }
.bar-row { display: grid; grid-template-columns: minmax(110px, 36%) 1fr auto; align-items: center; gap: .7rem; }
.bar-label { font-size: .9rem; font-weight: 600; }
.bar-track { background: #eef2f0; border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .5s ease; min-width: 3px; }
.bar-value { font-weight: 700; min-width: 1.6em; text-align: right; }
.date-block.is-winner .bar-fill { background: var(--green-dark); }

.voter-list { list-style: none; margin: .65rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.voter-chip { font-size: .78rem; background: var(--green-light); color: var(--green-700); border-radius: 999px; padding: .2rem .65rem; font-weight: 600; }

/* ---- Zile / persoane „NU pot participa" (roșu) ---- */
.cal-day.is-unavailable {
    background: #ef4444 !important; color: #fff;
    border-color: #b91c1c; box-shadow: 0 0 0 2px #fecaca;
}
/* Marcaj de stare în colțul zilei: ✓ disponibil / ✕ nu pot */
.cal-mark {
    position: absolute; top: 3px; left: 5px;
    font-size: .72rem; font-weight: 800; line-height: 1;
    color: #fff; pointer-events: none;
}

/* ---- Zile BLOCATE de admin (nimeni nu poate vota) ---- */
.cal-day.is-blocked {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
    background-image: repeating-linear-gradient(45deg,
        transparent 0, transparent 5px,
        rgba(148, 163, 184, .14) 5px, rgba(148, 163, 184, .14) 10px);
}
.cal-day.is-blocked .cal-num { color: #94a3b8; }
.cal-lock { font-size: .72rem; line-height: 1; }
/* În admin (mod blocare) zilele blocate rămân apăsabile, pentru deblocare. */
.cal-day.is-blocked:not(:disabled) { cursor: pointer; }
.cal-day.is-blocked:not(:disabled):hover { box-shadow: 0 0 0 2px #cbd5e1; }

.swatch.unavail { background: #ef4444; }
.chosen-chip.chip-no { background: var(--danger); }
.voter-chip.chip-no { background: #fee2e2; color: #b91c1c; }
.unavail-note { margin-top: .6rem; font-size: .8rem; font-weight: 700; color: #b91c1c; }
.list-divider {
    list-style: none; margin: .55rem 0 .25rem; font-size: .76rem; font-weight: 700;
    color: #b91c1c; text-transform: uppercase; letter-spacing: .03em;
}
.roster-item.is-unavailable-row { border-color: #fca5a5; background: #fef2f2; }

/* --------------------------- Desktop (≥768px) ---------------------------- */
@media (min-width: 768px) {
    h1 { font-size: 1.9rem; }
    .container { padding: 1.6rem 1rem 3rem; }

    /* meniul devine bară de tab-uri orizontală */
    .menu-toggle { display: none; }
    .mainmenu { display: flex !important; flex-direction: row; align-items: center; padding: .25rem .6rem .55rem; gap: .25rem; }
    .menu-item { text-align: center; }
    .menu-logout { margin-left: auto; }

    /* roster pe două coloane */
    .roster { grid-template-columns: 1fr 1fr; }
    /* prezentare: calendar + panou alături */
    .overview-grid { grid-template-columns: 1.3fr 1fr; align-items: start; }
    #day-panel { grid-template-columns: 1fr; }

    .step-pill { font-size: .9rem; padding: .6rem .7rem; }

    /* Pe desktop e loc destul: spațiere mai aerisită între zile, font mai mare
       și padding normal al cardului de calendar (anulează strângerea de pe mobil). */
    .cal-grid { gap: 6px; }
    .cal-num { font-size: 1rem; }
    .cal-card { padding-left: 1.25rem; padding-right: 1.25rem; }
}

/* ------------------------- Reducerea mișcării ---------------------------- */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
