/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
    padding-top: calc(80px + 1rem);
    padding-bottom: 1rem;
    box-sizing: border-box;
    overflow-y: auto;
    min-height: 100vh;
    min-width: 100vw;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    background-image: url("/images/pawPattern.webp");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid #0bb1b3;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 100%;
    max-height: calc(100vh - 80px - 2rem);
    overflow-y: auto;
    transform: translateY(-50px) scale(0.9);
    transition: all 0.3s ease;
    position: relative;
    margin: auto;
    flex-shrink: 0;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
    color: #0bb1b3;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.modal-header p {
    color: #1c1c1c;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #0f6869;
    font-weight: 600;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #0bb1b3;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #0bb1b3;
    box-shadow: 0 0 0 3px rgba(11, 177, 179, 0.1);
}

.form-group input.error {
    border-color: #e74c3c;
}

.error-message {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: none;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    flex: 1;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #f21187;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: rgba(242, 17, 135, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 170, 221, 0.4);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #e1e1e1;
}

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

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
}

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

.loading {
    display: none;
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0061ae;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Contenedor del input de teléfono integrado */
.phone-input-container {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    border: 1px solid #0bb1b3;
    border-radius: 8px;
    overflow: visible;
    background: white;
    transition: all 0.3s ease;
}

.phone-input-container:focus-within {
    border-color: #0bb1b3;
    box-shadow: 0 0 0 3px rgba(11, 177, 179, 0.1);
}

.phone-input-container.error {
    border-color: #e74c3c;
}

/* Select del código de país */
.phone-country-select {
    border: none;
    background: white;
    padding: 0.8rem;
    padding-right: 28px;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
    border-right: 1px solid #e0e0e0;
    min-width: 95px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    border-radius: 8px 0 0 8px;
    transition: background-color 0.2s ease;
}

.phone-country-select:hover {
    background-color: #f8f9fa;
}

.phone-country-select:focus {
    background-color: #f8f9fa;
}

/* Input del número de teléfono */
.phone-number-input {
    flex: 1;
    border: none;
    padding: 0.8rem;
    font-size: 1rem;
    outline: none;
    background: transparent;
    border-radius: 0 8px 8px 0;
}

.phone-number-input::placeholder {
    color: #999;
}

.phone-number-input.error {
    border-color: transparent;
}
 /* Custom scrollbar */
        #dropdownMenu::-webkit-scrollbar {
            width: 8px;
        }
        
        #dropdownMenu::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 10px;
        }
        
        #dropdownMenu::-webkit-scrollbar-thumb {
            background: #0bb1b3;
            border-radius: 10px;
        }
        
        #dropdownMenu::-webkit-scrollbar-thumb:hover {
            background: #099a9c;
        }
        #buttonGroup {
    transition: margin-top 0.3s ease;
}
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.success-message {
    display: none;
    text-align: center;
    padding: 2rem 1rem;
    color: rgb(38, 163, 90);
}

.error-display {
    display: none;
    text-align: center;
    padding: 2rem 1rem;
    color: #e74c3c;
}

/* Específico para dispositivos de pantalla intermedia (tablets, NestHub, etc.) */
@media (min-width: 481px) and (max-width: 1024px) {
    .modal-overlay {
        align-items: flex-start;
    }

    .modal {
        margin-top: 0;
        max-height: calc(100vh - 80px - 2rem);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
        padding-top: calc(80px + 1rem);
    }

    .modal {
        padding: 1.5rem;
        margin: 0;
        max-height: calc(100vh - 80px - 2rem);
        border-radius: 12px;
        min-height: auto;
    }

    .modal-header h2 {
        font-size: 1.6rem;
    }

    .form-group input {
        padding: 1rem;
        font-size: 1rem;
    }

    .phone-country-select {
        padding: 1rem;
        padding-right: 28px;
        font-size: 1rem;
        min-width: 90px;
    }

    .phone-number-input {
        padding: 1rem;
        font-size: 1rem;
    }

    .btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .close-btn {
        top: 10px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0.25rem;
        padding-top: calc(80px + 0.5rem);
    }

    .modal {
        padding: 1.25rem;
        border-radius: 10px;
        max-height: calc(100vh - 80px - 1rem);
    }

    .modal-header {
        margin-bottom: 1.25rem;
        padding-bottom: 0.75rem;
    }

    .modal-header h2 {
        font-size: 1.5rem;
    }

    .modal-header p {
        font-size: 0.9rem;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.4rem;
    }

    .form-group input {
        padding: 0.9rem;
        font-size: 0.95rem;
    }

    .phone-country-select {
        padding: 0.9rem;
        padding-right: 26px;
        font-size: 0.95rem;
        min-width: 85px;
    }

    .phone-number-input {
        padding: 0.9rem;
        font-size: 0.95rem;
    }

    .button-group {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    .btn {
        padding: 0.9rem;
        font-size: 0.95rem;
    }

    .close-btn {
        top: 8px;
        right: 12px;
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
    }

    .loading {
        padding: 1.5rem;
    }

    .success-message,
    .error-display {
        padding: 1.5rem 1rem;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (max-width: 768px) {
    .modal-overlay {
        align-items: flex-start;
        padding-top: calc(80px + 0.25rem);
    }

    .modal {
        max-height: calc(100vh - 80px - 0.5rem);
        padding: 1rem;
    }

    .modal-header {
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }

    .modal-header h2 {
        font-size: 1.4rem;
        margin-bottom: 0.25rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-group input {
        padding: 0.7rem;
    }

    .phone-country-select {
        padding: 0.7rem;
        padding-right: 24px;
        font-size: 0.9rem;
    }

    .phone-number-input {
        padding: 0.7rem;
        font-size: 0.9rem;
    }

    .button-group {
        margin-top: 1rem;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .modal {
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .modal-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* Pantallas muy pequeñas en altura (como algunos dispositivos smart home) */
@media (max-height: 600px) {
    .modal-overlay {
        align-items: flex-start;
        padding-top: calc(80px + 0.5rem);
        padding-bottom: 0.5rem;
    }

    .modal {
        max-height: calc(100vh - 80px - 1rem);
        padding: 1.5rem;
    }

    .modal-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .button-group {
        margin-top: 1rem;
    }
}