/* ============================================
   jQuery Modal Plugin - FCDesign Theme
   Compatible with jquery.modal.js v0.9.1
   ============================================ */

/* Modal Blocker (Overlay/Backdrop) */
.jquery-modal.blocker {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1050;
    overflow: auto;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Dark theme blocker */
[data-theme="dark"] .jquery-modal.blocker {
    background: rgba(0, 0, 0, 0.85);
}

/* Blocker states */
.jquery-modal.blocker.behind {
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
}

.jquery-modal.blocker.current {
    z-index: 1050;
}

/* Modal Container */
.modal {
    display: none;
    position: relative;
    background: var(--bg-card, #FFFFFF);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 100%;
    margin: auto;
    padding: 0;
    text-align: left;
    z-index: 1051;
    animation: modalSlideIn 0.3s ease-out;
}

/* Dark theme modal */
[data-theme="dark"] .modal {
    background: #1E293B;
    color: #E2E8F0;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
}

/* Modal sizes */
.modal.small {
    max-width: 400px;
}

.modal.medium {
    max-width: 600px;
}

.modal.large {
    max-width: 900px;
}

.modal.xlarge {
    max-width: 1200px;
}

/* Modal Header */
.modal-header {
    background: linear-gradient(135deg, var(--brand-primary, #4A90E2) 0%, var(--brand-secondary, #5BA3F5) 100%);
    color: #FFFFFF;
    padding: 24px 30px;
    border-radius: 16px 16px 0 0;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Dark theme modal header */
[data-theme="dark"] .modal-header {
    background: linear-gradient(135deg, #4A90E2 0%, #5BA3F5 100%);
}

/* Modal Body */
.modal-body {
    padding: 30px;
    max-height: calc(90vh - 200px);
    overflow-y: auto;
    color: var(--text-primary, #1E293B);
}

/* Dark theme modal body */
[data-theme="dark"] .modal-body {
    color: #E2E8F0;
}

/* Modal body scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-muted, #F1F5F9);
    border-radius: 4px;
}

[data-theme="dark"] .modal-body::-webkit-scrollbar-track {
    background: #334155;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-primary, #CBD5E1);
    border-radius: 4px;
}

[data-theme="dark"] .modal-body::-webkit-scrollbar-thumb {
    background: #475569;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary, #4A90E2);
}

/* Modal Footer */
.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-primary, #E2E8F0);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    border-radius: 0 0 16px 16px;
    background: var(--bg-secondary, #F8FAFC);
}

/* Dark theme modal footer */
[data-theme="dark"] .modal-footer {
    border-top-color: #334155;
    background: #0F172A;
}

.modal-footer .left {
    margin-right: auto;
}

.modal-footer .right {
    display: flex;
    gap: 12px;
}

/* Close Button (X) */
.close-modal,
a[rel="modal:close"].close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #FFFFFF;
    text-align: center;
    line-height: 34px;
    font-size: 18px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.close-modal:hover,
a[rel="modal:close"].close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    text-decoration: none;
}

.close-modal::before {
    content: "\f00d";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
}

/* Modal Buttons */
.modal .bttn,
.modal button.bttn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 120px;
}

.modal .bttn:not(.cancel) {
    background: linear-gradient(135deg, #4A90E2 0%, #5BA3F5 100%);
    color: #FFFFFF;
    border-color: #3B82F6;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
}

.modal .bttn:not(.cancel):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.5);
}

.modal .bttn.cancel,
.modal a[rel="modal:close"] {
    background: linear-gradient(135deg, #64748B 0%, #475569 100%);
    color: #FFFFFF;
    border-color: #94A3B8;
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.3);
}

.modal .bttn.cancel:hover,
.modal a[rel="modal:close"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 116, 139, 0.4);
    text-decoration: none;
}

/* Modal Spinner (Loading) */
.modal-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1052;
}

.modal-spinner > div {
    background-color: #4A90E2;
    height: 40px;
    width: 6px;
    margin: 0 2px;
    display: inline-block;
    animation: sk-stretchdelay 1.2s infinite ease-in-out;
}

.modal-spinner .rect2 {
    animation-delay: -1.1s;
}

.modal-spinner .rect3 {
    animation-delay: -1.0s;
}

.modal-spinner .rect4 {
    animation-delay: -0.9s;
}

@keyframes sk-stretchdelay {
    0%, 40%, 100% {
        transform: scaleY(0.4);
    }
    20% {
        transform: scaleY(1.0);
    }
}

/* Modal Animations */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .jquery-modal.blocker {
        padding: 10px;
    }

    .modal {
        max-width: 95vw !important;
        border-radius: 12px;
    }

    .modal-header {
        padding: 20px;
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 20px;
        max-height: calc(90vh - 160px);
    }

    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
        gap: 10px;
    }

    .modal-footer .left,
    .modal-footer .right {
        width: 100%;
        margin: 0;
    }

    .modal-footer .right {
        flex-direction: column;
    }

    .modal .bttn,
    .modal button.bttn {
        width: 100%;
    }

    .close-modal,
    a[rel="modal:close"].close-modal {
        top: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
        line-height: 30px;
        font-size: 16px;
    }
}

/* Client-specific modal styles (from existing code) */
.client-left_modal {
    width: 100%;
}

.client-left_modal .form-row {
    margin-bottom: 20px;
}

.client-left_modal label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary, #1E293B);
}

[data-theme="dark"] .client-left_modal label {
    color: #E2E8F0;
}

.client-left_modal .input-row {
    position: relative;
}

.client-left_modal .input-row i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #64748B);
}

.client-left_modal input,
.client-left_modal select,
.client-left_modal textarea {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border-primary, #E2E8F0);
    border-radius: 8px;
    background: var(--bg-tertiary, #F8FAFC);
    color: var(--text-primary, #1E293B);
    font-size: 14px;
}

[data-theme="dark"] .client-left_modal input,
[data-theme="dark"] .client-left_modal select,
[data-theme="dark"] .client-left_modal textarea {
    background: #334155;
    border-color: #475569;
    color: #E2E8F0;
}

.client-left_modal input:focus,
.client-left_modal select:focus,
.client-left_modal textarea:focus {
    outline: none;
    border-color: var(--brand-primary, #4A90E2);
    background: var(--bg-card, #FFFFFF);
}

[data-theme="dark"] .client-left_modal input:focus,
[data-theme="dark"] .client-left_modal select:focus,
[data-theme="dark"] .client-left_modal textarea:focus {
    background: #1E293B;
}

/* Make modal visible when opened */
.modal.is-visible,
.blocker .modal {
    display: block;
}
