/* ===================== MODALS v6.0 — Stitch Design System ===================== */
/* Modal Overlays, Dialog Boxes, Admin Widget */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.25s ease;
}

.modal-overlay.hidden {
    display: none;
}

/* ---- Glass Modal Container ---- */
.modal-content {
    background: linear-gradient(145deg, rgba(24, 24, 27, 0.95) 0%, rgba(9, 9, 11, 0.9) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] .modal-content {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(241, 245, 249, 0.92));
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.12);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px 12px;
    border-bottom: none;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 8px 28px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---- Bento Import File Cards ---- */
#viewLocalImport .kpi-grid {
    gap: 14px;
}

#viewLocalImport .kpi-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 20px !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: default;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#viewLocalImport .kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.1);
}

/* File loaded — only the upload BUTTON turns green, card stays neutral */
#viewLocalImport .btn-file-loaded {
    background: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.25) !important;
    color: #10b981 !important;
    font-weight: 600 !important;
}

/* ---- Bento Close / Clear Buttons ---- */
.modal-close-bento {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.modal-close-bento img {
    display: block;
    filter: brightness(0) saturate(100%) invert(52%) sepia(89%) saturate(1467%) hue-rotate(331deg) brightness(99%) contrast(95%);
}

.modal-close-bento:hover {
    background: rgba(239, 68, 68, 0.15);
    transform: scale(1.08);
}

.modal-close-bento:hover img {
    filter: brightness(0) saturate(100%) invert(36%) sepia(92%) saturate(2157%) hue-rotate(345deg) brightness(98%) contrast(94%);
}

/* ---- Premium Analyze Button ---- */
.btn-analyze {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: none;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3), 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-analyze:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 28px rgba(59, 130, 246, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-analyze:active:not(:disabled) {
    transform: translateY(0);
}

.btn-analyze:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

/* Shimmer effect on hover */
.btn-analyze::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.5s ease;
}

.btn-analyze:hover:not(:disabled)::after {
    left: 120%;
}

/* ---- Light Theme Bento Overrides ---- */
[data-theme="light"] .modal-content {
    background: #f7f9fc;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04) inset;
}

[data-theme="light"] #viewLocalImport .kpi-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] #viewLocalImport .kpi-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] #viewLocalImport .kpi-card.file-loaded {
    background: rgba(16, 185, 129, 0.04);
    border-color: rgba(16, 185, 129, 0.12);
}

[data-theme="light"] .modal-close-bento {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.12);
}

[data-theme="light"] .modal-header {
    border-bottom: none;
}

[data-theme="light"] .modal-footer {
    border-top-color: rgba(0, 0, 0, 0.06);
}

/* ---- Animations ---- */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.92) translateY(16px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ---- ADMIN FLOATING WIDGET ---- */
.admin-floating-widget {
    position: fixed;
    bottom: 30px;
    left: 230px;
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: wipeUp 0.3s ease forwards;
}

.admin-floating-widget.active {
    display: flex;
}

.admin-widget-header {
    background: rgba(239, 68, 68, 0.05);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-close-widget {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
}

.btn-close-widget:hover {
    color: var(--text-primary);
}

.admin-widget-body {
    padding: 16px;
}

.widget-kpi {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
}

.widget-kpi .label {
    color: var(--text-dim);
}

.widget-kpi .val {
    font-weight: 600;
}

@keyframes wipeUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}