/* CSS per i form dinamici condizionali */

/* Base container */
#conditional-forms-container {
    position: relative;
    z-index: 10000;
}

/* Stili generali per tutti i form */
.conditional-form {
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
    box-sizing: border-box;
    position: relative;
}

.conditional-form * {
    box-sizing: border-box;
}

/* Popup Modal Styles */
.conditional-form-popup {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10001 !important;
    display: none; /* Hidden by default, shown by JavaScript */
}

.conditional-form-popup.conditional-form-displayed {
    display: flex !important;
}

.conditional-form-popup .conditional-form-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.3s ease-out;
}

.conditional-form-popup-content {
    background: white;
    border-radius: 12px;
    max-width: 90%;
    width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.3s ease-out;
    position: relative;
}

.conditional-form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 24px 16px;
    border-bottom: 1px solid #eee;
}

.conditional-form-title {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    color: #333;
    flex-grow: 1;
    line-height: 1.3;
}

.conditional-form-subtitle {
    margin: 8px 0 0;
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
}

.conditional-form-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 4px;
    margin-left: 16px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.conditional-form-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

.conditional-form-body {
    padding: 24px;
}

.conditional-form-content {
    margin-bottom: 20px;
    color: #555;
    line-height: 1.6;
}

.conditional-form-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid #eee;
}

.conditional-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Banner Styles */
.conditional-form-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    z-index: 10001;
    animation: slideInDown 0.3s ease-out;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.conditional-form-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.conditional-form-banner-text {
    flex-grow: 1;
}

.conditional-form-banner-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.conditional-form-banner .conditional-form-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
}

.conditional-form-banner .conditional-form-subtitle {
    margin: 4px 0 0;
    opacity: 0.9;
    font-size: 0.85em;
}

.conditional-form-banner .conditional-form-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.conditional-form-banner .conditional-form-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Sidebar Styles */
.conditional-form-sidebar {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    animation: slideInRight 0.3s ease-out;
    border: 1px solid #e0e0e0;
}

.conditional-form-sidebar-content {
    padding: 20px;
}

.conditional-form-sidebar .conditional-form-header {
    padding: 0 0 16px;
    border-bottom: 1px solid #eee;
    margin-bottom: 16px;
}

.conditional-form-sidebar .conditional-form-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
}

.conditional-form-sidebar .conditional-form-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.conditional-form-sidebar .conditional-form-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* Floating Button Styles */
.conditional-form-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
}

.conditional-form-floating-trigger {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    font-family: inherit;
    font-weight: 500;
}

.conditional-form-floating-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.5);
}

.conditional-form-floating-trigger .floating-text {
    font-size: 0.9em;
}

.conditional-form-floating-content {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid #e0e0e0;
    animation: slideInUp 0.3s ease-out;
}

.conditional-form-floating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.conditional-form-floating-body {
    padding: 20px;
}

/* Inline Styles */
.conditional-form-inline {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin: 20px 0;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.conditional-form-inline-content {
    padding: 24px;
}

.conditional-form-inline .conditional-form-header {
    padding: 0 0 16px;
    border-bottom: 1px solid #eee;
    margin-bottom: 16px;
}

/* Form Fields Styles */
.conditional-form-fields {
    margin: 0;
}

.conditional-form-field {
    margin-bottom: 16px;
}

/* Message container styles */
.conditional-form-message-container {
    margin: 0 0 16px 0;
    padding: 0;
}

.conditional-form-message-container.has-message {
    display: block !important;
}

.form-success-message,
.form-error-message {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 0;
    font-size: 0.9em;
    font-weight: 500;
    border-width: 1px;
    border-style: solid;
}

.form-success-message {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.form-error-message {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.conditional-form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 0.9em;
}

.conditional-form-label .required {
    color: #e74c3c;
    margin-left: 2px;
}

.conditional-form-input,
.conditional-form-textarea,
.conditional-form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: inherit;
    transition: all 0.2s;
    background-color: white;
}

/* Email input specific styling */
.conditional-form-input[type="email"] {
    color: white;
    background: #333;
}

.conditional-form-input[type="email"]::-webkit-input-placeholder {
    color: #ccc;
    opacity: 1;
}

.conditional-form-input[type="email"]::-moz-placeholder {
    color: #ccc;
    opacity: 1;
}

.conditional-form-input[type="email"]:-ms-input-placeholder {
    color: #ccc;
}

.conditional-form-input:focus,
.conditional-form-textarea:focus,
.conditional-form-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.conditional-form-textarea {
    min-height: 80px;
    resize: vertical;
}

/* Radio and Checkbox Styles */
.conditional-form-radio-group {
    border: none;
    padding: 0;
    margin: 0;
}

.conditional-form-radio-group legend {
    padding: 0;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 0.9em;
}

.conditional-form-radio-label,
.conditional-form-checkbox-label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.conditional-form-radio-label:hover,
.conditional-form-checkbox-label:hover {
    background-color: #f8f9fa;
}

.conditional-form-radio,
.conditional-form-checkbox {
    margin-right: 8px;
    accent-color: #667eea;
}

.radio-text,
.checkbox-text {
    font-size: 0.9em;
    color: #333;
}

/* Button Styles */
.conditional-form-submit,
.conditional-form-button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-transform: none;
}

