/* ══════════════════════════════════════════════════════════════
   Metric Modal Styles
   Modern, professional modal for business metrics visualization
   ══════════════════════════════════════════════════════════════ */

/* Modal Overlay */
.metric-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

.metric-modal-overlay.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 20px 20px;
    overflow-y: auto;
}

/* Modal Container */
.metric-modal {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 900px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease-out;
    position: relative;
}

/* Modal Header */
.metric-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
}

.metric-modal-title-section {
    flex: 1;
    min-width: 0;
}

.metric-modal-title {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    color: #1A253C;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.metric-validation-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #D1FAE5;
    color: #065F46;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.metric-validation-badge svg {
    width: 14px;
    height: 14px;
}

.metric-metadata-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.metric-chip {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.metric-chip.category {
    background: #EFF6FF;
    color: #1E40AF;
}

.metric-chip.category.finance {
    background: #D1FAE5;
    color: #065F46;
}

.metric-chip.category.telemetry {
    background: #FEF3C7;
    color: #78350F;
}

.metric-chip.category.revenue {
    background: #EFF6FF;
    color: #1E40AF;
}

.metric-chip.category.customers {
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

.metric-chip.category.marketing {
    background: #FEF3C7;
    color: #78350F;
}

.metric-chip.category.support {
    background: rgba(234, 88, 12, 0.1);
    color: #EA580C;
}

.metric-chip.grain,
.metric-chip.unit {
    background: #F3F4F6;
    color: #374151;
}

.metric-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6B7280;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-modal-close:hover {
    background: #F3F4F6;
    color: #1A253C;
}

.metric-modal-close svg {
    width: 20px;
    height: 20px;
}

/* Tab Navigation */
.metric-tabs {
    display: flex;
    padding: 0 32px;
    border-bottom: 1px solid #E5E7EB;
    gap: 8px;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.metric-tabs::-webkit-scrollbar {
    display: none;
}

.metric-tab {
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #9CA3AF;
    transition: color 0.15s ease, border-bottom-color 0.15s ease;
    white-space: nowrap;
    position: relative;
    outline: none !important;
    box-shadow: none !important;
}

.metric-tab:hover {
    color: #6B7280;
}

.metric-tab:focus,
.metric-tab:focus-visible,
.metric-tab:active {
    outline: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    box-shadow: none !important;
}

.metric-tab.active {
    color: #0073D1;
    border-bottom-color: #0073D1;
}

.metric-tab.active.category-finance {
    color: #065F46;
    border-bottom-color: #065F46;
}

.metric-tab.active.category-telemetry {
    color: #78350F;
    border-bottom-color: #78350F;
}

.metric-tab.active.category-revenue {
    color: #1E40AF;
    border-bottom-color: #1E40AF;
}

.metric-tab.active.category-customers {
    color: #7c3aed;
    border-bottom-color: #7c3aed;
}

.metric-tab.active.category-marketing {
    color: #78350F;
    border-bottom-color: #78350F;
}

.metric-tab.active.category-support {
    color: #EA580C;
    border-bottom-color: #EA580C;
}

/* Modal Body */
.metric-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    min-height: 0;
}

.metric-tab-content {
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.metric-tab-content.active {
    display: block;
}

/* Section Styles */
.metric-section {
    margin-bottom: 40px;
}

.metric-section:last-child {
    margin-bottom: 0;
}

.metric-section-header {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6B7280;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E5E7EB;
}

.metric-section-content {
    font-size: 15px;
    line-height: 1.7;
    color: #374151;
}

.metric-section-content p {
    margin: 0 0 16px 0;
}

.metric-section-content p:last-child {
    margin-bottom: 0;
}

.metric-section-content ul {
    margin: 0;
    padding-left: 24px;
    line-height: 1.8;
}

.metric-section-content li {
    margin-bottom: 12px;
}

.metric-section-content li:last-child {
    margin-bottom: 0;
}

.metric-section-content code {
    background: #F3F4F6;
    color: #0073D1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    font-weight: 500;
}

/* OpenMetadata HTML description (rendered from catalog) */
.om-description {
    font-size: 15px;
    line-height: 1.7;
    color: #374151;
}

.om-description p {
    margin: 0 0 12px 0;
}

.om-description p:last-child {
    margin-bottom: 0;
}

.om-description strong {
    color: #111827;
    font-weight: 600;
}

.om-description ul,
.om-description ol {
    margin: 8px 0 12px 0;
    padding-left: 24px;
}

.om-description li {
    margin-bottom: 4px;
    line-height: 1.6;
}

.om-description code {
    background: #F3F4F6;
    color: #0073D1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

/* Dimension Pills */
.metric-dimensions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.metric-dimension-pill {
    padding: 6px 12px;
    background: #EFF6FF;
    color: #1E40AF;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-mono, monospace);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    outline: none;
}

.metric-dimension-pill:hover {
    background: #DBEAFE;
    border-color: #93C5FD;
}

.metric-dimension-pill:focus {
    outline: 2px solid #0073D1;
    outline-offset: 2px;
    border-color: transparent;
}

.metric-dimension-pill:active {
    transform: scale(0.98);
}

/* Code Blocks */
.metric-code-block {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    position: relative;
}

.metric-code-block:last-child {
    margin-bottom: 0;
}

.metric-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.metric-code-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-code-copy-btn {
    padding: 6px 12px;
    background: #FFFFFF;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-code-copy-btn:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.metric-code-copy-btn:active {
    transform: scale(0.98);
}

.metric-code-copy-btn.copied {
    background: #D1FAE5;
    border-color: #10B981;
    color: #065F46;
}

.metric-code-copy-btn svg {
    width: 14px;
    height: 14px;
}

.metric-code-pre {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #1A253C;
    overflow-x: auto;
    white-space: pre;
}

.metric-code-pre code {
    display: block;
}

/* Loading State */
.metric-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6B7280;
}

.metric-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #E5E7EB;
    border-top-color: #0073D1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.metric-loading-text {
    font-size: 14px;
    color: #9CA3AF;
}

/* Error State */
.metric-error {
    padding: 20px;
    background: #FEE2E2;
    border: 1px solid #FCA5A5;
    border-radius: 8px;
    color: #991B1B;
    font-size: 14px;
}

/* Expandable Sections */
.metric-expandable {
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    margin-top: 12px;
}

.metric-expandable-trigger {
    width: 100%;
    padding: 12px 16px;
    background: #F9FAFB;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.15s ease;
}

.metric-expandable-trigger:hover {
    background: #F3F4F6;
}

.metric-expandable-trigger svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.metric-expandable.expanded .metric-expandable-trigger svg {
    transform: rotate(90deg);
}

.metric-expandable-content {
    display: none;
    padding: 16px;
    border-top: 1px solid #E5E7EB;
}

.metric-expandable.expanded .metric-expandable-content {
    display: block;
}

/* Technical Details Table */
.metric-details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.metric-details-table tr {
    border-bottom: 1px solid #E5E7EB;
}

.metric-details-table tr:last-child {
    border-bottom: none;
}

.metric-details-table td {
    padding: 12px 8px;
    vertical-align: top;
}

.metric-details-table td:first-child {
    font-weight: 600;
    color: #6B7280;
    width: 140px;
}

.metric-details-table td:last-child {
    color: #1A253C;
    font-family: var(--font-mono, monospace);
}

/* Responsive Design */
@media (max-width: 768px) {
    .metric-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }

    .metric-modal-header,
    .metric-modal-body {
        padding: 20px;
    }

    .metric-tabs {
        padding: 0 20px;
    }

    .metric-modal-title {
        font-size: 20px;
    }

    .metric-code-pre {
        font-size: 12px;
    }
}

/* Custom Prism.js Styling */
.metric-code-pre code[class*="language-"],
.metric-code-pre pre[class*="language-"] {
    background: none;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #1A253C;
    text-shadow: none;
}

/* SQL Keywords */
.token.keyword,
.token.operator {
    color: #0073D1;
    font-weight: 500;
}

/* SQL Functions */
.token.function {
    color: #7c3aed;
}

/* Strings and Names */
.token.string,
.token.char {
    color: #0d9668;
}

/* Numbers */
.token.number {
    color: #EA580C;
}

/* Comments */
.token.comment {
    color: #9CA3AF;
    font-style: italic;
}

/* Punctuation */
.token.punctuation {
    color: #6B7280;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

/* Focus Styles for Accessibility */
.metric-modal-close:focus,
.metric-tab:focus,
.metric-code-copy-btn:focus,
.metric-expandable-trigger:focus {
    outline: 2px solid #0073D1;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .metric-modal-overlay {
        position: static;
        background: none;
    }

    .metric-modal-close,
    .metric-tabs {
        display: none;
    }

    .metric-tab-content {
        display: block !important;
        page-break-inside: avoid;
    }
}
