/**
 * Schema Viewer Styles
 * Styles for the Firestore schema visualization page
 */

/* Reset and base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f9fafb;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Container */
.schema-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.schema-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.schema-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.meta-info {
    font-size: 12px;
    color: #6b7280;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.zoom-level {
    font-size: 13px;
    color: #6b7280;
    min-width: 50px;
    text-align: center;
}

/* Main content */
.schema-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Architecture Summary */
.schema-architecture {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    flex-shrink: 0;
}

.architecture-flow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.architecture-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7280;
}

.architecture-chain {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.architecture-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px;
}

.architecture-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
}

.architecture-card h2 {
    font-size: 12px;
    margin-bottom: 8px;
}

.architecture-card ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.architecture-card li {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
}

.subtype-group {
    margin-bottom: 10px;
}

.subtype-group:last-child {
    margin-bottom: 0;
}

.subtype-group h3 {
    font-size: 12px;
    margin-bottom: 3px;
    color: #111827;
}

.subtype-group p {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    font-size: 11px;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 2px 7px;
}

/* Diagram Panel */
.diagram-panel {
    flex: 1;
    overflow: auto;
    padding: 24px;
    background: #f9fafb;
}

.diagram-wrapper {
    min-width: fit-content;
    transition: transform 0.15s ease;
}

.mermaid {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}

.error-message {
    color: #dc2626;
    background: #fef2f2;
    padding: 16px 24px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    font-size: 14px;
}

/* Detail Panel */
.detail-panel {
    width: 320px;
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.entity-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 12px;
}

.entity-badge.primary {
    background: #dbeafe;
    color: #1d4ed8;
}

.entity-badge.subtype {
    background: #ecfeff;
    color: #0e7490;
}

.entity-badge.supporting {
    background: #f3f4f6;
    color: #6b7280;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.hint-text {
    color: #9ca3af;
    font-size: 14px;
    line-height: 1.5;
}

/* Detail Sections */
.detail-section {
    margin-bottom: 24px;
}

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

.detail-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Field List */
.field-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 13px;
}

.field-item.reference {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
}

.field-name {
    font-weight: 500;
    color: #111827;
}

.field-type-badge {
    font-size: 11px;
    font-family: 'SF Mono', Consolas, monospace;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e5e7eb;
    color: #374151;
}

.field-type-badge.required {
    background: #dbeafe;
    color: #1d4ed8;
}

.required-badge {
    font-size: 10px;
    color: #dc2626;
    font-weight: 500;
}

/* Relationship List */
.relationship-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.relationship-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0fdf4;
    border-radius: 6px;
    font-size: 13px;
}

.rel-arrow {
    color: #22c55e;
    font-weight: bold;
}

.rel-target {
    font-weight: 500;
    color: #15803d;
    cursor: pointer;
}

.rel-target:hover {
    text-decoration: underline;
}

.rel-type {
    font-size: 11px;
    color: #6b7280;
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.rel-label {
    font-size: 11px;
    color: #9ca3af;
    margin-left: auto;
}

/* Footer / Legend */
.schema-footer {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 12px 24px;
    flex-shrink: 0;
}

.build-info {
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
}

.legend {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.primary {
    background: #3b82f6;
}

.legend-dot.subtype {
    background: #0891b2;
}

.legend-dot.supporting {
    background: #9ca3af;
}

.legend-line {
    width: 24px;
    height: 2px;
    position: relative;
}

.legend-line.one-to-many {
    background: #64748b;
}

.legend-line.one-to-many::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    width: 0;
    height: 0;
    border-left: 6px solid #64748b;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.legend-line.contains {
    background: #94a3b8;
    border-style: dashed;
}

/* Responsive */
@media (max-width: 768px) {
    .schema-main {
        flex-direction: column;
    }

    .architecture-grid {
        grid-template-columns: 1fr;
    }

    .detail-panel {
        width: 100%;
        height: 40vh;
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .legend {
        gap: 16px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: #111827;
        color: #f9fafb;
    }

    .schema-header,
    .schema-architecture,
    .detail-panel,
    .schema-footer {
        background: #1f2937;
        border-color: #374151;
    }

    .schema-header h1,
    .panel-header h2 {
        color: #f9fafb;
    }

    .meta-info,
    .hint-text {
        color: #9ca3af;
    }

    .diagram-panel {
        background: #111827;
    }

    .mermaid {
        background: #1f2937;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .btn-secondary {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }

    .btn-secondary:hover {
        background: #4b5563;
    }

    .field-item {
        background: #374151;
    }

    .architecture-card {
        background: #111827;
        border-color: #374151;
    }

    .architecture-chain,
    .subtype-group h3 {
        color: #f9fafb;
    }

    .architecture-card li {
        background: #1e3a8a;
        border-color: #1d4ed8;
        color: #bfdbfe;
    }

    .subtype-group p,
    .architecture-label {
        color: #9ca3af;
    }

    .chip {
        background: #374151;
        border-color: #4b5563;
        color: #e5e7eb;
    }

    .field-item.reference {
        background: #422006;
        border-left-color: #d97706;
    }

    .field-name {
        color: #f9fafb;
    }

    .field-type-badge {
        background: #4b5563;
        color: #e5e7eb;
    }

    .field-type-badge.required {
        background: #1e3a8a;
        color: #93c5fd;
    }

    .relationship-item {
        background: #14532d;
    }

    .rel-target {
        color: #86efac;
    }

    .rel-type {
        background: #1f2937;
        color: #9ca3af;
    }

    .entity-badge.primary {
        background: #1e3a8a;
        color: #93c5fd;
    }

    .entity-badge.subtype {
        background: #164e63;
        color: #a5f3fc;
    }

    .entity-badge.supporting {
        background: #374151;
        color: #9ca3af;
    }

    .error-message {
        background: #450a0a;
        border-color: #7f1d1d;
        color: #fca5a5;
    }
}
