/* Structure Viewer 2.2 – Modals (File Viewer + Export) */

/* ============================================================
   FILE VIEWER MODAL
   ============================================================ */

/* Outer wrapper – always covers the screen when shown.
   The backdrop-blur lives here so it appears immediately. */
.sv-modal {
    position: fixed;
    inset: 0;
    z-index: 100100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Remove the child overlay – blur is now on .sv-modal itself */
.sv-modal-overlay {
    display: none;
}

.sv-modal-content {
    position: relative;
    background: var(--sv-surface);
    border: 1px solid var(--sv-border-2);
    border-radius: var(--sv-radius-lg);
    box-shadow: var(--sv-shadow-lg);
    width: 92%;
    max-width: 920px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    z-index: 100101;
    overflow: hidden;
}

/* Header  ─ file icon + name/path + action icons */
.sv-modal-header {
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--sv-border);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--sv-surface-2);
    flex-shrink: 0;
}

/* File type icon bubble */
.sv-modal-file-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--sv-accent), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 16px var(--sv-accent-glow);
}

.sv-modal-file-icon svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

/* Filename + path block */
.sv-modal-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#sv-file-viewer-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--sv-text);
    margin: 0;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sv-modal-file-path {
    font-size: 11.5px;
    color: var(--sv-text-3);
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action icons (top-right) */
.sv-modal-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sv-modal-action-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--sv-radius-sm);
    border: 1px solid var(--sv-border-2);
    background: var(--sv-surface-3);
    color: var(--sv-text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--sv-transition);
    padding: 0;
}

.sv-modal-action-btn svg {
    width: 15px;
    height: 15px;
}

.sv-modal-action-btn:hover {
    background: var(--sv-surface-hover);
    border-color: var(--sv-accent);
    color: var(--sv-accent);
}

.sv-modal-action-btn.sv-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--sv-red);
    color: var(--sv-red);
}

/* Metadata bar – Size / Modified / Lines */
.sv-modal-meta {
    padding: 10px 22px;
    border-bottom: 1px solid var(--sv-border);
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--sv-surface-2);
    flex-shrink: 0;
}

.sv-modal-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--sv-text-3);
    padding: 0 16px 0 0;
}

.sv-modal-meta-item:not(:last-child)::after {
    content: '•';
    margin-left: 16px;
    color: var(--sv-border-2);
}

.sv-modal-meta-label {
    color: var(--sv-text-3);
}

.sv-modal-meta-value {
    color: var(--sv-text-2);
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 11.5px;
}

/* Code body – always dark regardless of app theme */
.sv-modal-body {
    flex: 1;
    overflow: auto;
    background: #0d1117;
}

.sv-modal-body pre,
#sv-file-content {
    margin: 0;
    padding: 20px 24px;
    background: #0d1117;
    border: none;
    font-family: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.75;
    tab-size: 4;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #c9d1d9;
    min-height: 200px;
    font-variant-ligatures: none;
    letter-spacing: 0.01em;
}

/* Light mode: code body still stays dark – intentional */
.sv-app.sv-light-mode .sv-modal-body,
.sv-app.sv-light-mode #sv-file-content {
    background: #0d1117;
    color: #c9d1d9;
}

.sv-app.sv-light-mode .sv-modal-content {
    background: #ffffff;
    border-color: #e2e8f0;
}

.sv-app.sv-light-mode .sv-modal-header,
.sv-app.sv-light-mode .sv-modal-meta {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

/* Remove old footer */
.sv-modal-footer {
    display: none !important;
}

/* ── Full-screen mode ──────────────────────────────────────── */
.sv-modal.sv-modal-fullscreen .sv-modal-content {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
}

/* ============================================================
   EXPORT MODAL  (Image 1 design)
   ============================================================ */

.sv-export-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sv-export-modal-dialog {
    background: var(--sv-surface);
    border: 1px solid var(--sv-border-2);
    border-radius: var(--sv-radius-lg);
    box-shadow: var(--sv-shadow-lg);
    width: 92%;
    max-width: 520px;
    padding: 28px;
    position: relative;
    animation: sv-modal-in 0.18s ease;
}

@keyframes sv-modal-in {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Export modal header */
.sv-export-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.sv-export-modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--sv-text);
    margin: 0;
    letter-spacing: -0.01em;
}

.sv-export-modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--sv-radius-sm);
    border: 1px solid var(--sv-border-2);
    background: var(--sv-surface-3);
    color: var(--sv-text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--sv-transition);
    padding: 0;
    flex-shrink: 0;
}

.sv-export-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--sv-red);
    color: var(--sv-red);
}

/* 2×2 grid */
.sv-export-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Individual export cards */
.sv-export-card {
    background: var(--sv-surface-2);
    border: 1px solid var(--sv-border);
    border-radius: var(--sv-radius);
    padding: 20px 18px;
    cursor: pointer;
    transition: all var(--sv-transition);
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    color: var(--sv-text);
    position: relative;
    overflow: hidden;
}

.sv-export-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--sv-transition);
}

.sv-export-card:hover {
    border-color: var(--sv-border-2);
    background: var(--sv-surface-3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.sv-export-card:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Icon container */
.sv-export-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sv-export-card-icon svg {
    width: 22px;
    height: 22px;
}

/* Per-format colours */
.sv-export-card[data-format="txt"] .sv-export-card-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--sv-blue);
}

.sv-export-card[data-format="json"] .sv-export-card-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--sv-amber);
}

.sv-export-card[data-format="xml"] .sv-export-card-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--sv-green);
}

.sv-export-card[data-format="pdf"] .sv-export-card-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--sv-red);
}

/* Hover glow per format */
.sv-export-card[data-format="txt"]:hover  { border-color: rgba(59,130,246,0.4); }
.sv-export-card[data-format="json"]:hover { border-color: rgba(245,158,11,0.4); }
.sv-export-card[data-format="xml"]:hover  { border-color: rgba(16,185,129,0.4); }
.sv-export-card[data-format="pdf"]:hover  { border-color: rgba(239,68,68,0.4); }

/* Card text */
.sv-export-card-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sv-export-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--sv-text);
    letter-spacing: -0.01em;
}

.sv-export-card-sub {
    font-size: 11.5px;
    color: var(--sv-text-3);
}

/* ── Copy structure button loading state ───────────────────── */
.sv-export-card.sv-loading-state {
    pointer-events: none;
    opacity: 0.7;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
    .sv-modal-content { width: 98%; max-height: 96vh; border-radius: var(--sv-radius); }

    .sv-export-modal-grid {
        grid-template-columns: 1fr;
    }

    .sv-export-modal-dialog {
        padding: 20px;
    }

    .sv-modal-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    .sv-modal-meta-item::after {
        display: none;
    }
}