/* Modal PGN - Overlay */
.pgn-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(48px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    overflow-y: auto;
    scroll-padding-bottom: 80px;
}

.pgn-modal-overlay.active {
    display: flex;
}

/* Modal Container */
.pgn-modal-container {
    background: var(--theme-modal-bg);
    border: 1px solid var(--theme-border);
    border-radius: 15px;
    max-width: 480px;
    width: 90%;
    margin: 0 auto;
    box-shadow: 0 20px 60px var(--theme-shadow);
    animation: modalSlideIn 0.3s ease-out;
    max-height: calc(94vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: all var(--transition-theme);
}

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

/* Header */
.pgn-modal-header {
    background: var(--theme-button-hover);
    color: var(--theme-button-text-hover);
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pgn-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.pgn-modal-close {
    background: none;
    border: none;
    color: var(--theme-button-text-hover);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.pgn-modal-close:hover {
    transform: scale(1.2);
}

/* Content */
.pgn-modal-content {
    padding: 20px;
    flex: 1 1 auto;
}

/* Form */
.pgn-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pgn-form-row {
    display: flex;
    gap: 12px;
}

.pgn-form-group--name {
    flex: 1.6;
}

.pgn-form-group--elo {
    flex: 0.8;
    min-width: 120px;
}

.pgn-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pgn-form-label {
    font-size: 0.8rem;
    color: #D4AF37;
    font-weight: 500;
}

.pgn-form-input,
.pgn-form-select {
    padding: 10px 12px;
    border: 1px solid var(--theme-input-border);
    border-radius: 6px;
    background: var(--theme-input-bg);
    color: var(--theme-text-secondary);
    font-size: 0.85rem;
    font-family: inherit;
    transition: all var(--transition-theme);
}

.pgn-form-input:focus,
.pgn-form-select:focus {
    outline: none;
    border-color: var(--theme-accent-primary);
    box-shadow: 0 0 0 2px var(--theme-shadow-glow);
    background: var(--theme-bg-tertiary);
}

.pgn-form-input::placeholder {
    color: var(--theme-input-placeholder);
    opacity: 1;
}

.pgn-form-select {
    cursor: pointer;
}

.pgn-form-select option {
    background: #1a1a1a;
    color: #e8e8e8;
}

/* Footer */
.pgn-modal-footer {
    padding: 20px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons */
.pgn-modal-btn {
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    min-width: 180px;
    margin-bottom: 6px;
}

.pgn-modal-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.pgn-modal-btn:active {
    transform: translateY(0) scale(0.98);
}

.pgn-modal-btn.secondary {
    background: var(--theme-button-bg);
    border: 2px solid var(--theme-border);
    color: var(--theme-accent-primary);
    text-shadow: 0 1px 2px var(--theme-shadow);
    transition: all var(--transition-theme);
}

.pgn-modal-btn.secondary:hover {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-accent-primary);
    color: var(--theme-accent-primary);
    filter: brightness(1.2);
    box-shadow: 
        0 8px 16px var(--theme-shadow),
        0 0 20px var(--theme-shadow-glow);
}

.pgn-modal-btn.primary {
    background: var(--theme-button-hover);
    border: 2px solid var(--theme-accent-primary);
    color: var(--theme-button-text-hover);
    text-shadow: 0 1px 3px var(--theme-shadow);
    transition: all var(--transition-theme);
}

.pgn-modal-btn.primary:hover {
    background: linear-gradient(145deg, #E0004A 0%, #A0002A 100%);
    border-color: #FFD700;
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.4),
        0 0 25px rgba(197, 0, 57, 0.6),
        0 0 10px rgba(255, 215, 0, 0.3);
}

.pgn-modal-btn.whatsapp {
    background: linear-gradient(145deg, #25D366 0%, #128C7E 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.pgn-modal-btn.whatsapp:hover {
    background: linear-gradient(145deg, #2EE872 0%, #149B8A 100%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.4),
        0 0 25px rgba(37, 211, 102, 0.6),
        0 0 10px rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 600px) {
    .pgn-modal-overlay {
        align-items: flex-start;
        padding: calc(18px + env(safe-area-inset-top, 0px)) 12px calc(56px + env(safe-area-inset-bottom, 0px));
    }
    
    .pgn-modal-container {
        width: 100%;
        margin: 0 auto;
        max-height: calc(100vh - 40px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    }
    
    .pgn-form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .pgn-form-group--elo {
        min-width: unset;
    }
    
    .pgn-modal-header {
        padding: 15px;
    }
    
    .pgn-modal-title {
        font-size: 1rem;
    }
    
    .pgn-modal-content {
        padding: 15px;
    }
    
    .pgn-form-group {
        gap: 4px;
    }
    
    .pgn-modal-footer {
        flex-direction: column;
        padding: 15px;
        gap: 12px;
    }
    
    .pgn-modal-btn {
        width: 100%;
        min-width: unset;
    }
}

/* ===== MÓVILES HORIZONTALES ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .pgn-modal-overlay {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 10px calc(32px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    .pgn-modal-container {
        max-width: 320px !important;
        max-height: calc(85vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
    }
    
    .pgn-modal-header {
        padding: 12px !important;
    }
    
    .pgn-modal-title {
        font-size: 0.95rem !important;
    }
    
    .pgn-modal-close {
        width: 26px !important;
        height: 26px !important;
        font-size: 20px !important;
    }
    
    .pgn-modal-content {
        padding: 12px !important;
    }
    
    .pgn-form {
        gap: 10px !important;
    }
    
    .pgn-form-row {
        gap: 8px !important;
    }
    
    .pgn-form-group {
        gap: 4px !important;
    }
    
    .pgn-form-label {
        font-size: 0.75rem !important;
    }
    
    .pgn-form-input,
    .pgn-form-select {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
    }
    
    .pgn-modal-footer {
        padding: 12px !important;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        gap: 10px !important;
    }
    
    .pgn-modal-btn {
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
        min-width: 140px !important;
    }
}
