/**
 * Bootstrap Modal Enhancements
 * Premium Modern UI for all Bootstrap Modals
 */

/* Enhanced Modal Backdrop - Screenshot Style */
.modal-backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-backdrop.show {
    opacity: 1;
}

.modal-backdrop.fade {
    opacity: 0;
}

/* Enhanced Modal Dialog */
.modal {
    z-index: 1055;
}

.modal-dialog {
    margin: 1.75rem auto;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.fade .modal-dialog {
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    opacity: 0;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Premium Modal Content - Screenshot Style */
.modal-content {
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    border: none;
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.6), 
        rgba(255, 255, 255, 0.9),
        rgba(255, 255, 255, 0.6),
        transparent
    );
    pointer-events: none;
    z-index: 1;
}

.modal-content::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
    pointer-events: none;
    animation: modalPulseGlow 4s ease-in-out infinite;
}

@keyframes modalPulseGlow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* Enhanced Modal Header - Screenshot Style */
.modal-header {
    padding: 40px 32px 28px 32px;
    border-bottom: none;
    background: transparent;
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: #1a1a1a;
    letter-spacing: -0.02em;
    margin: 0;
    text-align: center;
}

/* Icon Container for Bootstrap Modals */
.modal-header .icon-container,
.modal-body .icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header .icon-container .icon,
.modal-body .icon-container .icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    box-shadow: 
        0 8px 20px rgba(59, 130, 246, 0.2),
        0 0 0 1px rgba(59, 130, 246, 0.1) inset;
}

.modal-header .icon-container .icon i,
.modal-body .icon-container .icon i {
    font-size: 36px;
    color: #3b82f6;
}

/* Success Icon */
.modal-header .icon-container .icon.bg-success,
.modal-body .icon-container .icon.bg-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.08));
    box-shadow: 
        0 8px 20px rgba(16, 185, 129, 0.2),
        0 0 0 1px rgba(16, 185, 129, 0.1) inset;
}

.modal-header .icon-container .icon.bg-success i,
.modal-body .icon-container .icon.bg-success i {
    color: #10b981;
}

/* Error/Danger Icon */
.modal-header .icon-container .icon.bg-danger,
.modal-body .icon-container .icon.bg-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
    box-shadow: 
        0 8px 20px rgba(239, 68, 68, 0.2),
        0 0 0 1px rgba(239, 68, 68, 0.1) inset;
}

.modal-header .icon-container .icon.bg-danger i,
.modal-body .icon-container .icon.bg-danger i {
    color: #ef4444;
}

/* Warning Icon */
.modal-header .icon-container .icon.bg-warning,
.modal-body .icon-container .icon.bg-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.08));
    box-shadow: 
        0 8px 20px rgba(245, 158, 11, 0.2),
        0 0 0 1px rgba(245, 158, 11, 0.1) inset;
}

.modal-header .icon-container .icon.bg-warning i,
.modal-body .icon-container .icon.bg-warning i {
    color: #f59e0b;
}

/* Enhanced Close Button - Screenshot Style */
.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(241, 245, 249, 0.8);
    opacity: 0.7;
    transition: all 0.25s ease;
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 0;
    margin: 0;
    border: none;
}

.btn-close::before {
    content: '×';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    line-height: 1;
    color: #666666;
    font-weight: 300;
}

.btn-close:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

.btn-close:hover::before {
    color: #ef4444;
}

.btn-close:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
    outline: none;
}

/* Enhanced Modal Body - Screenshot Style */
.modal-body {
    padding: 0 32px 24px 32px;
    position: relative;
    z-index: 2;
    color: #666666;
    line-height: 1.6;
    text-align: center;
    font-size: 16px;
}

/* Center icons in modal body */
.modal-body .mb-2 {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px !important;
}

.modal-body .mb-2 i {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.08));
    box-shadow: 
        0 8px 20px rgba(59, 130, 246, 0.2),
        0 0 0 1px rgba(59, 130, 246, 0.1) inset;
    font-size: 36px;
    color: #3b82f6;
}

.modal-body .mb-2 i.text-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.08));
    box-shadow: 
        0 8px 20px rgba(16, 185, 129, 0.2),
        0 0 0 1px rgba(16, 185, 129, 0.1) inset;
    color: #10b981;
}

