/* Quiz Scuola Guida - Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --success: #34a853;
    --danger: #ea4335;
    --warning: #fbbc04;
    --text: #202124;
    --text-secondary: #5f6368;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --border: #dadce0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    position: static !important;
    display: block !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
}

html {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
#header {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

#header #title {
    font-size: 1.1em;
    font-weight: 600;
}

#headerUser {
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 12px;
}

#headerUser button {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}

#headerUser button:hover {
    background: rgba(255,255,255,0.25);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #2d9249; }

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.1em;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.card { overflow-x: auto; }

.data-table th, .data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg);
}

.data-table tr:hover td {
    background: var(--primary-light);
}

.data-table th:last-child,
.data-table td:last-child {
    width: 1rem;
    white-space: nowrap;
}

.data-table tr.clickable { cursor: pointer; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78em;
    font-weight: 600;
}

.badge-success { background: #e6f4ea; color: var(--success); }
.badge-danger  { background: #fce8e6; color: var(--danger); }
.badge-warning { background: #fef7e0; color: #e37400; }
.badge-info    { background: var(--primary-light); color: var(--primary); }

/* Dialog overlay */
.dialog-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 0;
    z-index: 1000;
    -webkit-overflow-scrolling: touch;
}

.dialog {
    background: white;
    border-radius: var(--radius);
    padding: 28px;
    max-width: 480px;
    width: 90%;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    margin: auto 0;
}

.dialog-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 16px;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Toggle pill — iOS-style on/off switch.
   Usage: <label class="toggle-pill"><input type="checkbox"><span class="toggle-switch"></span> Label</label>
   The native <input> stays in the DOM so .checked, change events and form submission still work. */
.toggle-pill.toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 0.95em;
    color: var(--text-secondary);
}
.toggle-pill.toggle-pill > input[type="checkbox"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    margin: 0;
}
.toggle-pill.toggle-pill .toggle-switch {
    width: 38px;
    height: 22px;
    background: #c7cbd1;
    border-radius: 999px;
    position: relative;
    transition: background 0.18s;
    flex: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.toggle-pill.toggle-pill .toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.18s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-pill.toggle-pill > input[type="checkbox"]:checked + .toggle-switch {
    background: var(--success);
}
.toggle-pill.toggle-pill > input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(16px);
}
.toggle-pill.toggle-pill > input[type="checkbox"]:checked ~ .toggle-label {
    color: var(--text);
    font-weight: 500;
}
.toggle-pill.toggle-pill > input[type="checkbox"]:focus-visible + .toggle-switch {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.toggle-pill.toggle-pill > input[type="checkbox"]:disabled + .toggle-switch {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* Version footer */
.version-footer {
    text-align: center;
    padding: 16px;
    font-size: 0.75em;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 600px) {
    .card { padding: 16px; }
    #header { padding: 10px 16px; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 0.9em; }
}
