/* ====================================
   Professional Modal Enhancement Styles
   ==================================== */

/* Modal Container & Backdrop */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal {
    z-index: 1055;
}

.modal.fade .modal-dialog {
    transform: scale(0.8) translateY(-50px);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Modal Content - Base Styling */
.modal-content {
    border: none;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal Header - Premium Design */
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.75rem 2rem;
    border: none;
    position: relative;
    overflow: hidden;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, -30px); }
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 50%, #ffd140 100%);
    background-size: 200% 100%;
    animation: gradientMove 3s linear infinite;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Alternative Header Colors */
.modal-header.bg-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.modal-header.bg-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
}

.modal-header.bg-warning {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
}

.modal-header.bg-info {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
}

.modal-header.bg-dark {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

/* Modal Title Enhancement */
.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modal-title i {
    font-size: 1.75rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Animated Icons */
.modal-title i.bi-robot,
.modal-title i.fa-robot {
    animation: robotBounce 2s infinite;
}

@keyframes robotBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.modal-title i.bi-check-circle,
.modal-title i.fa-check-circle {
    animation: checkPulse 1.5s infinite;
}

@keyframes checkPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Modal Body - Clean & Spacious */
.modal-body {
    padding: 2rem;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fc 100%);
    max-height: 70vh;
    overflow-y: auto;
}

/* Custom Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Modal Footer */
.modal-footer {
    padding: 1.5rem 2rem;
    background: white;
    border-top: 2px solid #e9ecef;
    display: flex;
    gap: 0.75rem;
}

/* Enhanced Form Controls */
.modal-body .form-control,
.modal-body .form-select {
    border: 2px solid #e3e6f0;
    border-radius: 12px;
    padding: 0.875rem 1.25rem;
    transition: all 0.3s ease;
    background: white;
    font-size: 0.95rem;
}
.form-select,
select {
    width: 100%;
    min-width: 280px;
    max-width: 100%;
    height: 2.6rem;
    line-height: 2.4rem;
    padding: 0 0.75rem;
    font-size: 0.95rem;
    color: #1f2937; /* ensure selected text is visible */
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='%23667eea' d='M5.25 7.5L10 12.25 14.75 7.5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 0.75rem center; /* RTL will override */
    background-size: 18px;
}

.form-select:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.15);
}

/* Ensure options render with visible text */
select option {
    color: #111827;
    background-color: #fff;
}

/* Compact variant for tight spaces */
.form-select.form-select-sm,
select.form-select-sm {
    height: 2.2rem;
    line-height: 2.1rem;
    font-size: 0.9rem;
}

/* RTL support: move chevron to the right */
[dir="rtl"] .form-select,
[dir="rtl"] select {
    background-position: right 0.75rem center;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.15);
    background: white;
    transform: translateY(-1px);
}

.modal-body .form-control:hover,
.modal-body .form-select:hover {
    border-color: #a5b4fc;
}

.modal-body textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* Form Labels */
.modal-body .form-label {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body .form-label i {
    color: #667eea;
}

.modal-body .form-label .text-danger {
    color: #ef4444 !important;
    font-size: 1.1rem;
}

/* Form Text & Hints */
.modal-body .form-text,
.modal-body .text-muted {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.modal-body .form-text i {
    font-size: 0.9rem;
}

/* Tab Navigation in Modals */
.modal-body .nav-tabs {
    border-bottom: 3px solid #e9ecef;
    margin-bottom: 2rem;
    margin-top: -0.5rem;
}

.modal-body .nav-tabs .nav-link {
    border: none;
    color: #6c757d;
    padding: 1rem 1.75rem;
    font-weight: 600;
    position: relative;
    transition: all 0.3s ease;
    border-radius: 10px 10px 0 0;
}

.modal-body .nav-tabs .nav-link:hover {
    color: #667eea;
    background: #f8f9fc;
}

.modal-body .nav-tabs .nav-link.active {
    color: #667eea;
    background: transparent;
    border: none;
}

.modal-body .nav-tabs .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px 3px 0 0;
}

.modal-body .nav-tabs .nav-link i {
    margin-left: 0.5rem;
}

/* Tab Content */
.modal-body .tab-content {
    animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Enhanced Buttons */
.modal-footer .btn,
.modal-body .btn {
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
}

.modal-footer .btn::before,
.modal-body .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.modal-footer .btn:hover::before,
.modal-body .btn:hover::before {
    width: 300px;
    height: 300px;
}

.modal-footer .btn-primary,
.modal-body .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.modal-footer .btn-primary:hover,
.modal-body .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.45);
}

