/* ===============================================
   Modern Modal Styles - UniPlain Admin
   =============================================== */

/* Base Modal Overlay */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.5));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease-out;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Container */
.modal-content {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 20px;
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 20px 40px -20px rgba(0, 0, 0, 0.15);
    margin: auto;
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: center;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px 20px 0 0;
    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 linear infinite;
}

@keyframes shimmer {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

/* Close Button */
.close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 20px;
    font-weight: 300;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.close:active {
    transform: scale(0.95) rotate(90deg);
}

/* Modal Body */
.modal-body {
    padding: 28px;
    max-height: calc(90vh - 180px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46a0);
}

/* Modal Footer */
.modal-footer {
    padding: 20px 28px;
    background: linear-gradient(to top, #f8f9fa, #ffffff);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-radius: 0 0 20px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Form Styles within Modal */
.modal form {
    margin: 0;
}

.modal .form-section {
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.modal .form-section h3,
.modal .form-section h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

/* Modal subtitle style for smaller text */
.modal .modal-subtitle {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 16px;
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.modal .form-group label .required {
    color: #e74c3c;
    margin-left: 2px;
}

.modal .form-group input[type="text"],
.modal .form-group input[type="email"],
.modal .form-group input[type="tel"],
.modal .form-group input[type="url"],
.modal .form-group input[type="number"],
.modal .form-group input[type="date"],
.modal .form-group input[type="datetime-local"],
.modal .form-group select,
.modal .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    box-sizing: border-box;
}

.modal .form-group input:focus,
.modal .form-group select:focus,
.modal .form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.modal .form-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.modal .form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.modal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modal .form-row .form-group {
    margin-bottom: 0;
}

.modal .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

/* Modal Buttons */
.modal .btn-primary,
.modal .btn-secondary,
.modal .btn-danger,
.modal button[type="submit"] {
    padding: 10px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.modal .btn-primary,
.modal button[type="submit"] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.modal .btn-primary:hover,
.modal button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.modal .btn-primary:active,
.modal button[type="submit"]:active {
    transform: translateY(0);
}

.modal .btn-secondary {
    background: white;
    color: #495057;
    border: 2px solid #e0e0e0;
}

.modal .btn-secondary:hover {
    background: #f8f9fa;
    border-color: #d0d0d0;
    transform: translateY(-2px);
}

.modal .btn-danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.modal .btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

/* Specific Modal Styles */

/* Announcement Modal */
.announcement-modal {
    max-width: 650px;
}

.announcement-modal .modal-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Banner Modal */
.banner-modal {
    max-width: 700px;
}

.banner-modal .modal-header {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* Inquiry Modal */
.inquiry-modal {
    max-width: 750px;
}

.inquiry-modal .modal-header {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.inquiry-modal .modal-header h2,
.inquiry-modal .modal-header h3 {
    color: #495057;
}

.inquiry-modal .close {
    color: #495057;
    background: rgba(0, 0, 0, 0.1);
}

/* Department Modal */
#departmentModal .modal-content,
#departmentInfoModal .modal-content {
    max-width: 900px;
}

#departmentModal .modal-header,
#departmentInfoModal .modal-header {
    background: linear-gradient(135deg, #3f5efb 0%, #fc466b 100%);
}

/* Schedule Modal */
#scheduleModal .modal-content {
    max-width: 800px;
}

#scheduleModal .modal-header {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* University Modal */
#universityModal .modal-content {
    max-width: 750px;
}

#universityModal .modal-header {
    background: linear-gradient(135deg, #ee9ca7 0%, #ffdde1 100%);
}

#universityModal .modal-header h2 {
    color: #495057;
}

#universityModal .close {
    color: #495057;
    background: rgba(0, 0, 0, 0.1);
}

/* Modal Size Variations */
.modal-content.modal-lg {
    max-width: 900px;
}

.modal-content.modal-xl {
    max-width: 1200px;
}

.modal-content.modal-sm {
    max-width: 500px;
}

/* Modal Loading State */
.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #6c757d;
}

.modal-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f0f0f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Modal Error State */
.modal-error {
    padding: 40px;
    text-align: center;
    color: #dc3545;
}

.modal-error h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
}

/* Modal Success Message */
.modal-success {
    padding: 20px;
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    border-radius: 12px;
    color: white;
    text-align: center;
    margin-bottom: 20px;
}

/* Special Effects for Important Modals */
.modal-content.modal-important {
    animation: importantPulse 0.5s ease-out;
}

@keyframes importantPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 95vh;
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 20px;
        border-radius: 16px 16px 0 0;
    }
    
    .modal-header h2,
    .modal-header h3 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 20px;
        max-height: calc(95vh - 160px);
    }
    
    .modal-footer {
        padding: 16px 20px;
        flex-direction: column-reverse;
        gap: 10px;
        border-radius: 0 0 16px 16px;
    }
    
    .modal .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal .btn-primary,
    .modal .btn-secondary,
    .modal .btn-danger,
    .modal button[type="submit"] {
        width: 100%;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .modal-header {
        border-radius: 0;
    }
    
    .modal-body {
        max-height: calc(100vh - 140px);
    }
    
    .modal-footer {
        border-radius: 0;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    }
    
    .modal .form-section {
        background: #2a2a2a;
    }
    
    .modal .form-group input,
    .modal .form-group select,
    .modal .form-group textarea {
        background: #1a1a1a;
        border-color: #3a3a3a;
        color: #e0e0e0;
    }
    
    .modal .form-group label {
        color: #b0b0b0;
    }
    
    .modal .btn-secondary {
        background: #2a2a2a;
        color: #e0e0e0;
        border-color: #3a3a3a;
    }
}

/* Animation Classes */
.modal.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.modal-content.slide-out {
    animation: modalSlideOut 0.3s ease-in forwards;
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
}