/* ===== Glassmorphism Theme ===== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    --primary: #4f8cff;
    --primary-dark: #3a6fd8;
    --primary-glow: rgba(79, 140, 255, 0.35);
    --danger: #ff5252;
    --success: #4caf50;
    --warning: #ffb74d;
    --bg-start: #0f0c29;
    --bg-mid: #302b63;
    --bg-end: #24243e;
    --card-bg: rgba(255, 255, 255, 0.06);
    --card-blur: blur(18px);
    --text: #ededf4;
    --text-light: rgba(255, 255, 255, 0.50);
    --border: rgba(255, 255, 255, 0.10);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    color-scheme: dark;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: 0.01em;
}

/* iOS fixed-background fallback */
@supports (-webkit-touch-callout: none) {
    body { background-attachment: scroll; }
    body::before {
        content: '';
        position: fixed;
        inset: 0;
        z-index: -1;
        background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ===== Header ===== */
header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 14px; font-size: 0.82rem; }
.header-right a {
    color: var(--text);
    text-decoration: none;
    opacity: 0.65;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: opacity 0.25s;
}
.header-right a:hover { opacity: 1; }
.header-right button {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 5px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.25s;
}
.header-right button:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
}

/* ===== Help button ===== */
.help-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
    border: 1px solid var(--border);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.25s;
}
.help-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text);
}

/* ===== How it works ===== */
.how-it-works {
    background: rgba(79, 140, 255, 0.06);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(79, 140, 255, 0.15);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px;
}
.how-it-works h3 {
    margin-bottom: 14px;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.how-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}
.how-step { display: flex; align-items: flex-start; gap: 12px; }
.how-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.how-step div strong {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}
.how-step p {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 2px;
    font-weight: 400;
    line-height: 1.5;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-align: center;
    transition: all 0.25s ease;
    gap: 6px;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 12px rgba(79, 140, 255, 0.2);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 4px 18px var(--primary-glow);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
}
.btn-danger {
    background: rgba(255, 82, 82, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 82, 82, 0.25);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(255, 82, 82, 0.28);
    border-color: rgba(255, 82, 82, 0.4);
}
.btn-small { padding: 5px 12px; font-size: 0.78rem; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text);
    color-scheme: dark;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.form-group input::placeholder, .form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 300;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: rgba(79, 140, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12);
    background: rgba(255, 255, 255, 0.07);
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    backdrop-filter: var(--card-blur);
    -webkit-backdrop-filter: var(--card-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
}

/* ===== Alerts ===== */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.84rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.alert-error {
    background: rgba(255, 82, 82, 0.10);
    color: #ff8a80;
    border-left: 3px solid var(--danger);
}
.alert-success {
    background: rgba(76, 175, 80, 0.10);
    color: #a5d6a7;
    border-left: 3px solid var(--success);
}
.alert-info {
    background: rgba(79, 140, 255, 0.10);
    color: #90caf9;
    border-left: 3px solid var(--primary);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.badge-pending {
    background: rgba(255, 183, 77, 0.12);
    color: var(--warning);
    border: 1px solid rgba(255, 183, 77, 0.25);
}
.badge-infrazione {
    background: rgba(255, 82, 82, 0.12);
    color: var(--danger);
    border: 1px solid rgba(255, 82, 82, 0.25);
}
.badge-scarto {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ===== Login page ===== */
.login-container {
    max-width: 380px;
    margin: 80px auto;
    padding: 0 16px;
}
.login-container h2 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 1.3rem;
    font-weight: 300;
    letter-spacing: 0.04em;
    color: var(--text);
}
.login-container .card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    padding: 28px;
}
.login-container .btn-primary { width: 100%; padding: 11px; font-size: 0.88rem; }

/* ===== Camera section ===== */
.camera-section { padding: 16px; }
.camera-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}
.camera-container video {
    width: 100%;
    max-height: 50vh;
    object-fit: cover;
    border-radius: var(--radius);
    background: #000;
}
.camera-container canvas { display: none; }

#camera-open {
    padding: 24px 16px;
    text-align: center;
}
#camera-open .btn {
    font-size: 0.9rem;
    padding: 12px 28px;
}

