/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #9b59b6;
    --light-bg: #ecf0f1;
    --lighter-bg: #f8f9fa;
    --dark-text: #2c3e50;
    --border-radius: 6px;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-strong: 0 6px 12px rgba(0,0,0,0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

/* Logo Header */
.logo-header {
    text-align: center;
    padding: 20px 0;
    background: white;
    /* border-radius: 0 0 var(--border-radius) var(--border-radius); */
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.logo {
    max-height: 120px;
    width: auto;
}

/* Privacy Disclaimer */
.privacy-disclaimer {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.privacy-disclaimer h3 {
    color: #856404;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.privacy-disclaimer p {
    color: #856404;
    margin-bottom: 10px;
}

.privacy-disclaimer ul {
    margin: 15px 0;
    padding-left: 25px;
}

.privacy-disclaimer li {
    color: #856404;
    margin-bottom: 5px;
    list-style-type: disc;
}

.privacy-disclaimer em {
    display: block;
    margin-top: 15px;
    font-weight: 600;
}

/* Header */
header {
    background: #e6f3ff;
    padding: 30px;
    border: 2px solid #3498db;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

h1 {
    color: var(--primary-color);
    font-size: 2em;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.1em;
    margin-bottom: 20px;
}

/* Law Reference - Collapsible */
.law-reference {
    background: white;
    margin-top: 30px;
    border-left: 4px solid #7c3aed;
    border-radius: var(--border-radius);
    padding: 0;
    box-shadow: var(--shadow);
}

.law-reference h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.law-text p {
    margin-bottom: 12px;
    line-height: 1.8;
    padding: 15px;
}

/* Collapsible Law Reference */
.law-reference-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    transition: background-color 0.3s ease;
}

.law-reference-toggle:hover {
    background: #e9ecef;
}

.law-reference-toggle h3 {
    margin: 0;
    display: inline;
}

.collapse-arrow {
    font-size: 20px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.collapse-arrow.collapsed {
    transform: rotate(-90deg);
}

.law-text-collapsible {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

.law-text-collapsible.collapsed {
    max-height: 0;
    padding: 0;
    opacity: 0;
}

/* Form Sections */
.form-section {
    background: white;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-section h2 {
    color: var(--primary-color);
    font-size: 1.4em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-bg);
}

/* Form Rows for multi-column layouts */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-row .form-group-small {
    flex: 0 0 120px;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark-text);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="tel"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input:required:valid {
    border-color: var(--success-color);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

/* Checkbox e Radio Groups */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: background 0.3s;
}

.checkbox-label:hover,
.radio-label:hover {
    background: var(--light-bg);
}

.checkbox-label input,
.radio-label input {
    margin-right: 10px;
    cursor: pointer;
}

/* Detailed Radio Groups */
.radio-group-detailed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label-detailed {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s;
}

.radio-label-detailed:hover {
    border-color: var(--secondary-color);
    background: var(--lighter-bg);
}

.radio-label-detailed input[type="radio"] {
    margin-right: 12px;
    margin-top: 3px;
}

.radio-label-detailed input[type="radio"]:checked + .radio-content {
    color: var(--primary-color);
}

.radio-label-detailed:has(input[type="radio"]:checked) {
    border-color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.05);
}

.radio-content {
    display: flex;
    flex-direction: column;
}

.radio-content strong {
    display: block;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.radio-content span {
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
}

/* Quick Add Section */
.quick-add-section {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--lighter-bg);
    border-radius: var(--border-radius);
}

.quick-add-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark-text);
}

.quick-add-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-add-btn {
    padding: 8px 16px;
    background: white;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9em;
    font-weight: 500;
}

.quick-add-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* AI System Entry */
.ai-system-entry {
    background: #f8f9fa;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: var(--border-radius);
    border: 1px solid #e0e0e0;
    position: relative;
}

.ai-system-entry.predefined-system {
    border-color: var(--info-color);
    background: rgba(155, 89, 182, 0.05);
}

.ai-system-entry h3 {
    color: var(--secondary-color);
    font-size: 1.1em;
    margin-bottom: 15px;
}

.remove-system {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.remove-system:hover {
    background: #c0392b;
    transform: rotate(90deg);
}

/* Buttons */
button {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--success-color);
    color: white;
    margin: 0 5px;
}

.btn-secondary:hover {
    background: #229954;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

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

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

#add-ai-system {
    background: #f8f9fa;
    color: var(--secondary-color);
    border: 2px dashed var(--secondary-color);
    width: 100%;
    margin-top: 15px;
}

#add-ai-system:hover {
    background: var(--secondary-color);
    color: white;
    border-style: solid;
}

/* Button Icons */
.btn-icon {
    margin-right: 8px;
    font-size: 1.1em;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 25px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-actions button {
    min-width: 150px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

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

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: var(--primary-color);
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.preview-format-select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 0.9em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.modal-close:hover {
    color: var(--danger-color);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex-grow: 1;
    background: #fafafa;
}

/* MODAL FOOTER - DEFINITIVO */
.modal-footer {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 20px !important;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.modal-footer button {
    flex: 1 1 0 !important;
    min-height: 50px !important;
    padding: 10px 8px !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    text-align: center !important;
}

.modal-footer .btn-icon {
    display: block !important;
    font-size: 20px !important;
    margin-bottom: 5px !important;
}

/* HERO SECTION - Box attraente e colorato */
.hero-section {
    background: linear-gradient(135deg, #f7fafc 0%, #e2e8f0 100%);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4);
    margin: 30px 0;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 50px 30px;
}

.hero-title {
    font-size: 2.5em;
    margin-bottom: 20px;
    line-height: 1.2;
    color: #004080;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    font-weight: 700;
}

.hero-subtitle {
    font-size: 1.3em;
    margin-bottom: 30px;
    color: rgba(45, 55, 72, 1);
    line-height: 1.6;
}

.hero-subtitle strong {
    color: #d97706;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.urgency-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b6b 40%, #ee5a6f 70%);
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: bold;
    margin-bottom: 30px;
    animation: pulse-badge 2s infinite;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    color: white;
    font-size: 1.1em;
    border: 2px solid rgba(255,255,255,0.3);
}

@keyframes pulse-badge {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
    }
}

.cta-primary {
    display: inline-block;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    padding: 20px 45px;
    font-size: 1.4em;
    font-weight: bold;
    text-decoration: none;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    border: 3px solid rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cta-primary:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
}

.cta-primary:active {
    transform: translateY(-2px);
}

.hero-note {
    margin-top: 25px;
    font-size: 1em;
    color: #4a5568;
    font-weight: 500;
    line-height: 1.6;
}

/* Blocco Informativa Matomo - Footer */
.matomo-disclaimer {
    max-width: 100%;
    margin: 30px 0 20px 0;
    padding: 20px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

.matomo-disclaimer h3 {
    color: #2d3748;
    font-size: 16px;
    margin: 0 0 15px 0;
    text-align: center;
    font-weight: 600;
}

.matomo-disclaimer p {
    line-height: 1.6;
    color: #4a5568;
    margin: 0 0 15px 0;
    text-align: justify;
}

.matomo-disclaimer a {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.matomo-disclaimer a:hover {
    text-decoration: underline;
}

#matomo-consent {
    margin-top: 20px;
    padding: 15px;
    background: #e3f2fd;
    border: 2px solid #90caf9;
    border-radius: 5px;
    display: inline-block;
}

#matomo-consent label {
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 15px;
    color: #1565c0;
}

#matomo-consent input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    accent-color: #ff9800;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 1.8em;
    }
    
    .hero-subtitle {
        font-size: 1.1em;
    }
    
    .cta-primary {
        font-size: 1.1em;
        padding: 15px 30px;
    }
    
    .hero-content {
        padding: 30px 20px;
    }
}
