/* ===== System Architecture Page ===== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d29;
    --bg-card: #21253a;
    --bg-card-hover: #282d45;
    --border: #2d3250;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --accent: #6c8aff;
    --accent-glow: rgba(108, 138, 255, 0.3);
    --success: #3ddc84;
    --error: #f44336;
    --warning: #ffab40;
    --info: #29b6f6;
    --purple: #a78bfa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Header ===== */
.arch-header {
    background: linear-gradient(135deg, #1a1d29 0%, #21253a 100%);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.arch-header-left .logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.arch-header-left h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.arch-header-left h1 span {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 13px;
    margin-left: 8px;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.back-link:hover {
    border-color: var(--accent);
    background: rgba(108, 138, 255, 0.1);
    color: var(--accent);
}

/* ===== Hero Section ===== */
.hero {
    text-align: center;
    padding: 48px 24px 32px;
    background: radial-gradient(ellipse at 50% 0%, rgba(108, 138, 255, 0.08) 0%, transparent 70%);
}

.hero-icon {
    font-size: 56px;
    margin-bottom: 16px;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.hero h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ===== Feature Badges ===== */
.feature-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.feature-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-badge:hover {
    transform: translateY(-2px);
}

.feature-badge.blue {
    background: rgba(108, 138, 255, 0.1);
    color: var(--accent);
    border-color: rgba(108, 138, 255, 0.3);
}

.feature-badge.green {
    background: rgba(61, 220, 132, 0.1);
    color: var(--success);
    border-color: rgba(61, 220, 132, 0.3);
}

.feature-badge.orange {
    background: rgba(255, 171, 64, 0.1);
    color: var(--warning);
    border-color: rgba(255, 171, 64, 0.3);
}

.feature-badge.purple {
    background: rgba(167, 139, 250, 0.1);
    color: var(--purple);
    border-color: rgba(167, 139, 250, 0.3);
}

.feature-badge.cyan {
    background: rgba(41, 182, 246, 0.1);
    color: var(--info);
    border-color: rgba(41, 182, 246, 0.3);
}

/* ===== Section ===== */
.section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 40px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--border), transparent);
}

/* ===== Architecture Diagram ===== */
.diagram-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 24px;
    margin-bottom: 32px;
    overflow-x: auto;
    position: relative;
}

.diagram-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6, var(--accent));
    border-radius: 16px 16px 0 0;
}

.mermaid {
    display: flex;
    justify-content: center;
}

/* Override mermaid dark theme */
.mermaid svg {
    max-width: 100%;
}

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

.component-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.component-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 14px 14px 0 0;
    transition: opacity 0.3s;
}

.component-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 24px var(--accent-glow);
    transform: translateY(-3px);
}

.component-card.layer-device::before {
    background: linear-gradient(90deg, var(--success), #2eb86f);
}

.component-card.layer-gateway::before {
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.component-card.layer-data::before {
    background: linear-gradient(90deg, var(--warning), #ff8f00);
}

.component-card.layer-external::before {
    background: linear-gradient(90deg, var(--info), #0288d1);
}

.component-card.layer-frontend::before {
    background: linear-gradient(90deg, var(--purple), #7c3aed);
}

.card-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.card-name {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
}

.card-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.card-tag {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(108, 138, 255, 0.1);
    color: var(--accent);
    border: 1px solid rgba(108, 138, 255, 0.2);
}

.card-tag.green {
    background: rgba(61, 220, 132, 0.1);
    color: var(--success);
    border-color: rgba(61, 220, 132, 0.2);
}

.card-tag.orange {
    background: rgba(255, 171, 64, 0.1);
    color: var(--warning);
    border-color: rgba(255, 171, 64, 0.2);
}

.card-tag.purple {
    background: rgba(167, 139, 250, 0.1);
    color: var(--purple);
    border-color: rgba(167, 139, 250, 0.2);
}

.card-tag.cyan {
    background: rgba(41, 182, 246, 0.1);
    color: var(--info);
    border-color: rgba(41, 182, 246, 0.2);
}

/* ===== Tech Stack Table ===== */
.tech-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.tech-table {
    width: 100%;
    border-collapse: collapse;
}

.tech-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
}

.tech-table td {
    padding: 10px 16px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.tech-table tr:last-child td {
    border-bottom: none;
}

.tech-table tr:hover td {
    background: rgba(108, 138, 255, 0.03);
}

.tech-table .tech-name {
    font-weight: 600;
    color: var(--accent);
}

.tech-table .tech-icon {
    font-size: 18px;
    width: 32px;
    text-align: center;
}

/* ===== Data Flow Section ===== */
.flow-steps {
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
    padding: 8px 0;
}

.flow-step {
    flex: 1;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    position: relative;
    transition: all 0.3s;
}

.flow-step:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.flow-step .step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.flow-step .step-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.flow-step .step-label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.flow-step .step-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.flow-arrow {
    display: flex;
    align-items: center;
    font-size: 20px;
    color: var(--text-secondary);
    padding: 0 4px;
    flex-shrink: 0;
}

/* ===== Port Table ===== */
.port-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.port-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.port-card:hover {
    border-color: var(--accent);
}

.port-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 52px;
}

.port-info .port-service {
    font-size: 12px;
    font-weight: 600;
}

.port-info .port-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.arch-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hero h2 {
        font-size: 22px;
    }

    .hero p {
        font-size: 13px;
    }

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

    .flow-steps {
        flex-direction: column;
        align-items: center;
    }

    .flow-arrow {
        transform: rotate(90deg);
    }

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