.capture-btn {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    background: rgba(79, 140, 255, 0.08);
    margin: 14px auto;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 0 20px rgba(79, 140, 255, 0.15);
}
.capture-btn:hover {
    background: rgba(79, 140, 255, 0.15);
    box-shadow: 0 0 28px rgba(79, 140, 255, 0.25);
}
.capture-btn:active {
    background: var(--primary);
    box-shadow: 0 0 32px var(--primary-glow);
    transform: scale(0.95);
}
.camera-close-btn {
    display: block;
    margin: 0 auto;
}

#preview-section img {
    width: 100%;
    max-width: 480px;
    display: block;
    margin: 0 auto;
    border-radius: var(--radius);
}

.upload-mode {
    display: flex;
    gap: 16px;
    margin: 12px 0;
    font-size: 0.84rem;
    color: var(--text);
}
.upload-mode label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.preview-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
}

/* ===== Photo list ===== */
.photo-list-section { padding: 16px; }

.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.filter-btn {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-light);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: all 0.25s;
}
.filter-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    color: var(--text);
}
.filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 10px rgba(79, 140, 255, 0.25);
}

.photo-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.photo-card {
    background: var(--card-bg);
    backdrop-filter: var(--card-blur);
    -webkit-backdrop-filter: var(--card-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.photo-card:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
}
.photo-card:active {
    transform: scale(1.01);
}
.photo-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}
.photo-info {
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.photo-time {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-light);
}
.photo-user {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-light);
}
.photo-notes {
    width: 100%;
    font-size: 0.82rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
    line-height: 1.5;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 48px 16px;
    font-size: 0.9rem;
    font-weight: 300;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}
.modal-content {
    background: rgba(25, 23, 55, 0.88);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-light);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
}
.modal-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.15);
}
.modal-content img {
    width: 100%;
    display: block;
    border-radius: var(--radius) var(--radius) 0 0;
}
.detail-info { padding: 18px 20px; }
.detail-info h3 {
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.detail-info p {
    margin-bottom: 6px;
    font-size: 0.84rem;
    font-weight: 400;
    color: var(--text-light);
}
.detail-info h4 {
    margin: 16px 0 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--danger);
}

/* ===== Admin page ===== */
.admin-container { padding: 20px; max-width: 1100px; margin: 0 auto; }
.admin-container h2 {
    margin-bottom: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.users-table th, .users-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text);
}
.users-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.03);
}
.users-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}
.status-active { color: var(--success); font-weight: 500; }
.status-inactive { color: var(--danger); font-weight: 500; }

.invite-form { display: flex; gap: 8px; margin-bottom: 24px; }
.invite-form input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--text);
    color-scheme: dark;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.invite-form input:focus {
    outline: none;
    border-color: rgba(79, 140, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12);
    background: rgba(255, 255, 255, 0.07);
}
.invite-form input::placeholder { color: rgba(255, 255, 255, 0.25); font-weight: 300; }

/* ===== Confirm reference banner ===== */
.confirm-reference {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 183, 77, 0.08);
    border: 1px solid rgba(255, 183, 77, 0.2);
    border-radius: var(--radius-sm);
    margin: 8px 16px;
}
.confirm-ref-img {
    width: 60px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.confirm-ref-info {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text);
}

/* ===== Confirm button on photo cards ===== */
.photo-card-actions {
    padding: 8px 14px 12px;
    border-top: 1px solid var(--border);
}
.btn-confirm-card { width: 100%; }
.btn-countdown {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-light);
    cursor: not-allowed;
    border: 1px solid var(--border);
}
.btn-countdown .countdown-text { font-variant-numeric: tabular-nums; }

/* ===== Toast ===== */
.toast {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 500;
    letter-spacing: 0.01em;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.toast-success { background: rgba(76, 175, 80, 0.85); }
.toast-error { background: rgba(255, 82, 82, 0.85); }
.toast-info { background: rgba(79, 140, 255, 0.85); }

/* ===== Footer ===== */
.legal-footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.8;
}
.legal-footer a {
    color: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    margin: 0 8px;
    transition: color 0.25s;
}
.legal-footer a:hover { color: var(--primary); text-decoration: none; }

/* ===== Desktop ===== */
@media (min-width: 768px) {
    .camera-section { display: none; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .photo-list-section { max-width: 1200px; margin: 0 auto; }
}