.btn {
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 1px solid #667eea;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
    color: #495057;
}

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

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

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translate(100%, -50%);
        opacity: 0;
    }
    to {
        transform: translate(0, -50%);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .conditional-form-popup-content {
        width: 95%;
        max-width: none;
        margin: 10px;
        min-height: auto;
    }
    
    .conditional-form-banner-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .conditional-form-banner-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .conditional-form-sidebar {
        right: 10px;
        width: calc(100% - 20px);
        max-width: 300px;
    }
    
    .conditional-form-floating-content {
        width: calc(100vw - 40px);
        right: 10px;
    }
    
    .conditional-form-floating-trigger .floating-text {
        display: none;
    }
    
    .conditional-form-floating-trigger {
        border-radius: 50%;
        width: 56px;
        height: 56px;
        padding: 16px;
    }
    
    .conditional-form-input,
    .conditional-form-textarea,
    .conditional-form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 16px;
    }
    
    .conditional-form-field {
        margin-bottom: 20px;
    }
    
    .conditional-form-label {
        font-size: 1em;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .conditional-form-popup-content {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .conditional-form-header,
    .conditional-form-body,
    .conditional-form-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .conditional-form-submit,
    .conditional-form-button {
        width: 100%;
        padding: 16px 24px;
        font-size: 1em;
        margin-top: 8px;
    }
    
    .conditional-form-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .conditional-form-title {
        font-size: 1.3em;
        line-height: 1.3;
    }
    
    .conditional-form-subtitle {
        font-size: 0.95em;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .conditional-form-popup-content,
    .conditional-form-sidebar,
    .conditional-form-inline,
    .conditional-form-floating-content {
        background: #2a2a2a;
        color: #e0e0e0;
        border-color: #444;
    }
    
    .conditional-form-title {
        color: #e0e0e0;
    }
    
    .conditional-form-subtitle,
    .conditional-form-content {
        color: #ccc;
    }
    
    .conditional-form-input,
    .conditional-form-textarea,
    .conditional-form-select {
        background-color: #333;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .conditional-form-input[type="email"] {
        color: white;
        background: #333;
    }
    
    .conditional-form-header,
    .conditional-form-footer {
        border-color: #444;
    }
    
    .btn-secondary {
        background: #444;
        color: #ccc;
        border-color: #555;
    }
    
    .btn-secondary:hover {
        background: #555;
        color: #e0e0e0;
    }
}

/* Mobile viewport fixes */
@media (max-width: 768px) {
    .conditional-form-popup {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height for mobile */
    }
    
    .conditional-form-popup-overlay {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .conditional-form-close {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .conditional-form-submit,
    .conditional-form-button {
        min-height: 48px;
        touch-action: manipulation;
    }
    
    .conditional-form-input,
    .conditional-form-textarea,
    .conditional-form-select {
        min-height: 48px;
        touch-action: manipulation;
    }
}

/* Accessibility */
.conditional-form-close:focus,
.conditional-form-input:focus,
.conditional-form-textarea:focus,
.conditional-form-select:focus,
.conditional-form-submit:focus,
.conditional-form-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .conditional-form {
        display: none !important;
    }
}

/* Newsletter-specific mobile optimizations */
@media (max-width: 768px) {
    /* Improve email input specifically for newsletter forms */
    .conditional-form-input[type="email"] {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 16px;
        border-radius: 8px;
        background: #2a2a2a;
        color: white;
    }
    
    .conditional-form-input[type="email"]:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    }
    
    /* Better mobile banner for newsletter signups */
    .conditional-form-banner {
        padding: 0;
    }
    
    .conditional-form-banner-content {
        padding: 16px 20px;
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .conditional-form-banner-text {
        margin-bottom: 12px;
    }
    
    .conditional-form-banner-actions {
        width: 100%;
        justify-content: center;
        gap: 12px;
    }
    
    /* Mobile-optimized sidebar for newsletter */
    .conditional-form-sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        transform: none;
        width: 100%;
        border-radius: 12px 12px 0 0;
        animation: slideInUp 0.3s ease-out;
        max-height: 80vh;
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    /* Ultra-small screen optimizations */
    .conditional-form-input[type="email"] {
        padding: 18px;
        font-size: 16px;
        min-height: 52px;
    }
    
    .conditional-form-floating-content {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .conditional-form-popup-overlay {
        align-items: flex-end;
        padding: 0;
    }
    
    .conditional-form-popup-content {
        width: 100%;
        height: auto;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
    }
}

/* ======= NOTICE-SPECIFIC STYLES ======= */

/* Notice Popup Styles */
.conditional-form-popup-content.conditional-form-notice {
    border-top: 4px solid #007bff;
}

.conditional-form-notice-indicator {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.conditional-form-notice-indicator.notice-type-info {
    background: #007bff;
}

.conditional-form-notice-indicator.notice-type-warning {
    background: #ffc107;
}

.conditional-form-notice-indicator.notice-type-error {
    background: #dc3545;
}

.conditional-form-notice-indicator.notice-type-success {
    background: #28a745;
}

/* Notice Actions */
.conditional-form-notice-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.conditional-form-notice-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.conditional-form-notice-actions .btn-primary {
    background: #007bff;
    color: white;
}

.conditional-form-notice-actions .btn-primary:hover {
    background: #0056b3;
}

.conditional-form-notice-actions .btn-secondary {
    background: #6c757d;
    color: white;
}

.conditional-form-notice-actions .btn-secondary:hover {
    background: #5a6268;
}

.conditional-form-notice-actions .btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

/* Notice Banner Styles */
.conditional-form-banner-notice {
    background: linear-gradient(135deg, #007bff, #0056b3) !important;
}

.conditional-form-banner-notice.notice-type-warning {
    background: linear-gradient(135deg, #ffc107, #e0a800) !important;
    color: #212529 !important;
}

.conditional-form-banner-notice.notice-type-error {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
}

.conditional-form-banner-notice.notice-type-success {
    background: linear-gradient(135deg, #28a745, #1e7e34) !important;
}

.conditional-form-notice-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.conditional-form-notice-content {
    margin-top: 8px;
    font-size: 0.9em;
    opacity: 0.95;
}

/* Notice Banner Actions */
.conditional-form-banner-notice .conditional-form-banner-actions .btn {
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.conditional-form-banner-notice .conditional-form-banner-actions .btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.conditional-form-banner-notice.notice-type-warning .conditional-form-banner-actions .btn {
    background: rgba(33, 37, 41, 0.1);
    color: #212529;
    border-color: rgba(33, 37, 41, 0.2);
}

.conditional-form-banner-notice.notice-type-warning .conditional-form-banner-actions .btn:hover {
    background: rgba(33, 37, 41, 0.15);
    border-color: rgba(33, 37, 41, 0.3);
}

/* Notice Auto-Dismiss Animation */
.conditional-form-notice-auto-dismiss {
    animation: noticeCountdown 5s linear forwards;
}

@keyframes noticeCountdown {
    0% {
        border-bottom: 4px solid #007bff;
    }
    100% {
        border-bottom: 4px solid transparent;
    }
}

/* Notice Responsive */
@media (max-width: 768px) {
    .conditional-form-banner-notice .conditional-form-banner-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .conditional-form-banner-notice .conditional-form-notice-icon {
        margin-right: 0;
        margin-bottom: 8px;
    }
    
    .conditional-form-notice-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .conditional-form-notice-actions .btn {
        width: 100%;
    }
}
