/* ==========================================
   PREMIUM MODAL SYSTEM STYLES
   ========================================== */

/* 1. Base Modal State (Hidden) */
.modal {
    display: none !important;
    /* Force hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;

    /* Premium Backdrop */
    background: rgba(15, 23, 42, 0.4);
    /* Dark blue-grey tint */
    backdrop-filter: blur(8px);
    /* Glass effect */
    -webkit-backdrop-filter: blur(8px);

    /* Animation states */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Active Modal State (Visible) */
.modal.modal-active,
.modal.show {
    /* Support both legacy and new classes */
    display: flex !important;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
}

/* 3. Modal Content Card */
.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 500px;
    /* Optimal reading width */
    max-height: 85vh;
    overflow-y: auto;
    position: relative;

    /* Modern Card Layout */
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.02);
    /* Subtle contour */

    /* Transformation Animation */
    transform: scale(0.92) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy pop effect */
}

/* Pop-up animation when active */
.modal.modal-active .modal-content,
.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

/* 4. Modal Header */
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(4px);
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.025em;
}

/* Close Button */
.modal-close {
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg);
}

/* 5. Modal Body */
.modal-body {
    padding: 1.5rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
}

/* Premium Inputs */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #1e293b;
    transition: all 0.2s ease;
    background: #f8fafc;
}

.form-input:focus {
    outline: none;
    background: #ffffff;
    border-color: #3b82f6;
    /* Primary brand color */
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
    color: #94a3b8;
}

/* 6. Form Actions */
.form-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Button Styling (overrides for modals) */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 12px -1px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}

/* Scrollbar styling for modal content */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
}

/* Ensure no clicking outside active modal */
.modal:not(.modal-active):not(.show) {
    pointer-events: none;
}