/**
 * Modern Modal UI Styles
 * Clean, professional modal styling for Bootstrap 4
 * Applied globally across all admin panel modals
 */

/* ═══════════════════════════════════════════════
   MODAL STRUCTURE
   ═══════════════════════════════════════════════ */

.modal-content {
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.16);
}

.modal-header {
    background: #fff;
    border-bottom: 1px solid #e8ecf0;
    padding: 20px 24px 16px;
    border-radius: 10px 10px 0 0;
}

.modal-header .modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1a2332;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header .close {
    font-size: 1.4rem;
    color: #6c7a8d;
    opacity: 1;
    padding: 0;
    margin: 0;
    font-weight: 300;
    text-shadow: none;
}

.modal-header .close:hover {
    color: #1a2332;
    opacity: 1;
}

.modal-body {
    padding: 24px;
    background: #f7f9fb;
}

.modal-footer {
    background: #fff;
    border-top: 1px solid #e8ecf0;
    padding: 16px 24px;
    border-radius: 0 0 10px 10px;
}

/* ═══════════════════════════════════════════════
   FORM CONTROLS INSIDE MODALS
   ═══════════════════════════════════════════════ */

.modal-body .form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px;
    display: block;
}

.modal-body .form-control {
    background: #fff;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    font-size: 0.88rem;
    color: #1a2332;
    height: 40px;
    padding: 8px 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-body .form-control:focus {
    border-color: var(--theme-color, #3b6cb7);
    box-shadow: 0 0 0 3px rgba(59, 108, 183, 0.12);
    outline: none;
    background: #fff;
}

.modal-body textarea.form-control {
    height: auto;
    min-height: 80px;
}

.modal-body select.form-control {
    appearance: auto;
    background-image: none;
}

.modal-body .form-control::placeholder {
    color: #adb5bd;
    opacity: 1;
}

.modal-body .form-control:disabled,
.modal-body .form-control[readonly] {
    background-color: #f1f3f5;
    opacity: 0.7;
}

/* ═══════════════════════════════════════════════
   CHECKBOXES & RADIOS
   ═══════════════════════════════════════════════ */

.modal-body .form-check-label {
    font-size: 0.85rem;
    color: #4a5568;
    cursor: pointer;
    font-weight: 500;
}

.modal-body .form-check-input {
    margin-top: 3px;
    cursor: pointer;
}

.modal-body .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(59, 108, 183, 0.12);
}

/* ═══════════════════════════════════════════════
   MODAL SECTIONS (GROUPED CONTENT)
   ═══════════════════════════════════════════════ */

.modal-section {
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 16px;
}

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

.modal-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c7a8d;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-section-title i {
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════
   BUTTONS IN MODALS
   ═══════════════════════════════════════════════ */

.modal-footer .btn {
    padding: 9px 22px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-footer .btn-primary,
.modal-footer .btn-theme {
    background: var(--theme-color, #3b6cb7);
    border-color: var(--theme-color, #3b6cb7);
    color: #fff;
}

.modal-footer .btn-primary:hover,
.modal-footer .btn-theme:hover {
    filter: brightness(1.08);
    color: #fff;
    border-color: var(--theme-color, #3b6cb7);
}

.modal-footer .btn-secondary {
    background: #e8ecf0;
    border-color: #e8ecf0;
    color: #4a5568;
}

.modal-footer .btn-secondary:hover {
    background: #d1d9e0;
    border-color: #d1d9e0;
    color: #4a5568;
}

.modal-footer .btn-danger {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.modal-footer .btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.modal-footer .btn-success {
    background: #28a745;
    border-color: #28a745;
    color: #fff;
}

.modal-footer .btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

/* ═══════════════════════════════════════════════
   INPUT GROUPS
   ═══════════════════════════════════════════════ */

.modal-body .input-group .input-group-text {
    background: #f7f9fb;
    border: 1px solid #d1d9e0;
    color: #6c7a8d;
    font-size: 0.85rem;
}

.modal-body .input-group .form-control:focus ~ .input-group-append .input-group-text,
.modal-body .input-group .form-control:focus ~ .input-group-prepend .input-group-text {
    border-color: var(--theme-color, #3b6cb7);
}

/* ═══════════════════════════════════════════════
   ALERTS IN MODALS
   ═══════════════════════════════════════════════ */

.modal-body .alert {
    border-radius: 6px;
    border: none;
    font-size: 0.85rem;
    padding: 12px 16px;
}

.modal-body .alert-info {
    background: #e8f4fd;
    color: #0c5460;
}

.modal-body .alert-warning {
    background: #fff3cd;
    color: #856404;
}

.modal-body .alert-danger {
    background: #f8d7da;
    color: #721c24;
}

.modal-body .alert-success {
    background: #d4edda;
    color: #155724;
}

/* ═══════════════════════════════════════════════
   TABLES IN MODALS
   ═══════════════════════════════════════════════ */

.modal-body .table {
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
}

.modal-body .table thead th {
    background: #f7f9fb;
    border-bottom: 2px solid #e8ecf0;
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 12px 16px;
}

.modal-body .table tbody td {
    padding: 12px 16px;
    font-size: 0.88rem;
    color: #1a2332;
    border-bottom: 1px solid #f1f3f5;
}

.modal-body .table tbody tr:last-child td {
    border-bottom: none;
}

/* ═══════════════════════════════════════════════
   FILE INPUTS
   ═══════════════════════════════════════════════ */

.modal-body .custom-file-label {
    background: #fff;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    color: #6c7a8d;
    font-size: 0.88rem;
    height: 40px;
    padding: 8px 12px;
}

.modal-body .custom-file-label::after {
    background: #f7f9fb;
    border-left: 1px solid #d1d9e0;
    color: #4a5568;
    height: 38px;
    padding: 8px 12px;
}

.modal-body .custom-file-input:focus ~ .custom-file-label {
    border-color: var(--theme-color, #3b6cb7);
    box-shadow: 0 0 0 3px rgba(59, 108, 183, 0.12);
}

/* ═══════════════════════════════════════════════
   BADGES IN MODALS
   ═══════════════════════════════════════════════ */

.modal-body .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ═══════════════════════════════════════════════
   HELP TEXT
   ═══════════════════════════════════════════════ */

.modal-body .form-text,
.modal-body small.text-muted {
    font-size: 0.78rem;
    color: #6c7a8d;
    margin-top: 4px;
    display: block;
}

/* ═══════════════════════════════════════════════
   REQUIRED FIELD INDICATOR
   ═══════════════════════════════════════════════ */

.modal-body .form-group label .text-danger {
    color: #dc3545;
    font-weight: 700;
}

/* ═══════════════════════════════════════════════
   MODAL SIZES
   ═══════════════════════════════════════════════ */

.modal-sm .modal-content {
    border-radius: 8px;
}

.modal-lg .modal-content,
.modal-xl .modal-content {
    border-radius: 12px;
}

/* ═══════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════ */

.modal-body.loading {
    position: relative;
    min-height: 200px;
}

.modal-body.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════ */

@media (max-width: 576px) {
    .modal-header {
        padding: 16px 20px 12px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 12px 20px;
    }
    
    .modal-footer .btn {
        padding: 8px 18px;
        font-size: 0.85rem;
    }
}

/* ═══════════════════════════════════════════════
   DARK MODE SUPPORT (OPTIONAL)
   ═══════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    body.dark-mode .modal-content {
        background: #1a2332;
    }
    
    body.dark-mode .modal-header {
        background: #1a2332;
        border-bottom-color: #2d3748;
    }
    
    body.dark-mode .modal-header .modal-title {
        color: #f7f9fb;
    }
    
    body.dark-mode .modal-header .close {
        color: #adb5bd;
    }
    
    body.dark-mode .modal-body {
        background: #0f1419;
    }
    
    body.dark-mode .modal-footer {
        background: #1a2332;
        border-top-color: #2d3748;
    }
    
    body.dark-mode .modal-section {
        background: #1a2332;
        border-color: #2d3748;
    }
    
    body.dark-mode .modal-body .form-control {
        background: #1a2332;
        border-color: #2d3748;
        color: #f7f9fb;
    }
    
    body.dark-mode .modal-body .form-control:focus {
        background: #1a2332;
        border-color: var(--theme-color, #3b6cb7);
    }
}

/* ═══════════════════════════════════════════════
   ANIMATION ENHANCEMENTS
   ═══════════════════════════════════════════════ */

.modal.fade .modal-dialog {
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

.modal.show .modal-dialog {
    transform: none;
}

/* ═══════════════════════════════════════════════
   ACCESSIBILITY IMPROVEMENTS
   ═══════════════════════════════════════════════ */

.modal-body .form-control:focus-visible {
    outline: 2px solid var(--theme-color, #3b6cb7);
    outline-offset: 2px;
}

.modal-header .close:focus {
    outline: 2px solid var(--theme-color, #3b6cb7);
    outline-offset: 2px;
}
