/* =========================================
   MODALS CSS - PERFORMANCE & STYLE FIX
   ========================================= */

/* Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Sfondo scuro senza blur per performance */
    z-index: 1000000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    padding: 10px;
    box-sizing: border-box;
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1;
}

/* Modal Content */
.modal-content {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 16px;
    padding: 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    z-index: 1000001; 
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- MODALE LARGE (2 Colonne) --- */
.modal-content.modal-large {
    max-width: 1200px !important;
    width: 95vw !important;
    height: 85vh;
}

/* Header */
.modal-header {
    padding: 20px 25px;
    background: #18181b;
    border-bottom: 1px solid #27272a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}
.modal-header h2 i { color: var(--primary); }

/* Body */
.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex-grow: 1;
}

/* Griglia Layout */
.modal-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
    height: 100%;
}

.modal-left-col, .modal-right-col {
    width: 100%;
    min-width: 0;
}

/* Stile Colonna Destra (Box) */
.modal-right-col {
    background: #1f1f23;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #333;
    height: 100%;
    box-sizing: border-box;
}

/* Footer & Buttons */
.modal-footer-bar {
    padding: 20px 30px;
    background: #131316;
    border-top: 1px solid #27272a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 20px;
}

/* PULSANTI ACTION (FIX) */
.btn-modal-action {
    flex: 1 1 0;
    padding: 16px 20px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 55px;
    white-space: nowrap;
}

.btn-modal-action:active { transform: scale(0.98); }

/* Save Button */
.btn-save {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.2);
}
.btn-save:hover { filter: brightness(1.1); box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.3); }

/* Sponsor Button */
.btn-sponsor {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}
.btn-sponsor:hover { 
    filter: brightness(1.15); 
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4); 
    transform: translateY(-1px);
}

/* Close Btn */
.modal-close-btn {
    background: transparent; border: none; color: #71717a; font-size: 24px;
    cursor: pointer; transition: color 0.2s; display: flex; align-items: center;
}
.modal-close-btn:hover { color: #fff; }

/* Form Styles */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #e4e4e7; font-size: 0.9rem; }

.form-input, .form-select, .form-textarea {
    width: 100%; background: #09090b; border: 1px solid #27272a; color: #fff;
    border-radius: 8px; padding: 12px 14px; font-size: 0.95rem; font-family: inherit;
    transition: all 0.2s ease; box-sizing: border-box;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* Country & Votifier Fix */
select.country-select {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em; padding-right: 2.5rem;
    background-color: #09090b;
}

textarea.votifier-key-area {
    font-family: 'Courier New', monospace; font-size: 0.8rem;
    background: #000; border: 1px solid #3f3f46; color: #4ade80;
    padding: 15px; min-height: 120px; line-height: 1.4; word-break: break-all;
}
input.votifier-port-input {
    background: #000; font-family: monospace; text-align: center; letter-spacing: 1px;
}

/* Checkbox Modes Style Fix */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }

.checkbox-item {
    cursor: pointer;
    position: relative;
}

/* Nasconde completamente l'input checkbox nativo */
.checkbox-item input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Stile del pulsante (label/span) */
.checkbox-item span {
    padding: 10px 18px; 
    background: #27272a; 
    border-radius: 8px; 
    font-size: 0.9rem;
    font-weight: 500;
    color: #a1a1aa; 
    cursor: pointer; 
    border: 1px solid #3f3f46; 
    transition: all 0.2s;
    user-select: none; 
    display: inline-block;
}

.checkbox-item:hover span { 
    background: #3f3f46; 
    color: #fff; 
    border-color: #52525b;
}

/* Stato Selezionato */
.checkbox-item input:checked + span {
    background: var(--primary); 
    color: #000; 
    font-weight: 700; 
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

/* Mobile */
@media (max-width: 850px) {
    .modal-content.modal-large { height: auto; max-height: 95vh; width: 95% !important; margin: 10px; }
    .modal-grid-layout { grid-template-columns: 1fr; gap: 20px; }
    .modal-right-col { height: auto; }
    .modal-footer-bar { flex-direction: column; gap: 10px; padding: 15px; }
    .btn-modal-action { width: 100%; flex: auto; }
}

/* Standard */
.btn-primary { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; }
.btn-discord { background: #5865F2; color: white; }
.error-msg { color: #fca5a5; background: rgba(127, 29, 29, 0.2); border: 1px solid rgba(248, 113, 113, 0.3); padding: 12px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9rem; display: none; }