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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #e0e0e0;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 70px;
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #0f3460;
    z-index: 1000;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    align-items: center;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    border: 2px solid #00d9ff;
    border-radius: 25px;
    color: #00d9ff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.2);
}

.lang-btn:hover {
    background: linear-gradient(135deg, #00d9ff 0%, #0891b2 100%);
    color: #16213e;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 217, 255, 0.4);
}

.lang-icon {
    font-size: 1.2rem;
}

/* Logout Button */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    border: 2px solid #ef4444;
    border-radius: 25px;
    color: #ef4444;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(239, 68, 68, 0.2);
}

.logout-btn:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid #0f3460;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 25px;
}

.logo-container {
    flex-shrink: 0;
}

.header-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.header-logo:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 217, 255, 0.3);
}

.header-text {
    flex: 1;
}

header h1 {
    font-size: 1.8rem;
    color: #00d9ff;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}

.metadata {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.meta-item {
    color: #94a3b8;
    font-size: 0.95rem;
}

/* Legend Styles */
.legend {
    background: rgba(15, 52, 96, 0.5);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #0f3460;
}

.legend h3 {
    color: #00d9ff;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box input {
    flex: 1;
    min-width: 250px;
    padding: 12px 20px;
    border: 2px solid #0f3460;
    border-radius: 8px;
    background: rgba(15, 52, 96, 0.5);
    color: #e0e0e0;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #00d9ff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.2);
}

.search-box input::placeholder {
    color: #64748b;
}

.search-box button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: #00d9ff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid #0f3460;
}

.search-box button:hover {
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    box-shadow: 0 5px 15px rgba(0, 217, 255, 0.2);
    transform: translateY(-2px);
}

/* Tree Container */
.tree-container {
    background: rgba(15, 52, 96, 0.3);
    border-radius: 15px;
    padding: 25px;
    border: 1px solid #0f3460;
}

/* Tree Structure */
.tree {
    list-style: none;
}

.tree-node {
    margin: 5px 0;
}

/* Node Headers */
.node-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(22, 33, 62, 0.6);
    border: 1px solid transparent;
}

.node-header:hover {
    background: rgba(15, 52, 96, 0.8);
    border-color: #0f3460;
    transform: translateX(5px);
}

.node-header.expanded {
    background: rgba(0, 217, 255, 0.1);
    border-color: rgba(0, 217, 255, 0.3);
}

.toggle-icon {
    font-size: 0.8rem;
    color: #00d9ff;
    width: 15px;
    transition: transform 0.3s ease;
}

.node-icon {
    font-size: 1.2rem;
}

.node-code {
    background: linear-gradient(135deg, #00d9ff 0%, #0891b2 100%);
    color: #16213e;
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Consolas', monospace;
}

.node-title {
    flex: 1;
    font-weight: 500;
    color: #e0e0e0;
}

.node-count {
    color: #64748b;
    font-size: 0.85rem;
    background: rgba(100, 116, 139, 0.2);
    padding: 3px 10px;
    border-radius: 12px;
}

/* System Node */
.system-node > .node-header {
    background: linear-gradient(135deg, rgba(15, 52, 96, 0.8) 0%, rgba(22, 33, 62, 0.8) 100%);
    border: 1px solid #0f3460;
}

.system-node > .node-header .node-title {
    color: #00d9ff;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Assembly Node */
.assembly-node > .node-header {
    margin-left: 25px;
    background: rgba(22, 33, 62, 0.7);
}

.assembly-node > .node-header .node-title {
    color: #94a3b8;
}

/* Component Node */
.component-node {
    margin-left: 50px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid rgba(15, 52, 96, 0.5);
    transition: all 0.3s ease;
}

.component-node:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(0, 217, 255, 0.3);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

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

.component-header .node-title {
    font-weight: 600;
    color: #e0e0e0;
}

.component-details {
    padding-left: 30px;
}

/* Service Types Badges */
.service-types {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.service-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Service Badge Colors */
.service-badge.ins {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.service-badge.srv {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.service-badge.rep {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.service-badge.rep-oh {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.service-badge.rep-reb {
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
    color: white;
}

.service-badge.chg {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.service-badge.cal {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.service-badge.tst {
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    color: white;
}

.service-badge.cln {
    background: linear-gradient(135deg, #84cc16 0%, #65a30d 100%);
    color: white;
}

.service-badge.adj {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
}

/* Typical Services */
.typical-services {
    color: #94a3b8;
    font-size: 0.9rem;
}

.typical-services strong {
    color: #64748b;
}

.service-item {
    display: inline-block;
    background: rgba(100, 116, 139, 0.2);
    padding: 3px 10px;
    border-radius: 5px;
    margin: 3px 5px 3px 0;
    font-size: 0.85rem;
}

/* Hidden Class */
.hidden {
    display: none;
}

/* Node Children */
.node-children {
    margin-top: 5px;
    padding-left: 20px;
    border-left: 2px solid rgba(0, 217, 255, 0.2);
    margin-left: 7px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        padding-top: 80px;
    }

    /* Top Bar Mobile */
    .top-bar {
        padding: 10px 15px;
    }

    .lang-btn, .logout-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .lang-btn span:last-child,
    .logout-btn span:last-child {
        display: none;
    }

    .lang-icon {
        font-size: 1.1rem;
    }

    /* Header Mobile */
    header {
        padding: 15px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .header-logo {
        width: 60px;
        height: 60px;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .metadata {
        flex-direction: column;
        gap: 8px;
        font-size: 0.85rem;
    }

    /* Legend Mobile */
    .legend {
        padding: 12px;
    }

    .legend h3 {
        font-size: 0.95rem;
    }

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

    .legend-item {
        font-size: 0.8rem;
    }

    /* Search Box Mobile */
    .search-box {
        flex-direction: column;
        gap: 10px;
    }

    .search-box input {
        min-width: 100%;
        font-size: 0.9rem;
    }

    .search-box button {
        width: 100%;
        padding: 10px;
    }

    /* Tree Nodes Mobile */
    .tree-container {
        padding: 10px;
    }

    .node-header {
        flex-wrap: wrap;
        padding: 10px;
        gap: 5px;
    }

    .node-code {
        font-size: 0.75rem;
        padding: 2px 6px;
    }

    .node-title {
        font-size: 0.85rem;
        flex: 1 1 100%;
        margin-top: 5px;
    }

    .node-count {
        display: none;
    }

    .node-icon {
        font-size: 1rem;
    }

    .toggle-icon {
        font-size: 0.7rem;
    }

    /* Component Details Mobile */
    .component-header {
        flex-wrap: wrap;
        gap: 5px;
    }

    .component-details {
        padding-left: 0;
        padding: 8px;
        font-size: 0.8rem;
    }

    .detail-row {
        flex-direction: column;
        gap: 3px;
    }

    .detail-label {
        min-width: auto;
    }

    /* Node Children Mobile */
    .node-children {
        padding-left: 10px;
        margin-left: 5px;
    }

    .assembly-node > .node-header,
    .component-node {
        margin-left: 5px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .container {
        padding: 5px;
        padding-top: 70px;
    }

    header h1 {
        font-size: 1rem;
    }

    .header-logo {
        width: 50px;
        height: 50px;
    }

    .node-header {
        padding: 8px;
    }

    .node-title {
        font-size: 0.8rem;
    }

    .service-badge {
        font-size: 0.65rem;
        padding: 2px 5px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #16213e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #00d9ff;
}

/* Animation for nodes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.node-children:not(.hidden) {
    animation: fadeIn 0.3s ease;
}
