/* Popup Overlay */
.comuna-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Container del Popup */
.comuna-popup-container {
    background: #ffffff;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Header */
.comuna-popup-header {
    padding: 30px 30px 20px;
    border-bottom: 2px solid #f0f0f0;
    text-align: center;
}

.comuna-popup-header h2 {
    margin: 0 0 10px;
    font-size: 28px;
    color: #333;
    font-weight: 700;
}

.comuna-popup-header p {
    margin: 0;
    color: #666;
    font-size: 16px;
}

/* Content */
.comuna-popup-content {
    padding: 30px;
}

.sucursal-section {
    margin-bottom: 0;
}

/* Select de Comunas */
.comuna-select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    line-height: 1.5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    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 16px center;
    padding-right: 40px;
    height: auto;
    min-height: 50px;
}

.comuna-select option {
    padding: 10px;
    font-size: 16px;
    line-height: 1.5;
}

.comuna-select:hover {
    border-color: #0066cc;
}

.comuna-select:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.comuna-select.selected {
    border-color: #00cc66;
    background-color: #f0fdf4;
}

/* Footer */
.comuna-popup-footer {
    padding: 20px 30px 30px;
    text-align: center;
}

.comuna-btn-primary,
.comuna-btn-secondary {
    width: 100%;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 12px;
}

.comuna-btn-primary {
    color: #fff;
    background: #0066cc;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.comuna-btn-primary:hover:not(:disabled) {
    background: #0052a3;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 102, 204, 0.3);
}

.comuna-btn-primary:disabled {
    background: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
}

.comuna-btn-secondary {
    color: #666;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
}

.comuna-btn-secondary:hover:not(:disabled) {
    background: #e8e8e8;
    border-color: #ccc;
    transform: translateY(-1px);
}

.comuna-note {
    margin: 15px 0 0;
    font-size: 13px;
    color: #999;
}

/* Error Message */
.comuna-error-message {
    display: none;
    margin: 15px 30px;
    padding: 12px 16px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    color: #c00;
    font-size: 14px;
    text-align: center;
}

.comuna-error-message.show {
    display: block;
}

/* Loading State */
.comuna-btn-primary.loading,
.comuna-btn-secondary.loading {
    position: relative;
    color: transparent;
}

.comuna-btn-primary.loading::after,
.comuna-btn-secondary.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.comuna-btn-secondary.loading::after {
    border: 3px solid rgba(0, 0, 0, 0.2);
    border-top-color: #666;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 640px) {
    .comuna-popup-container {
        width: 95%;
        margin: 20px;
    }

    .comuna-popup-header {
        padding: 20px 20px 15px;
    }

    .comuna-popup-header h2 {
        font-size: 24px;
    }

    .comuna-popup-content {
        padding: 20px;
    }

    .comuna-btn-primary,
    .comuna-btn-secondary {
        font-size: 16px;
        padding: 14px 24px;
    }
}