/* ============================================
   IT-Хаб: Основные стили
   Тёмная/Светлая тема, glassmorphism, анимации
   ============================================ */

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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --bg-body: #0a0e27;
    --bg-sidebar: rgba(15, 18, 45, 0.95);
    --bg-card: rgba(20, 25, 60, 0.8);
    --bg-card-hover: rgba(30, 35, 80, 0.9);
    --bg-input: rgba(30, 35, 70, 0.8);
    --border-color: rgba(99, 102, 241, 0.15);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-sidebar: rgba(255, 255, 255, 0.97);
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --bg-input: #f8fafc;
    --border-color: rgba(99, 102, 241, 0.12);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
}

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

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 270px;
    height: 100vh;
    max-height: 100vh;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sidebar-brand small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--primary-light);
}

.nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.nav-link .badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

.nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-user .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 270px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.top-bar {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar .page-title {
    font-size: 1.3rem;
    font-weight: 700;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.content-area {
    flex: 1;
    padding: 1.5rem 2rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    background: var(--bg-card-hover);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: var(--bg-card);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card .stat-glow {
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    opacity: 0.08;
    pointer-events: none;
}

/* ===== TABLES ===== */
.table {
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    margin-bottom: 0;
}

.table th {
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.9rem;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--primary-light);
}

/* ===== FORMS ===== */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    color: var(--text-primary);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

textarea.form-control {
    min-height: 100px;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.5rem 1.25rem;
    transition: var(--transition);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    border-radius: 10px;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-sm { border-radius: 8px; font-size: 0.8rem; padding: 0.35rem 0.75rem; }
.btn-xs { border-radius: 6px; font-size: 0.75rem; padding: 0.2rem 0.5rem; }

/* ===== BADGES ===== */
.badge {
    font-weight: 500;
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

/* ===== MODAL ===== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

/* ===== ONLINE INDICATOR ===== */
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.online-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.online-dot.offline { background: var(--text-muted); }

/* ===== CHAT ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease;
}

.chat-message.own {
    flex-direction: row-reverse;
}

.chat-message .msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: #fff;
    flex-shrink: 0;
}

.chat-message .msg-bubble {
    max-width: 70%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.75rem 1rem;
}

.chat-message.own .msg-bubble {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    color: #fff;
}

.chat-message .msg-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.chat-message.own .msg-name {
    color: rgba(255,255,255,0.7);
    text-align: right;
}

.chat-message .msg-text {
    font-size: 0.9rem;
    word-wrap: break-word;
}

.chat-message .msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.chat-message.own .msg-time {
    color: rgba(255,255,255,0.5);
    text-align: right;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
}

.chat-input-area .form-control {
    flex: 1;
}

/* ===== TICKET BOARD ===== */
.ticket-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.ticket-column {
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.ticket-column-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ticket-item {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.ticket-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ticket-item .ticket-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.ticket-item .ticket-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== CONFIG EDITOR ===== */
.config-editor {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 300px;
    resize: vertical;
    tab-size: 4;
    white-space: pre;
}

/* ===== TOPOLOGY ===== */
.topology-canvas {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

.topology-node {
    position: absolute;
    background: var(--bg-card-hover);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
    text-align: center;
    cursor: move;
    transition: box-shadow 0.3s;
    min-width: 120px;
    z-index: 10;
}

.topology-node:hover {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    border-color: var(--primary);
}

.topology-node .node-icon {
    font-size: 2rem;
    margin-bottom: 0.3rem;
}

.topology-node .node-name {
    font-size: 0.75rem;
    font-weight: 600;
}

.topology-node .node-ip {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-in {
    animation: slideIn 0.4s ease forwards;
}

/* ===== MOBILE TOGGLE ===== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ===== ALERT STYLES ===== */
.alert {
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .top-bar {
        padding: 0.75rem 1rem;
    }

    .top-bar .page-title {
        font-size: 1rem;
    }

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

/* ===== THEME SWITCH ===== */
.theme-switch {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    display: inline-block;
}

.theme-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    transition: var(--transition);
}

[data-theme="light"] .theme-switch::after {
    transform: translateX(20px);
    background: var(--warning);
}

/* ===== HEALTH BAR ===== */
.health-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(99, 102, 241, 0.1);
    overflow: hidden;
}

.health-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ===== DROPDOWN ===== */
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}

.dropdown-item {
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

.dropdown-divider {
    border-color: var(--border-color);
}

/* ===== OPTICAL LINKS ===== */
.optical-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

/* ===== PORT STATUS COLORS ===== */
.port-up { color: var(--success); }
.port-down { color: var(--danger); }
.port-disabled { color: var(--text-muted); }

/* ===== TOPOLOGY CONTEXT MENU ===== */
.topo-ctx-item {
    padding: 8px 16px;
    cursor: pointer;
    color: #1e293b;
    transition: background .15s;
    display: flex;
    align-items: center;
}
.topo-ctx-item:hover {
    background: #f1f5f9;
}


