
/* ============================================
   Share Modal
   ============================================ */

.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: shareModalFadeIn 0.2s ease;
}

@keyframes shareModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.share-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    overflow: hidden;
    animation: shareModalSlideIn 0.25s ease;
}

@keyframes shareModalSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.share-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.share-modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.share-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.share-modal-body {
    padding: 1.25rem;
}

.share-modal-hint {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.share-modal-url-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-modal-url {
    flex: 1;
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    min-width: 0;
}

.share-modal-url:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.share-modal-copy {
    white-space: nowrap;
    flex-shrink: 0;
}

.share-modal-note {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Share button in header */
#share-btn {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .share-modal-url-wrapper {
        flex-direction: column;
    }
    .share-modal-url {
        font-size: 0.75rem;
    }
}

/* ============================================
   Embed Code Modal
   ============================================ */

.embed-modal-dialog {
    max-width: 680px;
}

.embed-options {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.embed-option-row {
    margin-bottom: 0.75rem;
}

.embed-option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

.embed-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.embed-dimensions {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    transition: opacity var(--transition);
}

.embed-dim-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.embed-dim-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 40px;
}

.embed-dim-input {
    width: 70px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    text-align: center;
}

.embed-dim-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.embed-dim-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.embed-presets {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.embed-preset-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.embed-preset-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.embed-preset-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.embed-preview-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.embed-preview {
    width: 100%;
    min-height: 180px;
    max-height: 320px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    padding: 0.5rem;
}

.embed-preview-frame-wrapper {
    border-radius: 6px;
    overflow: hidden;
}

.embed-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.embed-code-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.embed-code-textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    line-height: 1.5;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
}

.embed-code-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.embed-copy-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.embed-options code {
    font-size: 0.8rem;
    background: var(--bg-secondary);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: var(--accent);
}

/* Embed mode — compact UI when loaded in an iframe */
html.embed-mode .header,
html.embed-mode .footer,
html.embed-mode .data-table-section,
html.embed-mode .transform-toggle-bar,
html.embed-mode .transform-panel,
html.embed-mode .recommendation-banner,
html.embed-mode .controls-bar,
html.embed-mode #chart-title-bar {
    display: none !important;
}

html.embed-mode .chart-panel {
    padding: 0 !important;
}

html.embed-mode .chart-container {
    border-radius: 0;
    box-shadow: none;
}

html.embed-mode main {
    padding: 0;
    min-height: 100vh;
}

html.embed-mode body {
    overflow: hidden;
}

@media (max-width: 768px) {
    .embed-dimensions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .embed-presets {
        gap: 0.35rem;
    }
    .embed-preview {
        min-height: 120px;
        max-height: 200px;
    }
    .embed-modal-dialog {
        max-width: 95%;
    }
}

/* ============================================
   Batch Export Modal
   ============================================ */

.batch-export-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(4px);
    padding: 1rem;
}
.batch-export-overlay.active {
    opacity: 1;
}
.batch-export-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    position: relative;
    transform: scale(0.92) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}
.batch-export-overlay.active .batch-export-modal {
    transform: scale(1) translateY(0);
}
.batch-export-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.batch-export-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.batch-export-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.batch-export-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.batch-export-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.35rem;
}
.batch-export-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0;
}
.batch-export-formats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.batch-export-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.batch-export-option:hover {
    border-color: var(--accent-muted);
    background: var(--bg-hover);
}
.batch-export-option:has(.batch-export-checkbox:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}
.batch-export-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.batch-export-format-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}
.batch-export-format-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.batch-export-format-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}
.batch-export-format-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.batch-export-format-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.batch-export-footer {
    text-align: center;
}
.batch-export-download-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
}
.batch-export-download-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.batch-export-download-btn:active {
    transform: translateY(0);
}
.batch-export-note {
    margin: 0.6rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .batch-export-modal {
        padding: 1.25rem;
    }
    .batch-export-option {
        padding: 0.6rem 0.75rem;
        gap: 0.5rem;
    }
    .batch-export-format-desc {
        display: none;
    }
    .batch-export-format-size {
        display: none;
    }
}

/* ============ Template Gallery Modal ============ */
.template-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(4px);
    padding: 1rem;
}
.template-overlay.active {
    opacity: 1;
}
.template-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    padding: 2rem;
    position: relative;
    transform: scale(0.92) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}
.template-overlay.active .template-modal {
    transform: scale(1) translateY(0);
}
.template-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.template-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.template-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.template-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}
.template-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.35rem;
}
.template-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0;
}
.template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.template-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.template-card:hover {
    border-color: var(--accent-muted);
    background: var(--bg-hover);
    transform: translateY(-1px);
}
.template-card-icon {
    font-size: 1.3rem;
    margin-bottom: 0.15rem;
}
.template-card-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}
.template-card-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.35;
}
.template-card-type {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    margin-top: 0.25rem;
    width: fit-content;
}
.template-footer {
    text-align: center;
}
.template-footer-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

/* Template Tabs */
.template-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}
.template-tab {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s;
}
.template-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.template-tab.active {
    color: var(--accent);
    background: var(--accent-light);
    border-color: var(--accent-muted);
}

/* Community Template Cards */
.community-card {
    border-left: 3px solid var(--accent-muted);
}
.template-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
.template-card-author {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
}
.template-card-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    margin-top: 0.2rem;
    width: fit-content;
}

/* Community Footer / Submit Link */
.template-community-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}
.template-submit-link {
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.template-submit-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .template-modal {
        padding: 1.25rem;
    }
    .template-grid {
        grid-template-columns: 1fr;
    }
    .template-card-desc {
        display: none;
    }
}
