/**
 * Internationalized Modal System Styles
 * Provides modern, responsive modal styling with accessibility features
 */

/* Modal overlay - provides backdrop and centering */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: modalFadeIn 0.3s ease-out;
}

/* Modal container - the actual modal box */
.modal-container {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    min-width: 320px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalSlideUp 0.3s ease-out;
}

/* Modal header */
.modal-header {
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    color: white;
    padding: 24px 32px;
    border-radius: 20px 20px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Modal header variations for different types */
.modal-header.error-header {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.modal-header.warning-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.modal-header.success-header {
    background: linear-gradient(135deg, #10b981, #059669);
}

/* Close button */
.modal-close-button {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    font-size: 24px !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    font-weight: bold !important;
}

.modal-close-button:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.05);
}

.modal-close-button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Modal body */
.modal-body {
    padding: 32px;
    font-size: 16px;
    line-height: 1.6;
    color: white;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Input fields in modals */
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
    margin-top: 12px;
}

.modal-body input[type="text"]:focus,
.modal-body input[type="email"]:focus,
.modal-body input[type="password"]:focus,
.modal-body textarea:focus {
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
    background: rgba(255, 255, 255, 0.15);
}

.modal-body input[type="text"]::placeholder,
.modal-body input[type="email"]::placeholder,
.modal-body input[type="password"]::placeholder,
.modal-body textarea::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Modal footer */
.modal-footer {
    padding: 24px 32px;
    text-align: right;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 0 20px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

/* Modal buttons */
.modal-button {
    padding: 12px 24px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    border: none !important;
    min-width: 80px !important;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Primary button (OK, Yes, Confirm) */
.modal-button-primary {
    background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.modal-button-primary:hover {
    background: linear-gradient(135deg, #0891b2, #0e7490) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.4);
}

.modal-button-primary:focus {
    outline: 2px solid #06b6d4;
    outline-offset: 2px;
}

/* Secondary button (Cancel, No) */
.modal-button-secondary {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.modal-button-secondary:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    transform: translateY(-2px);
}

.modal-button-secondary:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Danger button (for destructive actions) */
.modal-button-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.modal-button-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
}

/* Animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Modal exit animation */
.modal-overlay.modal-closing {
    animation: modalFadeOut 0.2s ease-in forwards;
}

.modal-overlay.modal-closing .modal-container {
    animation: modalSlideDown 0.2s ease-in forwards;
}

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

@keyframes modalSlideDown {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }
    
    .modal-container {
        min-width: auto;
        width: 100%;
        max-width: none;
        margin: 0;
    }
    
    .modal-header {
        padding: 20px 24px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-body {
        padding: 24px;
        font-size: 15px;
    }
    
    .modal-footer {
        padding: 20px 24px;
        flex-direction: column;
    }
    
    .modal-button {
        width: 100% !important;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {
    .modal-container {
        border-radius: 15px;
    }
    
    .modal-header {
        border-radius: 15px 15px 0 0;
        padding: 16px 20px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 20px;
        font-size: 14px;
    }
    
    .modal-footer {
        padding: 16px 20px;
        border-radius: 0 0 15px 15px;
    }
    
    .modal-button {
        padding: 14px 20px !important;
        font-size: 15px !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modal-container {
        border: 2px solid white;
    }
    
    .modal-button-primary {
        background: #0066cc !important;
    }
    
    .modal-button-secondary {
        background: transparent !important;
        border: 2px solid white !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-container,
    .modal-button,
    .modal-close-button {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .modal-container {
        background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
    }
}

/* Focus management styles */
.modal-overlay:focus-within {
    /* Ensure modal stays focused */
}

/* Loading state for async operations */
.modal-loading {
    pointer-events: none;
}

.modal-loading .modal-button {
    opacity: 0.6;
    cursor: not-allowed !important;
}

.modal-loading .modal-button::after {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: modalButtonSpinner 0.8s linear infinite;
    margin-left: 8px;
}

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

/* RTL support */
[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

[dir="rtl"] .modal-close-button {
    margin-right: auto;
    margin-left: 0;
}