/* ── Font Import ──────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700&family=Noto+Sans:wght@300;400;500;700&display=swap');

/* ── Design Tokens — Medical/Healthcare ──────────────── */
:root {
    --primary: #1565C0;
    --primary-light: #42A5F5;
    --primary-dark: #0D47A1;
    --primary-50: #E3F2FD;
    --primary-100: #BBDEFB;
    --accent: #00897B;
    --accent-light: #E0F2F1;
    --bg: #F4F7FA;
    --surface: #FFFFFF;
    --surface-alt: #F8FAFC;
    --text: #1E293B;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --sidebar-bg: #0D47A1;
    --sidebar-hover: #1565C0;
    --success: #2E7D32;
    --success-light: #E8F5E9;
    --danger: #C62828;
    --danger-light: #FFEBEE;
    --warning: #F57F17;
    --warning-light: #FFF8E1;
    --info: #0277BD;
    --info-light: #E1F5FE;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
    --transition: 200ms ease;
}


/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
body {
    font-family: 'Figtree', 'Noto Sans', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ── Layout principale ───────────────────────────────── */
.main {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-height: 100vh;
    background: var(--bg);
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    width: 100%;
}
.page-header h2, .page-header h3, .page-header h4 {
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-header h2 i, .page-header h3 i, .page-header h4 i {
    color: var(--primary);
    font-size: 1.3em;
}
.page-header .badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
}

/* ── Card  ───────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h4, .card-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-header h4 i, .card-header h5 i { color: var(--primary); }

.card-body { padding: 24px; }
.card-footer {
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    padding: 16px 24px;
}

/* ── Tabelle ─────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

th {
    background: var(--primary-dark);
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border: none !important;
    white-space: nowrap;
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

td {
    padding: 12px 16px;
    text-align: left;
    vertical-align: middle;
    border: none !important;
    border-bottom: 1px solid var(--border-light) !important;
    color: var(--text);
}

/* Righe alternate e hover — forza override su Bootstrap */
.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: transparent;
}
.table > tbody > tr {
    transition: background-color 0.2s ease !important;
}
.table > tbody > tr:nth-child(odd) > td,
.table > tbody > tr:nth-child(odd) > th {
    background-color: #FFFFFF !important;
}
.table > tbody > tr:nth-child(even) > td,
.table > tbody > tr:nth-child(even) > th {
    background-color: #EDF1F7 !important;
}
.table > tbody > tr:hover > td,
.table > tbody > tr:hover > th {
    background-color: #D4E5FA !important;
    cursor: pointer;
}

/* Table action links */
td a:not(.btn) {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.85rem;
    transition: color var(--transition);
}
td a:not(.btn):hover { color: var(--primary-dark); text-decoration: none; }

/* Table actions cell — icone orizzontali */
.table-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
}
.table-actions .btn {
    padding: 5px 8px;
    line-height: 1;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
}
.table-actions .btn i { font-size: 0.9rem; }
.table-actions .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
}
.table-actions .btn-outline-secondary:hover {
    background: var(--primary-50);
    color: var(--primary);
    border-color: var(--primary-light);
}
.table-actions .btn-outline-danger {
    color: var(--text-muted);
    border-color: var(--border);
}
.table-actions .btn-outline-danger:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}
.table-actions form { display: inline; }

/* ── Form ────────────────────────────────────────────── */
.form_row {
    display: flex;
    flex-direction: row;
    width: 100%;
    margin-bottom: 4px;
    gap: 16px;
}

.form_element {
    width: 100%;
    margin-bottom: 16px;
    padding: 0;
}

.form_element label, label.form-label {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
    display: block;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.form-control {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.92rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.10);
    outline: none;
}
.form-control::placeholder { color: var(--text-muted); }

.form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.10);
}

.values_container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    width: 100%;
}

/* ── Bottoni ─────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 9px 20px;
    transition: all var(--transition);
    cursor: pointer;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(13,71,161,0.25);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #B71C1C; }

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-outline-secondary:hover {
    background: var(--surface-alt);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-lg { padding: 12px 28px; font-size: 1rem; }

input[type="submit"] {
    margin-top: 20px;
    margin-bottom: 24px;
}

/* ── Checkbox / Radio personalizzate ──────────────────── */
.check-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.check-card:hover {
    border-color: var(--primary-light);
    background: var(--primary-50);
}
.check-card.active, .check-card:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-50);
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.12);
}
.check-card input[type="checkbox"],
.check-card input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.check-card label {
    margin: 0;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}

