/* 
 * Registro Comunicatori Digitali - Conforme alle linee guida AGID
 * Implementa il Design System .italia per la Pubblica Amministrazione
 */

/* Import font ufficiali AGID - Titillium Web e fallback */
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap');

/* Font preloading gestito tramite link rel="preload" nel HTML per prestazioni ottimali */

/* Design Tokens Italia - Variabili CSS conformi alle linee guida AGID */
:root[data-theme="light"], :root {
    /* Colori primari - Blu Italia */
    --primary-color: #0066CC;
    --primary-dark: #004D99;
    --primary-light: #3385D6;
    --primary-lighter: #66A3E0;
    --primary-lightest: #CCE0F5;
    
    /* Colori secondari conforme palette AGID */
    --secondary-color: #5A768A;
    --success-color: #008758;
    --warning-color: #A66F00;
    --danger-color: #D1344C;
    --info-color: #17A2B8;
    
    /* Grigi light mode */
    --gray-100: #F5F5F5;
    --gray-200: #E6E6E6;
    --gray-300: #CCCCCC;
    --gray-400: #B3B3B3;
    --gray-500: #808080;
    --gray-600: #666666;
    --gray-700: #4D4D4D;
    --gray-800: #333333;
    --gray-900: #1A1A1A;
    
    /* Semantic colors light mode */
    --background-color: #FFFFFF;
    --surface-color: #FFFFFF;
    --surface-secondary: #F5F5F5;
    --text-color: #1A1A1A;
    --text-secondary: #4D4D4D;
    --text-muted: #666666;
    --border-color: #E6E6E6;
    --border-light: #CCCCCC;
    
    --light-color: var(--gray-100);
    --dark-color: var(--gray-900);
}

/* Dark Theme - Palette AGID conforme WCAG 2.0 */
:root[data-theme="dark"] {
    /* Colori primari adattati per dark mode - Contrasto migliorato */
    --primary-color: #7BB3F0;
    --primary-dark: #5A9BE8;
    --primary-light: #9CC8F3;
    --primary-lighter: #CCE0F5;
    --primary-lightest: #E5F1FA;
    
    /* Colori secondari dark mode - Contrasto WCAG 2.0 */
    --secondary-color: #8FA5B2;
    --success-color: #66BB6A;
    --warning-color: #FFB74D;
    --danger-color: #EF5350;
    --info-color: #42A5F5;
    
    /* Grigi dark mode - Ottimizzati per contrasto WCAG */
    --gray-100: #1A1A1A;
    --gray-200: #2D2D2D;
    --gray-300: #404040;
    --gray-400: #595959;
    --gray-500: #737373;
    --gray-600: #A6A6A6;
    --gray-700: #D9D9D9;
    --gray-800: #EEEEEE;
    --gray-900: #FFFFFF;
    
    /* Semantic colors dark mode - Contrasto WCAG 2.0 AA */
    --background-color: #0D1117;
    --surface-color: #161B22;
    --surface-secondary: #21262D;
    --text-color: #F0F6FC;
    --text-secondary: #E6EDF3;
    --text-muted: #B1BAC4;
    --border-color: #30363D;
    --border-light: #484F58;
    
    --light-color: var(--gray-900);
    --dark-color: var(--gray-100);
}

/* Variabili globali per entrambi i temi */
:root {
    /* Tipografia uniforme - Solo Titillium Web AGID */
    --font-family-sans-serif: 'Titillium Web', sans-serif;
    --font-family-serif: 'Titillium Web', sans-serif;
    --font-family-monospace: 'Titillium Web', monospace;
    
    /* Spaziature e dimensioni */
    --border-radius: 4px;
    --border-radius-lg: 8px;
    --border-radius-sm: 2px;
    
    /* Ombre */
    --box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --box-shadow-lg: 0 8px 16px 0 rgba(0, 0, 0, 0.15);
    --box-shadow-xl: 0 16px 32px 0 rgba(0, 0, 0, 0.2);
    
    /* Transizioni */
    --transition-fast: all 0.15s ease-in-out;
    --transition-base: all 0.2s ease-in-out;
    --transition-slow: all 0.3s ease-in-out;
    
    /* Focus ring per accessibilità WCAG */
    --focus-ring: 0 0 0 3px rgba(0, 102, 204, 0.25);
    --focus-ring-danger: 0 0 0 3px rgba(209, 52, 76, 0.25);
    --focus-ring-success: 0 0 0 3px rgba(0, 135, 88, 0.25);
}

