/* ============================================================================
   COMPONENTS
   Buttons, badges, stat boxes, tables, pagination, cards, timeline, docs
   ============================================================================ */

/* Buttons */
.btn {
    padding: 8px 16px;
    background: #3b82f6;
    border: none;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
}

.btn:hover {
    background: #2563eb;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-purple {
    background: #8b5cf6;
}

.btn-purple:hover {
    background: #7c3aed;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:disabled {
    background: #64748b;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: #d97706;
    color: #fff;
}

.btn-warning:hover {
    background: #b45309;
}

/* Links */
.link {
    cursor: pointer;
    font-weight: bold;
}

.link:hover {
    text-decoration: underline;
}

.link-request-uuid {
    color: #06b6d4;
}

.link-service {
    color: #3b82f6;
}

.link-component {
    color: #fbbf24;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-info {
    background: #1e40af;
    color: #dbeafe;
}

.badge-warn {
    background: #c2410c;
    color: #fed7aa;
}

.badge-warning {
    background: #c2410c;
    color: #fed7aa;
}

.badge-error {
    background: #991b1b;
    color: #fecaca;
}

.badge-critical {
    background: #7f1d1d;
    color: #fca5a5;
}

.badge-debug {
    background: #4338ca;
    color: #e0e7ff;
}

/* Stat Boxes */
.stat-box {
    background: #1e293b;
    padding: 16px;
    border-radius: 6px;
    border: 1px solid #334155;
}

.stat-label {
    color: #64748b;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.stat-value {
    color: #60a5fa;
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 4px;
}

/* Tables */
.table-container {
    max-height: 70vh;
    overflow: auto;
    background: #1e293b;
    border-radius: 8px;
    margin-bottom: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #1e293b;
    border-radius: 8px;
    table-layout: fixed;
}

.data-table th {
    background: #0f172a;
    color: #94a3b8;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #334155;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.data-table tr:hover {
    background: #0f172a;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 8px 16px;
    background: #334155;
    border: none;
    border-radius: 6px;
    color: #cbd5e1;
    cursor: pointer;
}

.page-btn:hover {
    background: #475569;
}

.page-btn.active {
    background: #3b82f6;
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Cards */
.doc-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.doc-card {
    background: #1e293b;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #334155;
    cursor: pointer;
    transition: all 0.2s;
}

.doc-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.doc-card h3 {
    color: #60a5fa;
    margin-bottom: 8px;
}

.doc-card .badge {
    margin-bottom: 8px;
}

.doc-card p {
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Timeline */
.timeline-item {
    background: #1e293b;
    padding: 16px;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 3px solid #3b82f6;
}

.timeline-item:hover {
    background: #0f172a;
}

.timeline-item.clicked {
    background: #1e3a8a;
}

.timeline-time {
    color: #60a5fa;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.timeline-source {
    color: #94a3b8;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.timeline-source-detail {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-bottom: 8px;
    font-style: italic;
}

.timeline-content {
    color: #cbd5e1;
    font-size: 0.9rem;
}

/* Search Results Groups */
.source-group {
    margin-bottom: 1rem;
}

.source-group-title {
    color: #60a5fa;
    font-size: 1.1rem;
    margin: 0;
    padding: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.source-group-title:hover {
    background: rgba(96, 165, 250, 0.1);
    border-radius: 4px;
}

.highlighted-item {
    background: #1e3a8a !important;
}

/* Doc Content */
.doc-content {
    background: #1e293b;
    padding: 32px;
    border-radius: 8px;
    border: 1px solid #334155;
    max-width: 1200px;
    margin: 0 auto;
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
    color: #60a5fa;
    margin-top: 24px;
    margin-bottom: 12px;
}

.doc-content h1 {
    font-size: 2rem;
    margin-top: 0;
}

.doc-content h2 {
    font-size: 1.5rem;
}

.doc-content h3 {
    font-size: 1.2rem;
}

.doc-content a {
    color: #fbbf24;
    text-decoration: none;
}

.doc-content a:hover {
    text-decoration: underline;
}

.doc-content code {
    background: #0f172a;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    color: #60a5fa;
}

.doc-content pre {
    background: #0f172a;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 16px 0;
}

/* Mermaid diagram container (wraps the rendered pre.mermaid) */
.mermaid-container {
    position: relative;
    margin: 16px 0;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    overflow: hidden;
}

.mermaid-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    gap: 4px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.mermaid-container:hover .mermaid-toolbar {
    opacity: 1;
}

.mermaid-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
}

.mermaid-btn:hover {
    background: #1e3a5f;
    color: #e2e8f0;
}

.mermaid-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.mermaid-zoom-level {
    display: flex;
    align-items: center;
    color: #64748b;
    font-size: 11px;
    padding: 0 4px;
    min-width: 36px;
    justify-content: center;
    user-select: none;
}

.mermaid-viewport {
    overflow: hidden;
    cursor: grab;
    min-height: 200px;
}

.mermaid-viewport.is-dragging {
    cursor: grabbing;
}

.mermaid-viewport pre.mermaid {
    background: none;
    padding: 24px;
    margin: 0;
    border: none;
    border-radius: 0;
    text-align: center;
    transform-origin: 0 0;
    transition: none;
    overflow: visible;
}

.mermaid-viewport pre.mermaid svg {
    max-width: none;
    height: auto;
}

/* Fullscreen mode */
.mermaid-container.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    border-radius: 0;
    border: none;
    margin: 0;
}

.mermaid-container.is-fullscreen .mermaid-viewport {
    height: 100%;
}

.mermaid-container.is-fullscreen .mermaid-toolbar {
    top: 12px;
    right: 12px;
}

.doc-content pre code {
    background: none;
    padding: 0;
}

.doc-content ul,
.doc-content ol {
    margin-left: 32px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.doc-content li {
    margin-bottom: 8px;
}

/* Markdown Tables in Doc Content */
.doc-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: #0f172a;
    border-radius: 6px;
    overflow: hidden;
}

.doc-content th,
.doc-content td {
    padding: 12px 16px;
    text-align: left;
    border: 1px solid #334155;
}

.doc-content th {
    background: #1e3a5f;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.doc-content td {
    color: #e2e8f0;
}

.doc-content tr:hover td {
    background: #1e293b;
}

/* Service Credentials Banner */
.service-credentials-banner {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    border: 1px solid #3d5a7f;
    border-radius: 6px;
    padding: 8px 16px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: #e0e7ff;
    flex-shrink: 0;
}

.service-credentials-banner strong {
    color: #93c5fd;
}
