/* FSF Pass Generator - Stylesheet */

:root {
    --red: #e60012;
    --red-dark: #cc0000;
    --bg: #f5f5f5;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --text-hint: #9ca3af;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --topbar-h: 54px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: block; }

/* ── Login ── */
.login-container {
    max-width: 360px;
    margin: 0 auto;
    padding: 60px 24px;
}
.login-header { text-align: center; margin-bottom: 40px; }
.login-logo {
    display: inline-block;
    background: var(--red);
    color: #fff;
    font-size: 28px;
    font-weight: 900;
    font-style: italic;
    padding: 10px 24px;
    border-radius: 8px;
    letter-spacing: 2px;
    margin-bottom: 16px;
}
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-header p { color: var(--text-muted); font-size: 14px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

input[type="text"], input[type="email"], input[type="tel"],
input[type="password"], input[type="search"], textarea, select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(230,0,18,0.1);
}
textarea { resize: vertical; }

.error-msg {
    background: #fef2f2;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--red); color: #fff; }
.btn-light { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-gray { background: #374151; color: #fff; }
.btn-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    padding: 6px;
}
.btn-crea-pass {
    padding: 16px;
    font-size: 16px;
    border-radius: var(--radius);
    margin-top: 8px;
}

/* ── Top Bar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--red);
    padding: 0 16px;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { color: #fff; font-size: 18px; font-weight: 800; letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}
.badge-year { background: rgba(255,255,255,0.2); color: #fff; }

/* ── Online / Sync Status ── */
.online-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}
.online-badge.online { background: rgba(255,255,255,0.25); color: #fff; }
.online-badge.offline { background: #fef3c7; color: #92400e; }

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.sync-dot.synced { background: #4ade80; }
.sync-dot.pending { background: #fbbf24; animation: pulse 1.5s infinite; }
.sync-dot.syncing { background: #60a5fa; animation: pulse 0.5s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Search Bar ── */
.search-bar {
    padding: 12px 16px 8px;
    display: flex;
    gap: 10px;
}
.search-input-wrap {
    flex: 1;
    position: relative;
}
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-hint);
}
.search-input-wrap input {
    padding-left: 38px;
    background: var(--surface);
}

/* ── Filter Bar ── */
.filter-bar {
    padding: 4px 16px 8px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-pill {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.filter-pill.active {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

/* ── Contact List ── */
.contact-list { padding: 0 16px 80px; }

.contact-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 4px solid #ccc;
    padding: 14px 14px 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.contact-card:hover { box-shadow: var(--shadow); }
.contact-card:active { transform: scale(0.99); }

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f3f4f6;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-hint);
    font-size: 14px;
}
.contact-avatar img { width: 100%; height: 100%; object-fit: cover; }

.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-name .arte { font-weight: 400; color: var(--text-muted); font-size: 13px; margin-left: 4px; }
.contact-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.access-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.contact-card .arrow {
    color: var(--border);
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-hint);
}
.empty-state svg { margin-bottom: 12px; }
.empty-state p { font-size: 15px; font-weight: 600; }

.list-count {
    font-size: 12px;
    color: var(--text-hint);
    font-weight: 600;
    padding: 4px 0 10px;
}

/* ── Pending Badge ── */
.pending-badge {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    color: #92400e;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 200;
}

/* ── Edit Screen ── */
#screen-edit .topbar { background: #fff; border-bottom: 1px solid var(--border); }
#screen-edit .btn-icon { color: var(--text); }
#screen-edit .btn-primary { background: var(--red); color: #fff; }

.edit-layout {
    display: flex;
    min-height: calc(100vh - var(--topbar-h));
}
.edit-form {
    flex: 1;
    padding: 20px;
    max-width: 500px;
}
.edit-preview {
	display: none;
//     flex: 0 0 320px;
//     padding: 20px;
//     background: #f3f4f6;
//     border-left: 1px solid var(--border);
//     display: flex;
//     flex-direction: column;
//     align-items: center;
// }
// .preview-label {
//     font-size: 11px;
//     font-weight: 700;
//     text-transform: uppercase;
//     letter-spacing: 1px;
//     color: var(--text-hint);
//     margin-bottom: 14px;
}

/* ── Photo Upload ── */
.photo-upload { text-align: center; margin-bottom: 20px; }
.photo-preview {
    width: 120px;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    margin: 0 auto;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    color: var(--text-hint);
    transition: all 0.15s;
    gap: 4px;
}
.photo-preview:hover { border-color: var(--red); }
.photo-preview span { font-size: 11px; font-weight: 600; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview.has-photo { border-style: solid; }

/* ── Level Grid ── */
.level-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.level-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid var(--border);
    background: #f3f4f6;
    color: var(--text-muted);
}
.level-btn.active { color: #fff; }

/* ── Access Grid ── */
.access-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
}
.access-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.15s;
}
.access-btn.active { background: rgba(var(--zone-rgb), 0.1); }
.access-btn .check {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.access-btn.active .check { background: var(--zone-color); }
.access-btn .zone-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.access-btn.active .zone-label { color: var(--text); }

.edit-actions-row {
    display: flex;
    justify-content: center;
    margin-top: 12px;
    padding-bottom: 40px;
}

/* ── Modal ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}
.modal-content {
    position: relative;
    background: #1a1a1a;
    border-radius: 16px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: toastIn 0.2s ease;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .edit-layout { flex-direction: column; }
    .edit-preview { display: none; } /* Nascondi preview su mobile, usa modal */
    .edit-form { max-width: 100%; }
    .form-row { flex-direction: column; gap: 0; }
    .access-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
    .contact-list { max-width: 700px; }
    .search-bar { max-width: 700px; }
    .filter-bar { max-width: 700px; }
}
/* ═══════════════════════════════════════
   ADMIN PANEL 
   ═══════════════════════════════════════ */

.admin-content { max-width: 600px; margin: 0 auto; padding: 20px; padding-bottom: 60px; }

.admin-section {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
}
.admin-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.admin-section-header h2 { font-size: 16px; font-weight: 700; }
.admin-section-info {
    background: #fef3c7; color: #92400e;
    font-size: 13px; font-weight: 700;
    padding: 4px 12px; border-radius: 20px;
}
.admin-section-info.limit-reached { background: #fef2f2; color: #b91c1c; }
.admin-section-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* ── Add Form (zone + livelli) ── */
.admin-add-form {
    display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap;
}
.admin-add-form input[type="text"] { flex: 1; min-width: 120px; padding: 8px 12px; font-size: 14px; }
.admin-add-form input[type="color"] {
    width: 40px; height: 38px; border: 2px solid var(--border);
    border-radius: 8px; padding: 2px; cursor: pointer; background: var(--surface);
}
.admin-add-form input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.admin-add-form input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

/* ── Zone List ── */
.admin-zones-list, .admin-levels-list { display: flex; flex-direction: column; gap: 6px; }

.admin-zone-item, .admin-level-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    border: 1.5px solid var(--border); background: var(--surface);
    transition: all 0.15s;
}
.admin-zone-item.inactive, .admin-level-item.inactive { opacity: 0.5; background: #f9fafb; }

.admin-zone-color-swatch {
    width: 28px; height: 28px; border-radius: 6px;
    flex-shrink: 0; border: 1px solid rgba(0,0,0,0.1);
}

.admin-zone-edit-color, .admin-level-edit-color {
    width: 28px; height: 28px; border: 2px solid var(--border);
    border-radius: 6px; padding: 1px; cursor: pointer;
    background: transparent; flex-shrink: 0;
}
.admin-zone-edit-color::-webkit-color-swatch-wrapper,
.admin-level-edit-color::-webkit-color-swatch-wrapper { padding: 1px; }
.admin-zone-edit-color::-webkit-color-swatch,
.admin-level-edit-color::-webkit-color-swatch { border: none; border-radius: 4px; }

.admin-zone-label, .admin-level-label { font-weight: 700; font-size: 14px; }
.admin-zone-code, .admin-level-code { font-size: 11px; color: var(--text-hint); font-family: monospace; }

/* ── Toggle Switch ── */
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #d1d5db; border-radius: 24px; transition: 0.2s;
}
.toggle-slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background-color: white;
    border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background-color: #22c55e; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── Small Icon Button ── */
.btn-icon-small {
    width: 28px; height: 28px; border: none; border-radius: 6px;
    background: #f3f4f6; color: var(--text-muted);
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; transition: all 0.15s; flex-shrink: 0;
}
.btn-icon-small:hover { background: #fef2f2; color: #b91c1c; }

/* ── Level Item Specifics ── */
.admin-level-colors { display: flex; gap: 4px; align-items: center; }
.admin-level-colors label { font-size: 10px; color: var(--text-hint); }

.admin-level-zones {
    display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
    padding-top: 8px; border-top: 1px solid var(--border);
}
.admin-level-zone-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 4px;
    font-size: 10px; font-weight: 700;
    cursor: pointer; transition: all 0.15s;
    border: 1.5px solid var(--border);
    background: #f3f4f6; color: var(--text-muted);
}
.admin-level-zone-chip.active {
    border-color: transparent;
}
.admin-level-zone-chip .chip-dot {
    width: 8px; height: 8px; border-radius: 50%;
}

/* ── Admin Screen Topbar ── */
#screen-admin .topbar { background: #1f2937; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .admin-add-form { flex-wrap: wrap; }
    .admin-add-form input[type="text"] { min-width: 0; }
    .admin-level-item { flex-wrap: wrap; }
}
.admin-users-list { display: flex; flex-direction: column; gap: 6px; }
.admin-user-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); }
.admin-user-item.inactive { opacity: 0.5; background: #f9fafb; }
.admin-user-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { font-weight: 700; font-size: 14px; }
.admin-user-username { font-size: 11px; color: var(--text-hint); font-family: monospace; }
.admin-user-role-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.admin-user-role-badge.admin { background: #fef2f2; color: #b91c1c; }
.admin-user-role-badge.staff { background: #eff6ff; color: #1d4ed8; }
.admin-user-actions { display: flex; gap: 4px; align-items: center; }
.btn-icon-small-reset { width: 28px; height: 28px; border: none; border-radius: 6px; background: #eff6ff; color: #1d4ed8; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn-icon-small-reset:hover { background: #dbeafe; }