/* Focus ring dark mode con contrasti WCAG */
:root[data-theme="dark"] {
    --focus-ring: 0 0 0 3px rgba(123, 179, 240, 0.4);
    --focus-ring-danger: 0 0 0 3px rgba(239, 83, 80, 0.4);
    --focus-ring-success: 0 0 0 3px rgba(102, 187, 106, 0.4);
}

/* Reset e base styles conformi AGID */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Base font size AGID */
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Tipografia conforme linee guida AGID */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-sans-serif);
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
}

h3 {
    font-size: 1.75rem;
    font-weight: 600;
}

h4 {
    font-size: 1.5rem;
    font-weight: 600;
}

h5 {
    font-size: 1.25rem;
    font-weight: 600;
}

h6 {
    font-size: 1.125rem;
    font-weight: 600;
}

.display-1 {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--primary-color);
}

.display-2 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--primary-color);
}

.display-3 {
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--primary-color);
}

.display-4 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--primary-color);
}

/* Lead text */
.lead {
    font-size: 1.25rem;
    font-weight: 300;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Link styles conformi AGID */
a {
    color: var(--primary-color);
    text-decoration: underline;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

a:focus {
    outline: 0;
    box-shadow: var(--focus-ring);
    border-radius: var(--border-radius-sm);
}

/* Text utilities - Solo Titillium Web */
.text-serif {
    font-family: 'Titillium Web', sans-serif !important;
}

.text-monospace {
    font-family: 'Titillium Web', monospace !important;
}

.fw-light { font-weight: 300 !important; }
.fw-normal { font-weight: 400 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fw-bolder { font-weight: 900 !important; }

/* Header PA conforme linee guida AGID */
.header-pa {
    background-color: var(--primary-color);
    border-bottom: 3px solid var(--primary-dark);
}

.header-pa .navbar-brand {
    font-family: var(--font-family-sans-serif);
    font-weight: 700;
    font-size: 1.375rem;
    color: white !important;
    text-decoration: none;
}

.header-pa .navbar-brand:hover {
    color: var(--primary-lightest) !important;
}

.header-pa .navbar-brand svg,
.header-pa .navbar-brand i {
    margin-right: 0.75rem;
    vertical-align: middle;
}

.navbar-nav .nav-link {
    font-family: var(--font-family-sans-serif);
    font-weight: 500;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    transition: var(--transition-fast);
    border-radius: var(--border-radius);
    margin: 0 0.25rem;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white !important;
}

.navbar-nav .nav-link:focus {
    outline: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.navbar-nav .nav-link.active {
    background-color: var(--primary-dark);
    color: white !important;
    font-weight: 600;
}

/* Hamburger menu accessibile */
.navbar-toggler {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius);
    padding: 0.375rem 0.75rem;
}

.navbar-toggler:focus {
    outline: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Theme Toggle AGID conforme */
.theme-toggle {
    background: none;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius);
    color: white;
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-left: 0.5rem;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

.theme-toggle:focus {
    outline: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
    color: white;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: var(--transition-fast);
}

.theme-toggle .theme-icon {
    display: block;
}

.theme-toggle .theme-icon.d-none {
    display: none !important;
}

/* Screen reader only text for theme toggle */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Cards conformi Design System .italia */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    transition: var(--transition-base);
    margin-bottom: 1.5rem;
    background-color: var(--surface-color);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--box-shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.card-header {
    background-color: var(--surface-secondary);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-family-sans-serif);
    font-weight: 600;
    font-size: 1.125rem;
    padding: 1rem 1.25rem;
    color: var(--text-color);
}

.card-body {
    padding: 1.25rem;
    font-family: var(--font-family-sans-serif);
}

.card-title {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.card-subtitle {
    font-weight: 400;
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.card-footer {
    background-color: var(--surface-secondary);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}

/* Card specifiche per contenuti PA */
.card-primary {
    border-left: 4px solid var(--primary-color);
}

.card-success {
    border-left: 4px solid var(--success-color);
}

.card-warning {
    border-left: 4px solid var(--warning-color);
}

.card-danger {
    border-left: 4px solid var(--danger-color);
}

/* Buttons conformi Design System .italia */
.btn {
    font-family: var(--font-family-sans-serif);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.375;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--box-shadow-lg);
}

.btn:focus {
    outline: 0;
    box-shadow: var(--focus-ring);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--box-shadow);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Button primario */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-primary:focus {
    box-shadow: var(--focus-ring);
}

.btn-primary:active {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Button outline primario */
.btn-outline-primary {
    background-color: transparent;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Button secondario */
.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--gray-600);
    border-color: var(--gray-600);
    color: white;
}

/* Button success */
.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #006B47;
    border-color: #006B47;
    color: white;
}

.btn-success:focus {
    box-shadow: var(--focus-ring-success);
}

/* Button warning */
.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #8A5700;
    border-color: #8A5700;
    color: white;
}

/* Button danger */
.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #B8293D;
    border-color: #B8293D);
    color: white;
}

.btn-danger:focus {
    box-shadow: var(--focus-ring-danger);
}

/* Button sizes */
.btn-sm {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    line-height: 1.25;
}

.btn-lg {
    font-size: 1.125rem;
    padding: 1rem 2rem;
    line-height: 1.5;
}

/* Button block */
.btn-block {
    display: block;
    width: 100%;
}

/* Button group */
.btn-group .btn {
    margin-right: 0;
}

.btn-group .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-group .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Forms conformi Design System .italia */
.form-label {
    font-family: var(--font-family-sans-serif);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: block;
}

.form-label.required::after {
    content: "*";
    color: var(--danger-color);
    margin-left: 0.25rem;
}

.form-control {
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    transition: var(--transition-fast);
    width: 100%;
}

.form-control:focus {
    outline: 0;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
    background-color: var(--surface-color);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: var(--surface-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.form-control.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: var(--focus-ring-danger);
}

.form-control.is-valid {
    border-color: var(--success-color);
}

.form-control.is-valid:focus {
    border-color: var(--success-color);
    box-shadow: var(--focus-ring-success);
}

/* Select */
.form-select {
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    transition: var(--transition-fast);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23666' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px 12px;
    appearance: none;
}

/* Form select dark mode con contrasto WCAG */
:root[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23B1BAC4' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

.form-select:focus {
    outline: 0;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

/* Checkbox e Radio */
.form-check {
    position: relative;
    display: block;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
}

.form-check-input {
    position: absolute;
    top: 0.25rem;
    left: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--surface-color);
    transition: var(--transition-fast);
    cursor: pointer;
}

.form-check-input[type="radio"] {
    border-radius: 50%;
}

.form-check-input:focus {
    outline: 0;
    box-shadow: var(--focus-ring);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
    background-size: 16px 16px;
    background-position: center;
    background-repeat: no-repeat;
}

.form-check-input[type="radio"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
}

.form-check-label {
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    color: var(--text-color);
    cursor: pointer;
    line-height: 1.5;
}

/* Form text e messaggi di aiuto */
.form-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.invalid-feedback {
    display: block;
    font-size: 0.875rem;
    color: var(--danger-color);
    margin-top: 0.25rem;
    font-weight: 500;
}

.valid-feedback {
    display: block;
    font-size: 0.875rem;
    color: var(--success-color);
    margin-top: 0.25rem;
    font-weight: 500;
}

/* Form groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-floating {
    position: relative;
}

.form-floating > .form-control {
    padding: 1rem 1rem 0.25rem;
}

.form-floating > label {
    position: absolute;
    top: 0;
    left: 1rem;
    height: 100%;
    padding: 1rem 0;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Alert conformi Design System .italia */
.alert {
    border: 1px solid transparent;
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    position: relative;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    z-index: 2;
}

/* Alert primario */
.alert-primary {
    background-color: var(--primary-lightest);
    border-color: var(--primary-light);
    color: var(--primary-dark);
}

/* Alert primary dark mode WCAG */
:root[data-theme="dark"] .alert-primary {
    background-color: #1565C0;
    border-color: var(--primary-color);
    color: #E3F2FD;
}

.alert-primary .alert-link {
    color: var(--primary-dark);
    font-weight: 600;
}

/* Alert success */
.alert-success {
    background-color: #E8F5E8;
    border-color: var(--success-color);
    color: #155724;
    border-left: 4px solid var(--success-color);
}

/* Alert success dark mode WCAG */
:root[data-theme="dark"] .alert-success {
    background-color: #1B5E20;
    border-color: var(--success-color);
    color: #C8E6C9;
}

.alert-success .alert-link {
    color: #155724;
    font-weight: 600;
}

/* Alert danger/error */
.alert-danger {
    background-color: #FBEAEA;
    border-color: var(--danger-color);
    color: #721C24;
    border-left: 4px solid var(--danger-color);
}

/* Alert danger dark mode WCAG */
:root[data-theme="dark"] .alert-danger {
    background-color: #B71C1C;
    border-color: var(--danger-color);
    color: #FFCDD2;
}

.alert-danger .alert-link {
    color: #721C24;
    font-weight: 600;
}

/* Alert warning */
.alert-warning {
    background-color: #FDF6E3;
    border-color: var(--warning-color);
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

/* Alert warning dark mode WCAG */
:root[data-theme="dark"] .alert-warning {
    background-color: #E65100;
    border-color: var(--warning-color);
    color: #FFE0B2;
}

.alert-warning .alert-link {
    color: #856404;
    font-weight: 600;
}

/* Alert info */
.alert-info {
    background-color: #E3F2FD;
    border-color: var(--info-color);
    color: #0C5460;
    border-left: 4px solid var(--info-color);
}

/* Alert info dark mode WCAG */
:root[data-theme="dark"] .alert-info {
    background-color: #01579B;
    border-color: var(--info-color);
    color: #BBDEFB;
}

.alert-info .alert-link {
    color: #0C5460;
    font-weight: 600;
}

/* Alert con icone */
.alert-icon {
    padding-left: 3rem;
}

.alert-icon::before {
    content: "";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    background-size: contain;
    background-repeat: no-repeat;
}

.alert-success.alert-icon::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23008758'%3e%3cpath fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z' clip-rule='evenodd'/%3e%3c/svg%3e");
}

.alert-danger.alert-icon::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23D1344C'%3e%3cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3e%3c/svg%3e");
}

.alert-warning.alert-icon::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A66F00'%3e%3cpath fill-rule='evenodd' d='M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3e%3c/svg%3e");
}

.alert-info.alert-icon::before {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2317A2B8'%3e%3cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z' clip-rule='evenodd'/%3e%3c/svg%3e");
}

/* Badges conformi Design System .italia */
.badge {
    font-family: var(--font-family-sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--border-radius);
    padding: 0.375rem 0.5rem;
    display: inline-block;
}

.badge-primary {
    background-color: var(--primary-color);
    color: white;
}

.badge-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.badge-success {
    background-color: var(--success-color);
    color: white;
}

.badge-warning {
    background-color: var(--warning-color);
    color: white;
}

.badge-danger {
    background-color: var(--danger-color);
    color: white;
}

.badge-info {
    background-color: var(--info-color);
    color: white;
}

.badge-light {
    background-color: var(--gray-200);
    color: var(--dark-color);
}

.badge-dark {
    background-color: var(--dark-color);
    color: white;
}

/* Badge outline */
.badge-outline-primary {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.badge-outline-secondary {
    background-color: transparent;
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
}

.badge-outline-success {
    background-color: transparent;
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.badge-outline-warning {
    background-color: transparent;
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

.badge-outline-danger {
    background-color: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

/* Badge rounded */
.badge-pill {
    border-radius: 10rem;
}

/* Tables conformi Design System .italia */
.table {
    font-family: var(--font-family-sans-serif);
    width: 100%;
    margin-bottom: 1rem;
    color: var(--dark-color);
    vertical-align: top;
    border-color: var(--gray-200);
    background-color: white;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 0.75rem;
    border-bottom: none;
    border-top: none;
    text-align: left;
}

.table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background-color: var(--gray-100);
    transition: var(--transition-fast);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.025);
}

.table-responsive {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table variants */
.table-primary th {
    background-color: var(--primary-color);
    color: white;
}

.table-secondary th {
    background-color: var(--secondary-color);
    color: white;
}

.table-success th {
    background-color: var(--success-color);
    color: white;
}

.table-warning th {
    background-color: var(--warning-color);
    color: white;
}

.table-danger th {
    background-color: var(--danger-color);
    color: white;
}

/* Table actions */
.table-actions {
    width: 1%;
    white-space: nowrap;
}

.table-actions .btn {
    margin-right: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.table-actions .btn:last-child {
    margin-right: 0;
}

/* Sidebar (Admin) */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);
}

.sidebar .nav-link {
    color: var(--dark-color);
    font-weight: 500;
    transition: var(--transition);
    border-radius: var(--border-radius);
    margin: 0.25rem 0.5rem;
}

.sidebar .nav-link:hover {
    background-color: var(--light-color);
    color: var(--primary-color);
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
}

/* Main content area for admin */
main {
    padding-top: 48px;
}

/* Modal */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--box-shadow-lg);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: var(--light-color);
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: var(--light-color);
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Custom utilities */
.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

/* Registry specific styles */
.registry-row {
    cursor: pointer;
    transition: var(--transition);
}

.registry-row:hover {
    background-color: #f8f9fa !important;
}

/* Search input styling */
#searchInput {
    max-width: 300px;
}

/* Questionnaire styles */
.question-card {
    border-left: 4px solid var(--primary-color);
}

.question-card.correct {
    border-left-color: var(--success-color);
}

.question-card.incorrect {
    border-left-color: var(--danger-color);
}

/* Statistics cards */
.stats-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stats-card h4 {
    color: white;
    margin-bottom: 0.5rem;
}

/* Footer PA conforme linee guida AGID */
.footer-pa {
    background-color: var(--dark-color);
    color: var(--gray-300);
    border-top: 3px solid var(--primary-color);
    margin-top: 3rem;
    padding: 2rem 0 1rem;
}

.footer-pa h5 {
    color: white;
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.footer-pa p {
    color: var(--gray-300);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.footer-pa a {
    color: var(--gray-300);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer-pa a:hover {
    color: white;
    text-decoration: underline;
}

.footer-pa .list-unstyled {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1rem;
}

.footer-pa .list-unstyled li {
    margin-bottom: 0.5rem;
}

.footer-pa .list-unstyled a {
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-block;
    padding: 0.25rem 0;
}

.footer-pa .list-unstyled a:hover {
    color: white;
    text-decoration: underline;
}

/* Footer bottom */
.footer-bottom {
    background-color: var(--gray-900);
    color: var(--gray-400);
    padding: 1rem 0;
    font-size: 0.75rem;
    text-align: center;
    border-top: 1px solid var(--gray-700);
}

.footer-bottom p {
    margin: 0;
    color: var(--gray-400);
}

/* Link istituzionali footer */
.footer-institutional-links {
    background-color: var(--gray-800);
    padding: 1rem 0;
    text-align: center;
    border-top: 1px solid var(--gray-700);
}

.footer-institutional-links a {
    color: var(--gray-300);
    font-size: 0.875rem;
    margin: 0 1rem;
    text-decoration: none;
}

.footer-institutional-links a:hover {
    color: white;
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    main {
        padding-top: 0;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-group-sm .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .display-4 {
        font-size: 2rem;
    }
    
    #searchInput {
        max-width: 100%;
        margin-top: 0.5rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .badge {
        font-size: 0.65em;
    }
    
    .form-control, .form-select {
        font-size: 0.875rem;
    }
}

/* Print styles */
@media print {
    .navbar, .sidebar, .btn, .modal, footer {
        display: none !important;
    }
    
    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .badge {
        border: 1px solid currentColor;
        color: #000 !important;
        background: transparent !important;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-color: #f8f9fa;
        --light-color: #343a40;
    }
    
    body {
        background-color: #121212;
        color: var(--dark-color);
    }
    
    .card {
        background-color: #1e1e1e;
        color: var(--dark-color);
    }
    
    .table {
        color: var(--dark-color);
    }
    
    .table th {
        background-color: #2d2d2d;
    }
    
    .form-control, .form-select {
        background-color: #2d2d2d;
        border-color: #495057;
        color: var(--dark-color);
    }
    
    .modal-content {
        background-color: #1e1e1e;
        color: var(--dark-color);
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* Focus indicators for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control, .form-select {
        border: 2px solid #000;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== RESPONSIVE DESIGN AGGIUNTIVO - MEDIA QUERIES AGID ===== */

/* Miglioramenti per la responsiveness su tutti i dispositivi */
@media (max-width: 1199.98px) {
    .container {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .display-3 { 
        font-size: 2.25rem; 
        line-height: 1.2; 
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-lg {
        font-size: 1rem;
        padding: 0.875rem 1.75rem;
    }
}

/* Tablet - fino a 991px */
@media (max-width: 991.98px) {
    .display-3 { 
        font-size: 2rem; 
        line-height: 1.3; 
    }
    
    .display-4 { 
        font-size: 1.75rem; 
        line-height: 1.3; 
    }
    
    .lead {
        font-size: 1.125rem;
        line-height: 1.6;
    }
    
    .navbar-brand {
        font-size: 1.125rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.625rem 0.875rem;
        font-size: 0.95rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .row.g-4 > * {
        margin-bottom: 1rem;
    }
}

/* Mobile landscape - fino a 767px */
@media (max-width: 767.98px) {
    html {
        font-size: 15px; /* Leggermente più piccolo per mobile */
    }
    
    .container {
        padding-left: 0.875rem;
        padding-right: 0.875rem;
    }
    
    /* Typography mobile ottimizzata */
    h1 { 
        font-size: 1.875rem; 
        line-height: 1.3; 
        margin-bottom: 0.875rem;
    }
    
    .display-3 { 
        font-size: 1.75rem; 
        line-height: 1.3; 
        margin-bottom: 1rem;
    }
    
    .display-4 { 
        font-size: 1.5rem; 
        line-height: 1.3; 
    }
    
    .lead {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }
    
    /* Header mobile */
    .header-pa .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar-collapse {
        margin-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 1rem;
    }
    
    /* Cards responsive */
    .card {
        border-radius: var(--border-radius);
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem 0.875rem;
        text-align: center;
    }
    
    .card-title {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }
    
    .card svg {
        width: 42px;
        height: 42px;
        margin-bottom: 0.75rem;
    }
    
    /* Bottoni mobile */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Griglie responsive */
    .row.g-4 > * {
        margin-bottom: 1.25rem;
    }
    
    .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Forms mobile */
    .form-control,
    .form-select {
        padding: 0.75rem;
        font-size: 1rem;
    }
    
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    /* Alerts mobile */
    .alert {
        padding: 1rem;
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }
    
    .alert-icon {
        padding-left: 2.75rem;
    }
    
    .alert-icon::before {
        left: 0.875rem;
        width: 1.125rem;
        height: 1.125rem;
    }
}

/* Mobile portrait - fino a 575px */
@media (max-width: 575.98px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Typography mobile portrait */
    h1 { font-size: 1.625rem; }
    .display-3 { font-size: 1.625rem; }
    .display-4 { font-size: 1.375rem; }
    
    .lead {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    /* Header compatto */
    .header-pa .navbar-brand {
        font-size: 0.95rem;
    }
    
    .navbar-toggler {
        padding: 0.375rem 0.625rem;
        font-size: 0.875rem;
    }
    
    /* Cards stack su mobile portrait */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 0.875rem;
    }
    
    .card svg {
        width: 36px;
        height: 36px;
        margin-bottom: 0.625rem;
    }
    
    .card-title {
        font-size: 1rem;
        margin-bottom: 0.625rem;
    }
    
    .card-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* Bottoni compatti */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
    
    /* Forms compatte */
    .form-control,
    .form-select {
        padding: 0.625rem;
        font-size: 0.95rem;
    }
    
    /* Tables responsive */
    .table-responsive {
        font-size: 0.85rem;
        border: none;
    }
    
    .table-responsive table {
        min-width: 500px;
    }
}

/* Ottimizzazioni per accessibilità e prestazioni */
@media (max-width: 480px) {
    /* Extra small devices */
    .display-3 { font-size: 1.5rem; }
    
    .card svg {
        width: 32px;
        height: 32px;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.875rem;
    }
    
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}
