/* ============================================================
   myVote — Stili dei componenti
   ============================================================
   File separato dai "fondamentali" (styles.css) per chiarezza:
   qui ci sono SOLO le regole che riproducono i Composable
   personalizzati dell'app Android (PrimaryActionButton, SectionCard,
   DexSwitch, JurorColorPicker, ecc.).
   ============================================================ */

/* ---------- PrimaryActionButton ---------- */
.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-sm);
    padding: 16px 24px;
    width: 100%;
    min-height: 56px;
    font-size: 1.05rem;
    font-weight: 600;
    transition: filter .15s ease, transform .05s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- OutlinedButton ---------- */
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
    font-weight: 500;
    transition: background .15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-outline:hover:not(:disabled) {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.btn-outline:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-outline.danger {
    color: var(--danger);
    border-color: var(--danger);
}
.btn-outline.danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ---------- TextButton (inline action, no border) ---------- */
.btn-text {
    background: transparent;
    color: var(--primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
}
.btn-text:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.btn-text.danger { color: var(--danger); }

/* ---------- Floating Action Button (es. "Nuovo template") ---------- */
.fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: var(--primary);
    color: var(--on-primary);
    padding: 14px 22px;
    border-radius: 28px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
}
.fab:hover { filter: brightness(1.1); }

/* ---------- SectionCard ---------- */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.section-card.tappable {
    cursor: pointer;
    transition: background .15s ease;
}
.section-card.tappable:hover {
    background: var(--surface-2);
}

/* ---------- DexSwitch (toggle) ---------- */
.dex-switch {
    width: 52px;
    height: 30px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 20px;
    position: relative;
    flex-shrink: 0;
    transition: background .2s ease;
    cursor: pointer;
}
.dex-switch[aria-checked="true"] {
    background: var(--primary);
    border-color: var(--primary);
}
.dex-switch::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text);
    top: 3px;
    left: 3px;
    transition: transform .2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.dex-switch[aria-checked="true"]::after {
    transform: translateX(22px);
    background: var(--on-primary);
}

/* ---------- JurorColorPicker ---------- */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.color-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-width .15s ease, transform .1s ease;
}
.color-dot.selected {
    border-width: 3px;
    border-color: var(--text);
    transform: scale(1.05);
}
.color-dot.color-default {
    background: var(--surface);
    color: var(--text);
}

/* ---------- FilterChip ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.chip.selected {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    border-color: var(--primary);
    color: var(--primary);
}

/* ---------- IconButton (icona cliccabile a 40px) ---------- */
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: background .15s ease;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--danger); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* ---------- DragHandle (riordino liste) ---------- */
.drag-handle {
    cursor: grab;
    user-select: none;
    touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.draggable-row {
    transition: background .12s ease;
    background: var(--surface);
    border-radius: var(--radius-sm);
}
.draggable-row.dragging {
    background: var(--surface-3);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10;
}

/* ---- Classi gestite da SortableJS durante il drag ---- */
.sortable-ghost {
    /* Il "fantasma" che resta nella posizione di partenza: lo schiariamo
       per indicare visualmente che lì verrà depositata la riga.        */
    opacity: 0.45;
    background: var(--surface-2);
}
.sortable-chosen {
    /* La riga toccata (ma non ancora trascinata): leggera elevazione.   */
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.sortable-drag {
    /* Il "clone" che segue il dito: ombra forte + lift visibile.        */
    box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
    transform: scale(1.02);
    cursor: grabbing;
}

/* ---------- Lobby items / juror list ---------- */
.lobby-juror {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}
.lobby-juror .status-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.lobby-juror .status-icon.connected { background: var(--primary); color: var(--on-primary); }
.lobby-juror .status-icon.idle      { background: transparent; border: 2px solid var(--muted); color: var(--muted); }
.lobby-juror .status-icon.skipped   { background: var(--tertiary); color: var(--on-primary); }

/* ---------- QR code image holder ---------- */
.qr-holder {
    width: 260px;
    height: 260px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius-md);
    padding: 10px;
}
.qr-holder canvas {
    width: 100% !important;
    height: 100% !important;
    image-rendering: pixelated;
}

/* ---------- Approval buttons (votazione approval/percentage) ---------- */
.approval-buttons {
    width: 100%;
}
.approval-btn {
    /* Pulsante "outline" che diventa pieno solo se selezionato. Cosi` il
       giurato vede chiaramente la propria scelta prima di confermare /
       inviare. Stilisticamente coerente con btn-outline + btn-primary. */
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    text-align: center;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.approval-btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--primary);
}
.approval-btn.selected {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

/* ---------- Vote pill (riepilogo performance) ---------- */
.vote-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    color: white;
    font-weight: 700;
    min-width: 36px;
    text-align: center;
}

/* ---------- StatBlock (Riepilogo) ---------- */
.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 0;
}
.stat-block .value {
    color: var(--primary);
    font-size: 2rem;
    font-weight: 700;
}
.stat-block .label {
    color: var(--secondary);
    font-size: 0.85rem;
}

/* ---------- Logo home ---------- */
.home-logo svg {
    width: 96px;
    height: 96px;
    fill: var(--primary);
}

/* ---------- Toast errori standardizzato ---------- */
.toast.error {
    background: color-mix(in srgb, var(--danger) 18%, var(--surface));
    border-color: var(--danger);
    color: var(--danger);
    font-weight: 500;
}

/* ---------- Helpers per il QR scanner ---------- */
.scanner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.scanner-overlay video {
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-md);
    background: black;
}
.scanner-overlay .scanner-controls {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    width: 100%;
    max-width: 480px;
}
.scanner-overlay .scanner-status {
    color: white;
    margin-top: 12px;
    text-align: center;
}

/* ---------- Vote color preview palette (settings) ---------- */
.color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
