/* ==========================================================================
   MicroChat 3.0 - Professional Visualization & Artifact Design System
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Interactive Chart Card System
   -------------------------------------------------------------------------- */
.mc-chart-card {
    background: #FFFFFF;
    border: 1px solid var(--border, #E5E7EB);
    border-radius: 14px;
    padding: 16px 18px;
    margin: 14px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
}

.mc-chart-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
}

.mc-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.mc-chart-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mc-chart-type-badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #2563EB;
    background: rgba(37, 99, 235, 0.08);
    padding: 2px 7px;
    border-radius: 6px;
    width: max-content;
}

.mc-chart-title {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text-main, #111827);
    margin: 0;
    line-height: 1.35;
}

.mc-chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted, #71717A);
    margin: 0;
}

.mc-chart-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mc-btn-chart-action {
    background: transparent;
    border: 1px solid var(--border, #E5E7EB);
    color: var(--text-muted, #71717A);
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.mc-btn-chart-action:hover {
    background: #F4F4F5;
    color: var(--text-main, #18181B);
    border-color: #D4D4D8;
}

/* Summary Statistics Strip */
.mc-chart-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: #F9FAFB;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.mc-stat-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.82rem;
}

.mc-stat-k {
    color: var(--text-muted, #71717A);
    font-weight: 500;
}

.mc-stat-v {
    color: var(--text-main, #111827);
    font-weight: 600;
}

/* Canvas Body */
.mc-chart-body {
    position: relative;
    width: 100%;
    min-height: 240px;
    max-height: 360px;
    height: 280px;
}

.mc-chart-body canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Chart Table View Toggle */
.mc-chart-table-view {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    font-size: 0.85rem;
}

.mc-chart-inner-table {
    width: 100%;
    border-collapse: collapse;
}

.mc-chart-inner-table th,
.mc-chart-inner-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border, #E5E7EB);
    text-align: left;
}

.mc-chart-inner-table th {
    background: #F4F4F5;
    font-weight: 600;
}

/* Chart Footer & Source */
.mc-chart-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border, #F4F4F5);
    font-size: 0.76rem;
    color: var(--text-muted, #71717A);
}

.mc-chart-source {
    display: flex;
    align-items: center;
    gap: 5px;
    font-style: italic;
}

.mc-chart-source span {
    font-weight: 500;
}

.mc-chart-note {
    font-size: 0.72rem;
    opacity: 0.8;
}

/* Streaming Skeleton Indicator */
.mc-chart-skeleton {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    margin: 12px 0;
    border-radius: 12px;
    background: #F9FAFB;
    border: 1px dashed var(--border, #D4D4D8);
    color: var(--text-muted, #71717A);
    font-size: 0.88rem;
    font-weight: 500;
}

.mc-chart-pulse {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #3B82F6;
    border-top-color: transparent;
    animation: mcSpin 0.75s linear infinite;
}

@keyframes mcSpin {
    to { transform: rotate(360deg); }
}

.mc-chart-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #FEF2F2;
    border: 1px solid #FEE2E2;
    color: #991B1B;
    border-radius: 10px;
    font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   2. Enhanced Code Block Wrapper
   -------------------------------------------------------------------------- */
.code-block-wrapper {
    margin: 1rem 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #334155;
    background: #1E293B;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    background: #0F172A;
    border-bottom: 1px solid #334155;
    user-select: none;
}

.code-lang-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #94A3B8;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.code-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.code-copy-btn:hover {
    color: #F8FAFC;
    background: rgba(255, 255, 255, 0.08);
}

.code-copy-btn.copied {
    color: #10B981;
}

.code-block-wrapper pre {
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 12px 16px !important;
    max-height: 480px;
}

/* --------------------------------------------------------------------------
   3. Enhanced Table Card & Numeric Cells
   -------------------------------------------------------------------------- */
.ai-table-card {
    margin: 1rem 0;
    background: #FFFFFF;
    border: 1px solid var(--border, #E5E7EB);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.ai-table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #F9FAFB;
    border-bottom: 1px solid var(--border, #E5E7EB);
}

.ai-table-badge {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #4B5563;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ai-table-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted, #71717A);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.ai-table-copy-btn:hover {
    background: #E5E7EB;
    color: var(--text-main, #111827);
}

.ai-table-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ai-table-scroll-wrapper table {
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

td.numeric-cell, th.numeric-cell {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   4. Image Lightbox Modal
   -------------------------------------------------------------------------- */
.mc-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    padding: 24px;
}

.mc-lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.mc-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mc-lightbox-content img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.mc-lightbox-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #27272A;
    color: #FFFFFF;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.mc-lightbox-close:hover {
    transform: scale(1.1);
    background: #3F3F46;
}

/* --------------------------------------------------------------------------
   5. Dark Mode Overrides for Visualization Components
   -------------------------------------------------------------------------- */
body.dark-mode .mc-chart-card,
[data-theme="dark"] .mc-chart-card {
    background: #18181B;
    border-color: #27272A;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

body.dark-mode .mc-chart-card:hover,
[data-theme="dark"] .mc-chart-card:hover {
    border-color: rgba(96, 165, 250, 0.4);
}

body.dark-mode .mc-chart-type-badge,
[data-theme="dark"] .mc-chart-type-badge {
    color: #60A5FA;
    background: rgba(96, 165, 250, 0.12);
}

body.dark-mode .mc-chart-title,
[data-theme="dark"] .mc-chart-title {
    color: #F4F4F5;
}

body.dark-mode .mc-btn-chart-action,
[data-theme="dark"] .mc-btn-chart-action {
    border-color: #27272A;
    color: #A1A1AA;
}

body.dark-mode .mc-btn-chart-action:hover,
[data-theme="dark"] .mc-btn-chart-action:hover {
    background: #27272A;
    color: #FFFFFF;
}

body.dark-mode .mc-chart-stats,
[data-theme="dark"] .mc-chart-stats {
    background: #27272A;
    border-color: rgba(255, 255, 255, 0.04);
}

body.dark-mode .mc-stat-k,
[data-theme="dark"] .mc-stat-k {
    color: #A1A1AA;
}

body.dark-mode .mc-stat-v,
[data-theme="dark"] .mc-stat-v {
    color: #F4F4F5;
}

body.dark-mode .mc-chart-footer,
[data-theme="dark"] .mc-chart-footer {
    border-top-color: #27272A;
    color: #A1A1AA;
}

body.dark-mode .mc-chart-skeleton,
[data-theme="dark"] .mc-chart-skeleton {
    background: #27272A;
    border-color: #3F3F46;
    color: #A1A1AA;
}

body.dark-mode .ai-table-card,
[data-theme="dark"] .ai-table-card {
    background: #18181B;
    border-color: #27272A;
}

body.dark-mode .ai-table-card-header,
[data-theme="dark"] .ai-table-card-header {
    background: #27272A;
    border-bottom-color: #3F3F46;
}

body.dark-mode .ai-table-badge,
[data-theme="dark"] .ai-table-badge {
    color: #D4D4D8;
}

body.dark-mode .ai-table-copy-btn,
[data-theme="dark"] .ai-table-copy-btn {
    color: #A1A1AA;
}

body.dark-mode .ai-table-copy-btn:hover,
[data-theme="dark"] .ai-table-copy-btn:hover {
    background: #3F3F46;
    color: #FFFFFF;
}

/* --------------------------------------------------------------------------
   6. Attachment Cards (User Uploads)
   -------------------------------------------------------------------------- */
.file-attachment-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #FFFFFF;
    border: 1px solid var(--border, #E5E7EB);
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    max-width: 100%;
    cursor: pointer;
    transition: all 0.15s ease;
}

.file-attachment-card:hover {
    border-color: #3B82F6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
    transform: translateY(-1px);
}

.file-attachment-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.file-attachment-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 2px;
}

.file-attachment-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.file-attachment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted, #71717A);
}

.file-type-pill {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 4px;
}

body.dark-mode .file-attachment-card,
[data-theme="dark"] .file-attachment-card {
    background: #18181B;
    border-color: #27272A;
}

body.dark-mode .file-attachment-card:hover,
[data-theme="dark"] .file-attachment-card:hover {
    border-color: #60A5FA;
}