/* Griglia checkbox */
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.check-grid-2 { grid-template-columns: repeat(2, 1fr); }
.check-grid-3 { grid-template-columns: repeat(3, 1fr); }
.check-grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .check-grid, .check-grid-2, .check-grid-3, .check-grid-4 {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 480px) {
    .check-grid, .check-grid-2, .check-grid-3, .check-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Checkbox con campo espandibile */
.check-expandable {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.check-expandable .check-card {
    width: 100%;
}
.check-expandable .expand-field {
    padding-left: 42px;
}

/* Sezione label dentro card */
.section-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

/* ── Template container ──────────────────────────────── */
.template_container {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0;
    justify-content: start;
    align-items: stretch;
}

/* ── Appuntamenti / Calendario ───────────────────────── */
.appointment {
    background: var(--primary-50);
    margin: 4px 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    cursor: pointer;
    font-size: 0.82rem;
    transition: background var(--transition);
}
.appointment:hover { background: var(--primary-100); }
.appointment p { margin: 2px 0; line-height: 1.4; }
.appointment strong { font-weight: 600; color: var(--text-secondary); font-size: 0.78rem; }

.current-day { background-color: var(--warning-light) !important; }
.table-bordered>:not(caption)>*>* { max-width: 65px; }

/* ── Quick action cards (dashboard) ──────────────────── */
.quick-action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.quick-action-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text);
}
.quick-action-card .icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--primary);
    transition: background var(--transition);
}
.quick-action-card:hover .icon-circle {
    background: var(--primary);
    color: #fff;
}
.quick-action-card h6 {
    font-weight: 600;
    font-size: 0.88rem;
    margin: 0;
}

/* ── Stat cards ──────────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text-secondary); }

/* ── Alert / Feedback ────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
    padding: 12px 16px;
}
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); }
.alert-info { background: var(--info-light); color: var(--info); }

/* ── Pagine speciali ─────────────────────────────────── */
.login__main, .home__main, .loading__main, .success__main, .about__main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

.form__login, .form__file-upload {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.input_container { display: flex; flex-direction: column; margin-bottom: 1rem; }
input:not([type="submit"]):not(.form-control):not(.btn) { border: none; }

/* ── Prescrizione ────────────────────────────────────── */
.image-denti { padding-top: 2%; padding-bottom: 2%; }
.bold { font-weight: 700; }
#numero_dente { width: 100%; }

.dati_studio, .dati_paziente, .image-denti, .note,
.dispositivo_medico, .appuntamento, .registrazione_occlusale, .colore_dente {
    width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#form_prescrizione { display: flex; flex-direction: column; }

/* ── Errori ──────────────────────────────────────────── */
.error_message {
    color: var(--danger);
    font-size: 1rem;
    font-weight: 600;
    margin: 24px 0;
}

.page_content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* ── Loader ──────────────────────────────────────────── */
.lds-ring { display: inline-block; position: relative; width: 80px; height: 80px; }
.lds-ring div {
    box-sizing: border-box; display: block; position: absolute;
    width: 64px; height: 64px; margin: 8px;
    border: 8px solid var(--primary-light); border-radius: 50%;
    animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: var(--primary-light) transparent transparent transparent;
}
.lds-ring div:nth-child(1) { animation-delay: -0.45s; }
.lds-ring div:nth-child(2) { animation-delay: -0.3s; }
.lds-ring div:nth-child(3) { animation-delay: -0.15s; }
@keyframes lds-ring { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ── Utilita' ────────────────────────────────────────── */
.hover-rise { transition: transform var(--transition), box-shadow var(--transition); }
.hover-rise:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.hide_element { display: none; }
.text-muted { color: var(--text-muted) !important; }
.section-divider { border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; color: var(--border); }
.empty-state p { font-size: 0.95rem; margin-bottom: 16px; }

/* ── Mobile responsive ───────────────────────────────── */
input::placeholder, textarea::placeholder {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media screen and (max-width: 1199px) {
    .form_row { flex-direction: column; gap: 0; }
    .template_container { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start !important; gap: 8px; }
    .form-narrow, .form-medium, .form-wide { max-width: 100%; }

    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
    td { border: none !important; position: relative; padding: 10px 16px 10px 45%; text-align: right; }
    td:before { position: absolute; left: 16px; content: attr(data-label); font-weight: 600; color: var(--text-secondary); font-size: 0.82rem; text-align: left; }
}

@media screen and (max-width: 768px) {
    .quick-action-card { padding: 16px 12px; }
    .quick-action-card .icon-circle { width: 44px; height: 44px; font-size: 1.1rem; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 1.4rem; }
    .card-body { padding: 16px; }
    .login-card { margin: 16px; }
}

/* ── Focus states (Accessibility) ────────────────────── */
:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.3); }
