/* ========== RESET & BASE ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: #0a192f;
    color: #ccd6f6;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

/* ========== TOOLBAR ========== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: #112240;
    border-bottom: 1px solid #1d3461;
    flex-shrink: 0;
    z-index: 100;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #64ffda;
    letter-spacing: -0.02em;
}

.logo i {
    font-size: 1.3rem;
}

.arch-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.arch-selector label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8892b0;
    font-weight: 500;
}

.arch-selector select {
    background: #1d3461;
    color: #ccd6f6;
    border: 1px solid #233554;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.arch-selector select:hover,
.arch-selector select:focus {
    border-color: #64ffda;
    outline: none;
}

.arch-description {
    font-size: 0.75rem;
    color: #8892b0;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toolbar-controls {
    display: flex;
    gap: 4px;
}

.toolbar-controls button {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1d3461;
    border: 1px solid #233554;
    color: #8892b0;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.toolbar-controls button:hover {
    background: #233554;
    color: #64ffda;
    border-color: #64ffda;
}

.toolbar-controls button.active {
    background: rgba(100, 255, 218, 0.1);
    color: #64ffda;
    border-color: rgba(100, 255, 218, 0.3);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #8892b0;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #233554;
    transition: all 0.2s;
}

.back-link:hover {
    color: #64ffda;
    border-color: #64ffda;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.network-canvas {
    width: 100%;
    height: 100%;
}

/* ========== LEGEND ========== */
.legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(17, 34, 64, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid #1d3461;
    border-radius: 10px;
    padding: 14px 18px;
    z-index: 10;
}

.legend-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64ffda;
    margin-bottom: 10px;
    font-weight: 600;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #8892b0;
    cursor: default;
    transition: color 0.2s;
}

.legend-item:hover {
    color: #ccd6f6;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ========== LOADING ========== */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 25, 47, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 50;
    opacity: 1;
    transition: opacity 0.4s;
    pointer-events: none;
}

.loading-overlay.hidden {
    opacity: 0;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #233554;
    border-top-color: #64ffda;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay span {
    font-size: 0.8rem;
    color: #8892b0;
}

/* ========== DETAIL PANEL ========== */
.detail-panel {
    width: 340px;
    background: #112240;
    border-left: 1px solid #1d3461;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel.closed {
    transform: translateX(100%);
    width: 0;
    border: none;
    overflow: hidden;
}

.panel-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
    color: #374151;
}

.panel-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: #233554;
}

.panel-placeholder p {
    font-size: 0.85rem;
    line-height: 1.5;
}

.panel-content {
    padding: 0;
}

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

.panel-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.panel-icon svg {
    width: 28px;
    height: 28px;
}

.panel-title-block {
    flex: 1;
    min-width: 0;
}

.panel-title-block h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #e6f1ff;
    line-height: 1.3;
}

.panel-category {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: 999px;
    display: inline-block;
    margin-top: 4px;
}

.panel-close {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8892b0;
    transition: all 0.2s;
}

.panel-close:hover {
    background: rgba(100, 255, 218, 0.1);
    color: #64ffda;
}

.panel-body {
    padding: 0 20px 20px;
}

.panel-section {
    margin-top: 20px;
}

.panel-section h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64ffda;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.panel-section h3 i {
    font-size: 0.75rem;
}

.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 12px;
    background: rgba(29, 52, 97, 0.4);
    border-radius: 6px;
    gap: 12px;
}

.detail-row .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8892b0;
    white-space: nowrap;
    flex-shrink: 0;
}

.detail-row .value {
    font-size: 0.8rem;
    color: #ccd6f6;
    text-align: right;
    word-break: break-word;
}

.connections-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.connection-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(29, 52, 97, 0.4);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: background 0.2s;
    cursor: pointer;
}

.connection-item:hover {
    background: rgba(29, 52, 97, 0.7);
}

.connection-item .conn-dir {
    font-size: 0.7rem;
    color: #64ffda;
    width: 16px;
    text-align: center;
}

.connection-item .conn-name {
    flex: 1;
    color: #ccd6f6;
}

.connection-item .conn-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: #8892b0;
    padding: 2px 6px;
    background: rgba(10, 25, 47, 0.5);
    border-radius: 4px;
}

/* ========== CATEGORY COLORS ========== */
.cat-compute {
    background: rgba(255, 153, 0, 0.15);
    color: #FF9900;
}

.cat-storage {
    background: rgba(59, 72, 204, 0.15);
    color: #6B7FFF;
}

.cat-database {
    background: rgba(46, 115, 184, 0.15);
    color: #5BA3E6;
}

.cat-network {
    background: rgba(140, 79, 255, 0.15);
    color: #A77BFF;
}

.cat-messaging {
    background: rgba(231, 21, 123, 0.15);
    color: #F05A9E;
}

.cat-analytics {
    background: rgba(1, 168, 141, 0.15);
    color: #2BD4B0;
}

.cat-security {
    background: rgba(221, 52, 76, 0.15);
    color: #E96B7D;
}

.cat-frontend {
    background: rgba(245, 166, 35, 0.15);
    color: #F5C563;
}

/* ========== VIS.JS OVERRIDES ========== */
.vis-network {
    outline: none !important;
}

div.vis-tooltip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    background: #112240 !important;
    color: #ccd6f6 !important;
    border: 1px solid #233554 !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

/* ========== MOBILE ========== */
.mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 25, 47, 0.6);
    z-index: 200;
}

.mobile-drawer-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        height: auto;
        padding: 10px 14px;
        gap: 8px;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .arch-description {
        display: none;
    }

    .detail-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 85vw;
        max-width: 360px;
        height: 100vh;
        z-index: 250;
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .detail-panel.open-mobile {
        transform: translateX(0);
    }

    .legend {
        bottom: 12px;
        left: 12px;
        padding: 10px 14px;
    }
}

/* ========== SCROLLBAR ========== */
.detail-panel::-webkit-scrollbar {
    width: 4px;
}

.detail-panel::-webkit-scrollbar-track {
    background: transparent;
}

.detail-panel::-webkit-scrollbar-thumb {
    background: #233554;
    border-radius: 4px;
}

.detail-panel::-webkit-scrollbar-thumb:hover {
    background: #64ffda;
}