.modal-footer .btn-success,
.modal-body .btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 4px 15px rgba(56, 239, 125, 0.35);
}

.modal-footer .btn-success:hover,
.modal-body .btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(56, 239, 125, 0.45);
}

.modal-footer .btn-danger,
.modal-body .btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    box-shadow: 0 4px 15px rgba(235, 51, 73, 0.35);
}

.modal-footer .btn-warning,
.modal-body .btn-warning {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
    box-shadow: 0 4px 15px rgba(242, 153, 74, 0.35);
}

.modal-footer .btn-info,
.modal-body .btn-info {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.35);
}

.modal-footer .btn-secondary,
.modal-body .btn-secondary {
    background: #6c757d;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.25);
}

.modal-footer .btn-secondary:hover,
.modal-body .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.35);
}

/* Close Button Enhancement */
.btn-close {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    opacity: 1;
    transition: all 0.3s ease;
    padding: 0.5rem;
    width: 2.75rem;
    height: 2.75rem;
    position: relative;
    z-index: 2;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.45);
    transform: rotate(90deg) scale(1.1);
}

.btn-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Form Check Enhancement */
.modal-body .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.modal-body .form-check-input:checked {
    background-color: #667eea;
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.15);
}

.modal-body .form-check-input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
    background-size: 80%;
}

.modal-body .form-switch .form-check-input {
    width: 3rem;
    height: 1.6rem;
    border-radius: 2rem;
    background-color: #e5e7eb;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: left center;
}

.modal-body .form-switch .form-check-input:checked {
    background-position: right center;
}

.modal-body .form-check-input[type="radio"] {
    border-radius: 50%;
}

.modal-body .form-check-input[type="radio"]:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-size: 100%;
}

.modal-body .form-check-label {
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

/* Alert Enhancements in Modal */
.modal-body .alert {
    border: none;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid;
    animation: slideInRight 0.4s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.modal-body .alert-info {
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    border-left-color: #0ea5e9;
    color: #075985;
}

.modal-body .alert-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-left-color: #10b981;
    color: #065f46;
}

.modal-body .alert-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left-color: #f59e0b;
    color: #92400e;
}

.modal-body .alert-danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-left-color: #ef4444;
    color: #991b1b;
}

/* Badge Enhancement */
.modal-body .badge {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Input Group Enhancement */
.modal-body .input-group {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.modal-body .input-group-text {
    background: linear-gradient(135deg, #f8f9fc 0%, #e9ecef 100%);
    border: 2px solid #e3e6f0;
    color: #667eea;
    font-weight: 600;
}

/* Loading Spinner */
.modal-body .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .modal-content {
        border-radius: 16px 16px 0 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 1.25rem 1.5rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-footer {
        padding: 1rem 1.5rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #1e293b;
        color: #f1f5f9;
    }
    
    .modal-body {
        background: linear-gradient(to bottom, #1e293b 0%, #0f172a 100%);
    }
    
    .modal-body .form-control,
    .modal-body .form-select {
        background: #334155;
        border-color: #475569;
        color: #f1f5f9;
    }
    
    .modal-footer {
        background: #1e293b;
        border-top-color: #334155;
    }
}

/* Print Styles */
@media print {
    .modal-backdrop,
    .btn-close {
        display: none !important;
    }
    
    .modal-content {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