.modal-body .mb-2 i.text-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
    box-shadow: 
        0 8px 20px rgba(239, 68, 68, 0.2),
        0 0 0 1px rgba(239, 68, 68, 0.1) inset;
    color: #ef4444;
}

.modal-body .mb-2 i.text-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.08));
    box-shadow: 
        0 8px 20px rgba(245, 158, 11, 0.2),
        0 0 0 1px rgba(245, 158, 11, 0.1) inset;
    color: #f59e0b;
}

.modal-body h3 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: #1a1a1a;
    letter-spacing: -0.02em;
    margin: 0 0 12px 0;
}

/* Enhanced Modal Footer - Screenshot Style */
.modal-footer {
    padding: 0 32px 32px 32px;
    border-top: none;
    background: transparent;
    position: relative;
    z-index: 2;
    gap: 12px;
    display: flex;
    justify-content: space-between;
}

/* Enhanced Modal Buttons - Screenshot Style */
.modal-footer .btn,
.modal-body .btn {
    flex: 1;
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    border: none;
    min-height: 48px;
}

.modal-footer .btn-primary,
.modal-body .btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.modal-footer .btn-primary:hover,
.modal-body .btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.modal-footer .btn-primary:active,
.modal-body .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.modal-footer .btn-secondary,
.modal-body .btn-secondary,
.modal-footer .btn-outline-secondary,
.modal-body .btn-outline-secondary {
    background: transparent;
    color: #3b82f6;
    border: 1px solid transparent;
}

.modal-footer .btn-secondary:hover,
.modal-body .btn-secondary:hover,
.modal-footer .btn-outline-secondary:hover,
.modal-body .btn-outline-secondary:hover {
    background: rgba(59, 130, 246, 0.05);
    color: #2563eb;
}

.modal-footer .btn-secondary:active,
.modal-body .btn-secondary:active,
.modal-footer .btn-outline-secondary:active,
.modal-body .btn-outline-secondary:active {
    background: rgba(59, 130, 246, 0.1);
}

.modal-footer .btn:focus,
.modal-body .btn:focus {
    outline: none;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.3),
        0 6px 20px rgba(59, 130, 246, 0.4),
        0 2px 8px rgba(59, 130, 246, 0.3);
}

