/**
 * Admin Modal Styles
 *
 * Generic modal styling for Django admin bulk actions.
 * Used with admin_modal_action.js for intercepting form submissions
 * and showing modals directly on the changelist page.
 */

/* Modal container - use class .admin-action-modal for the wrapper */
.admin-action-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.admin-action-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.admin-action-modal .modal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.admin-action-modal .modal-header {
    padding: 15px 20px;
    background: #417690;
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-action-modal .modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.admin-action-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.admin-action-modal .modal-close:hover {
    opacity: 0.8;
}

.admin-action-modal .modal-body {
    padding: 20px;
    overflow-y: auto;
}

.admin-action-modal .modal-body label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
}

.admin-action-modal .modal-body .helptext {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
}

.admin-action-modal .modal-body .create-links {
    margin-top: 15px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 4px;
}

.admin-action-modal .modal-body .create-links a {
    margin-right: 10px;
}

.admin-action-modal .modal-footer {
    padding: 15px 20px;
    background: #f5f5f5;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.admin-action-modal .modal-message {
    padding: 10px;
    margin-top: 15px;
    border-radius: 4px;
    display: none;
}

.admin-action-modal .modal-message.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.admin-action-modal .modal-message.error {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

/* Select2 styling for modals */
.admin-action-modal select {
    width: 100%;
}

.admin-action-modal .select2-container--default .select2-selection--multiple {
    min-height: 40px;
    border: 1px solid #ccc;
}

.admin-action-modal .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #417690;
    border-color: #417690;
    color: white;
}

.admin-action-modal .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: white;
}

/* Ensure Select2 dropdown appears above modal */
.select2-container--open {
    z-index: 10001 !important;
}

.select2-dropdown {
    z-index: 10001 !important;
}

/* Radio and checkbox option groups */
.admin-action-modal .radio-options,
.admin-action-modal .checkbox-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.admin-action-modal .radio-option,
.admin-action-modal .checkbox-option {
    display: flex;
    align-items: flex-start;
    padding: 10px 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.admin-action-modal .radio-option:hover,
.admin-action-modal .checkbox-option:hover {
    background: #f0f0f0;
    border-color: #417690;
}

.admin-action-modal .radio-option input[type="radio"],
.admin-action-modal .checkbox-option input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
}

.admin-action-modal .option-content {
    flex: 1;
}

.admin-action-modal .option-label {
    font-weight: 600;
    color: #333;
    display: block;
}

.admin-action-modal .option-description {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Selected state */
.admin-action-modal .radio-option.selected,
.admin-action-modal .checkbox-option.selected {
    background: #e8f4f8;
    border-color: #417690;
}

/* Option group label */
.admin-action-modal .option-group-label {
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

/* Option group sections */
.admin-action-modal .option-section {
    margin-bottom: 20px;
}

.admin-action-modal .option-section:last-child {
    margin-bottom: 0;
}

.admin-action-modal .option-section-title {
    font-weight: bold;
    font-size: 13px;
    color: #417690;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #ddd;
}

/* Loading overlay */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
}

.modal-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #417690;
    border-radius: 50%;
    animation: modal-spin 0.8s linear infinite;
}

@keyframes modal-spin {
    to { transform: rotate(360deg); }
}

/* Result popup styling */
.result-popup {
    max-width: 500px;
}

.result-popup .modal-header {
    display: flex;
    align-items: center;
}

.result-popup .modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
}

.result-icon.success {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.result-icon.error {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.result-success .modal-header {
    background: #28a745;
}

.result-error .modal-header {
    background: #dc3545;
}

.result-message {
    line-height: 1.6;
}

.result-message a {
    color: #417690;
    text-decoration: underline;
}

.result-message a:hover {
    color: #205067;
}
