/* Local Fonts - Vazirmatn Complete Family */
@font-face {
    font-family: 'Vazirmatn';
    src: url('/static/vendor/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/static/vendor/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/static/vendor/Vazirmatn-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/static/vendor/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Local Fonts - JetBrains Mono for Code, Numbers & Technical Data */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/vendor/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/static/vendor/JetBrainsMono-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* Reset & Core Utilities */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --border-color: rgba(255, 255, 255, 0.08);
}

html, body {
    background-color: #0b0f19;
    color: #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', 'Vazirmatn', sans-serif;
    direction: ltr;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

code, pre, .font-mono {
    font-family: 'JetBrains Mono', monospace !important;
    letter-spacing: 0 !important;
    font-feature-settings: normal !important;
}

/* Ensure hidden works unconditionally */
.hidden {
    display: none !important;
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
}
::-webkit-scrollbar-thumb {
    background: rgba(51, 65, 85, 0.8);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.9);
}

/* Glassmorphism Panels & Cards */
.glass-panel {
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Login Page Direct Styling Fallbacks */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.login-card {
    width: 100%;
    max-width: 28rem;
    padding: 2rem;
    border-radius: 1.5rem;
    background: rgba(17, 24, 39, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}
.login-input {
    width: 100%;
    background-color: rgba(2, 6, 23, 0.85);
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #ffffff;
    font-family: inherit;
    transition: all 0.2s ease;
}
.login-input:focus {
    outline: none;
    border-color: #22d3ee;
    box-shadow: 0 0 0 1px #22d3ee;
}

.glass-card {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 1rem;
    transition: all 0.2s ease;
}

.glass-card:hover {
    border-color: rgba(6, 182, 212, 0.25);
    box-shadow: 0 4px 20px -2px rgba(6, 182, 212, 0.06);
}

.glass-header {
    background: rgba(11, 15, 25, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Buttons */
.btn-gradient {
    background: linear-gradient(135deg, #06b6d4 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.25);
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}
.btn-gradient:hover {
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    transition: all 0.2s ease;
    cursor: pointer;
}
.btn-secondary:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.btn-danger {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}
.btn-danger:hover {
    filter: brightness(1.1);
    box-shadow: 0 2px 12px rgba(244, 63, 94, 0.35);
}

/* Navigation items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 0.9rem;
    border-radius: 0.75rem;
    font-size: 0.825rem;
    font-weight: 500;
    color: #94a3b8;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-align: left;
    cursor: pointer;
}
.nav-item:hover {
    color: #ffffff;
    background: rgba(30, 41, 59, 0.65);
}
.nav-item.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
    border: 1px solid rgba(6, 182, 212, 0.35);
    box-shadow: 0 2px 10px rgba(6, 182, 212, 0.1);
}
.nav-item.active svg {
    color: #22d3ee;
}

/* Terminal Tab */
.term-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.15s ease;
    cursor: pointer;
}
.term-tab-btn:hover {
    color: #ffffff;
    background: rgba(30, 41, 59, 0.9);
}
.term-tab-btn.active {
    color: #38bdf8;
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.35);
}

/* Xterm overrides */
.xterm {
    padding: 0.5rem;
    height: 100%;
}
.xterm .xterm-viewport {
    background-color: transparent !important;
}

/* Badges */
.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-inactive {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* ========================================================
   Mobile Optimization & Responsive Styling
   ======================================================== */
@media (max-width: 768px) {
    /* Mobile Drawer Sidebar (LTR) */
    .sidebar-drawer {
        position: fixed !important;
        top: 0;
        bottom: 0;
        left: 0;
        right: auto !important;
        width: 280px !important;
        max-width: 85vw;
        z-index: 60 !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 35px rgba(0, 0, 0, 0.85);
    }
    .sidebar-drawer.mobile-open {
        transform: translateX(0) !important;
    }

    #mobile-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.75);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 55;
        transition: opacity 0.25s ease;
    }

    /* Mobile Bottom Navigation Bar */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(11, 15, 25, 0.94);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        align-items: center;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        z-index: 45;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }
    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        flex: 1;
        height: 100%;
        color: #94a3b8;
        font-size: 10px;
        font-family: inherit;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: all 0.15s ease;
    }
    .mobile-nav-btn:hover {
        color: #e2e8f0;
    }
    .mobile-nav-btn.active {
        color: #22d3ee;
    }
    .mobile-nav-btn.active svg {
        color: #22d3ee;
        transform: scale(1.15);
    }

    /* Content padding on mobile to leave space for bottom nav */
    .tab-pane {
        padding: 0.85rem !important;
        padding-bottom: 5.25rem !important;
    }

    /* Header sizing on mobile */
    header.glass-header {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
        height: 3.5rem !important;
    }
    header.glass-header h2 {
        font-size: 0.95rem !important;
    }

    /* Terminal container on mobile */
    #tab-terminal {
        height: calc(100vh - 7rem) !important;
        padding-bottom: 5.25rem !important;
    }

    /* Smooth touch scrolling for tables */
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile grid gaps */
    .grid {
        gap: 0.75rem !important;
    }

    /* Card padding */
    .glass-card {
        padding: 0.85rem !important;
    }
}

/* Mobile Virtual Terminal Keyboard Toolbar */
.mobile-term-toolbar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.4rem 0.5rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    margin-top: 0.35rem;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}
.mobile-key-btn {
    padding: 0.35rem 0.65rem;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.1s ease;
}
.mobile-key-btn:active {
    background: #06b6d4;
    color: #0b0f19;
    font-weight: bold;
    transform: scale(0.95);
}