.modal-footer .btn-secondary:focus,
.modal-body .btn-secondary:focus,
.modal-footer .btn-outline-secondary:focus,
.modal-body .btn-outline-secondary:focus {
    box-shadow: 
        0 0 0 4px rgba(148, 163, 184, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Modal Status Bar (for type-based modals) */
.modal-status {
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    position: relative;
    z-index: 3;
}

.modal-status.bg-success {
    background: linear-gradient(90deg, #10b981, #059669);
}

.modal-status.bg-danger {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.modal-status.bg-warning {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.modal-status.bg-info {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 1rem;
    }

    .modal-content {
        border-radius: 20px;
    }

    .modal-header {
        padding: 24px 24px 20px 24px;
    }

    .modal-title {
        font-size: 22px;
    }

    .modal-body {
        padding: 24px 24px;
    }

    .modal-footer {
        padding: 20px 24px 28px 24px;
        flex-direction: column-reverse;
    }

    .modal-footer .btn,
    .modal-body .btn {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 16px;
    }

    .modal-header {
        padding: 20px 20px 16px 20px;
    }

    .modal-title {
        font-size: 20px;
    }

    .modal-body {
        padding: 20px 20px;
    }

    .modal-footer {
        padding: 16px 20px 24px 20px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .modal,
    .modal-dialog,
    .modal-content,
    .modal-backdrop,
    .modal-content::after,
    .btn-close,
    .modal-footer .btn,
    .modal-body .btn {
        transition: none;
        animation: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
        border-color: rgba(226, 232, 240, 0.1);
    }

    .modal-header {
        background: linear-gradient(to bottom, rgba(30, 41, 59, 0.5), transparent);
        border-bottom-color: rgba(226, 232, 240, 0.1);
    }

    /*
     * Do not use background-clip + transparent text-fill on .modal-title:
     * nested spans inherit transparent fill and become unreadable on light panels.
     */
    .modal-title {
        color: #f1f5f9;
        background: none;
        -webkit-background-clip: unset;
        background-clip: unset;
        -webkit-text-fill-color: #f1f5f9;
    }

    .modal-body {
        color: #cbd5e1;
    }

    .modal-footer {
        background: linear-gradient(to bottom, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
        border-top-color: rgba(226, 232, 240, 0.1);
    }

    .btn-close {
        background: rgba(30, 41, 59, 0.8);
        border-color: rgba(226, 232, 240, 0.1);
    }

    .btn-close::before {
        color: #cbd5e1;
    }
}

/* Light-panel modals: keep white chrome when OS prefers dark */
@media (prefers-color-scheme: dark) {
    #signupLoginModal .modal-content {
        background: linear-gradient(to bottom, #ffffff, #f8f9fa);
        border-color: rgba(255, 255, 255, 0.1);
    }

    #signupLoginModal .modal-header {
        background: transparent;
        border-bottom-color: transparent;
    }

    #signupLoginModal .modal-title {
        color: #0f172a;
        -webkit-text-fill-color: #0f172a;
    }

    #signupLoginModal .signup-login-welcome {
        color: #64748b !important;
        -webkit-text-fill-color: #64748b;
    }

    #signupLoginModal .signup-login-title {
        color: #0f172a !important;
        -webkit-text-fill-color: #0f172a;
    }

    #signupLoginModal .modal-body {
        color: #64748b;
    }

    #signupLoginModal .btn-close {
        background: rgba(241, 245, 249, 0.8);
        border: none;
    }

    #signupLoginModal .btn-close::before {
        color: #666666;
    }

    #applyNow .modal-content,
    #applyExternalJob .modal-content {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.08);
    }

    #applyNow .modal-header,
    #applyExternalJob .modal-header {
        background: #ffffff;
        border-bottom-color: #e9ecef;
    }

    #applyNow .modal-title,
    #applyNow .modal-title *,
    #applyExternalJob .modal-title,
    #applyExternalJob .modal-title * {
        color: #212529 !important;
        -webkit-text-fill-color: #212529;
        background: none;
        -webkit-background-clip: unset;
        background-clip: unset;
    }

    #applyNow .modal-body,
    #applyExternalJob .modal-body {
        background: #ffffff;
        color: #212529;
    }

    #applyNow .modal-footer,
    #applyExternalJob .modal-footer {
        background: #ffffff;
        border-top-color: #e9ecef;
    }

    #applyNow .btn-close,
    #applyExternalJob .btn-close {
        background: rgba(241, 245, 249, 0.8);
        border: none;
    }

    #applyNow .btn-close::before,
    #applyExternalJob .btn-close::before {
        color: #666666;
    }
}

/*
 * Jobzilla main.scss: .twm-sign-up / .twm-model-popup .modal-content beats flat .modal-content.
 * Match that specificity so enhancements actually apply.
 */
.twm-sign-up .modal-content,
.twm-model-popup .modal-content {
    background: linear-gradient(to bottom, #ffffff, #f8f9fa);
    border: none;
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    position: relative;
}

.twm-sign-up .modal-header,
.twm-model-popup .modal-header {
    border-bottom: none;
    background: transparent;
}

.twm-sign-up .modal-title,
.twm-model-popup .modal-title {
    color: #1a1a1a;
    -webkit-text-fill-color: #1a1a1a;
}

.twm-sign-up .modal-body,
.twm-model-popup .modal-body {
    color: #666666;
}

@media (prefers-color-scheme: dark) {
    .twm-sign-up .modal-content,
    .twm-model-popup .modal-content {
        background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
        border-color: rgba(226, 232, 240, 0.1);
    }

    .twm-sign-up .modal-title,
    .twm-model-popup .modal-title {
        color: #f1f5f9;
        -webkit-text-fill-color: #f1f5f9;
        background: none;
        -webkit-background-clip: unset;
        background-clip: unset;
    }

    .twm-sign-up .modal-body,
    .twm-model-popup .modal-body {
        color: #cbd5e1;
    }
}
