:root {
    /* Colors */
    --bg-dark: #0f0f13;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary: #00ff9d;
    /* Neon Green */
    --primary-dim: rgba(0, 255, 157, 0.1);
    --secondary: #7000ff;
    /* Neon Purple */
    --danger: #ff4757;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;

    /* Effects */
    --blur: 10px;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Typography */
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* Global Navbar Styles */
.app-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    height: 60px;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

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

body {
    background-color: var(--bg-dark);
    /* Cyberpunk Grid Background */
    background-image:
        linear-gradient(rgba(0, 255, 157, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 157, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.15),
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 2px);
    pointer-events: none;
    z-index: 9999;
}

#app {
    width: 100%;
    min-height: 100vh;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.btn {
    background: var(--primary);
    color: #000;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-main);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--primary-dim);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="tel"],
select,
textarea {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 4px;
    color: var(--primary);
    font-family: var(--font-mono);
    width: 100%;
    transition: all 0.3s ease;
    appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-right: 0.6rem;
    cursor: pointer;
    vertical-align: middle;
    border: 2px solid var(--primary);
    border-radius: 3px;
    background: transparent;
    position: relative;
    transition: all 0.2s ease;
}

input[type="radio"] {
    border-radius: 50%;
}

input[type="checkbox"]:checked {
    background-color: var(--primary);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");
    background-size: 80%;
    background-position: center;
    background-repeat: no-repeat;
}

input[type="checkbox"]:checked::after {
    content: none;
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #000;
    border-radius: 50%;
}

#report-container canvas {
    max-height: 150px;
}

/* Platform Card Active State */
.platform-card.active {
    background: rgba(0, 255, 157, 0.1) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 15px rgba(0, 255, 157, 0.1);
}

/* Custom Select Arrow */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ff9d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s ease;
}

.toast.error {
    border-color: var(--danger);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    font-family: 'JetBrains Mono';
    font-size: 0.9rem;
    letter-spacing: 1px;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--secondary);
    border-bottom: 2px solid var(--secondary);
    background: rgba(0, 255, 157, 0.05);
}

/* Report Accordion Styles */
.accordion-item {
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.acc-header {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    font-family: 'JetBrains Mono';
    font-size: 0.9rem;
    transition: background 0.3s;
}

.acc-header:hover {
    background: rgba(0, 255, 157, 0.05);
}

.acc-body {
    max-height: 0;
    padding: 0 1.5rem;
    transition: all 0.4s ease-out;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.accordion-item.active .acc-body {
    max-height: 2000px;
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.acc-badge {
    font-size: 0.7rem;
    background: var(--primary);
    color: black;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

/* Grid Lists & Cards */
.grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.8rem;
}

.sub-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono';
    font-size: 0.8rem;
    color: var(--text-main);
}

.port-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.port-card {
    background: rgba(0, 255, 157, 0.02);
    border: 1px solid rgba(0, 255, 157, 0.1);
    padding: 1rem;
    text-align: center;
    border-radius: 8px;
}

.port-num {
    font-size: 1.5rem;
    color: var(--primary);
    font-family: 'JetBrains Mono';
    font-weight: bold;
}

.port-service {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 0.3rem 0;
}

.port-status {
    font-size: 0.65rem;
    color: #00ff00;
    letter-spacing: 1px;
}

.geo-info div {
    margin-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 0.4rem;
}

.geo-info label {
    color: var(--primary);
    font-size: 0.7rem;
    display: block;
    margin-bottom: 0.2rem;
}

.dns-grid .dns-section {
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    margin-bottom: 0.8rem;
    border-radius: 6px;
    border-left: 2px solid var(--secondary);
}

.tab-btn.active::before {
    content: '> ';
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Tab Buttons for File Analysis */
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}


/* Big Connect Button */
.big-connect-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 157, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    border: 3px solid var(--primary);
    box-shadow: 0 0 30px rgba(0, 255, 157, 0.2), inset 0 0 20px rgba(0, 255, 157, 0.1);
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: pulse 3s infinite;
}

.big-connect-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(0, 255, 157, 0.4), inset 0 0 30px rgba(0, 255, 157, 0.2);
    text-shadow: 0 0 10px var(--primary);
}

.big-connect-btn:active {
    transform: scale(0.95);
}

/* Progress Bar Component */
.fs-progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1rem;
    position: relative;
    display: none;
}

.fs-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px var(--primary);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.4);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(0, 255, 157, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0);
    }
}

/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */

/* Sidebar Toggle Buttons (Hidden on Desktop) */
.hamburger-btn,
.sidebar-close-btn,
.sidebar-overlay {
    display: none;
}

/* Navbar Brand Text */
.navbar-brand-text {
    display: block;
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 768px) {

    .mobile-only {
        display: flex !important;
    }

    /* --- Layout Adjustments --- */
    body {
        font-size: 14px;
    }

    .container {
        padding: 1rem 0.5rem;
        /* Reduce side padding on mobile */
        width: 100%;
        overflow-x: hidden;
        /* Prevent horizontal scroll on body */
    }

    /* Fixed Sidebar (Off-canvas) */
    #app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px !important;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        background: rgba(15, 15, 19, 0.95) !important;
        border-right: 1px solid var(--border-color);
        padding-top: 1rem !important;
    }

    #app-sidebar.open {
        transform: translateX(0);
    }

    /* Overlay */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(3px);
        z-index: 1050;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Buttons */
    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--primary);
        font-size: 1.5rem;
        padding: 0.5rem;
        cursor: pointer;
        margin-right: 0.5rem;
    }

    .sidebar-close-row {
        display: flex;
        justify-content: flex-end;
        padding: 0 1rem;
        margin-bottom: 1rem;
    }

    .sidebar-close-btn {
        display: flex;
        background: transparent;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0.5rem;
    }

    /* Navbar */
    .app-navbar {
        padding: 0 1rem !important;
    }

    /* Navbar Flex Fixes */
    .app-navbar {
        display: flex !important;
        flex-direction: row !important;
        /* Force row even on mobile */
        flex-wrap: nowrap !important;
        /* Prevent wrapping */
        justify-content: space-between !important;
        align-items: center !important;
        gap: 0.5rem;
        padding: 0 0.5rem !important;
        /* Tighter padding */
        height: 60px;
    }

    .navbar-actions {
        display: none !important;
    }

    /* DESKTOP FORM LAYOUTS (Default) */
    /* Moved from inline JS to support mobile override */
    #phishing-form {
        display: grid;
        grid-template-columns: 4fr 1fr;
        gap: 1rem;
        align-items: end;
    }

    #security-form {
        display: grid;
        grid-template-columns: 2fr 4fr 1fr;
        gap: 1rem;
        align-items: end;
    }

    /* Default Chat Sidebar (Desktop) */
    /* Mobile rule overrides this with display: none */
    .chat-sidebar {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Global: Force specific control containers to stack vertically */
    .audit-controls,
    .vpn-controls,
    .url-check-box,
    .footprint-checkbox-group,
    .file-upload-area,
    .hash-row,
    #scan-form>div,
    #phishing-form>div,
    #security-form>div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    /* Ensure inputs/buttons in these stacks take full width */
    .audit-controls>*,
    .vpn-controls>*,
    .url-check-box>*,
    #scan-form input,
    #scan-form select,
    #scan-form button,
    #phishing-form input,
    #phishing-form button,
    #security-form input,
    #security-form button {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 0.5rem !important;
    }

    /* Guest Navbar Fix */
    .desktop-only {
        display: none !important;
    }

    /* Main Content Area */
    #app>div:nth-child(2) {
        /* The flex container below navbar */
        padding-top: 60px !important;
    }

    #app>div:nth-child(2)>div:nth-child(2) {
        /* The main content div */
        padding: 1rem !important;
    }

    /* Dashboard/Admin/File Grid & Phishing/Security Forms */
    .container>div[style*="grid-template-columns"],
    div[style*="grid-template-columns"],
    #phishing-form,
    #security-form {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* System Metrics Specific Fix */
    .system-metrics {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Fix stats container breaking */
    .stats-container {
        flex-direction: column;
    }

    /* Scan Results / Grids */
    .grid-list {
        grid-template-columns: 1fr;
    }

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

    /* Typography & Spacing */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    /* Tables/Pre tags - Fix horizontal scrolling */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    pre {
        font-size: 0.75rem;
        overflow-x: auto;
        padding: 0.5rem;
        white-space: pre-wrap;
        /* Wrap long lines in code blocks */
        word-break: break-all;
    }

    /* Login/Signup Cards */
    .card.glass.fade-in {
        padding: 2rem 1.5rem !important;
        width: 100% !important;
    }

    /* Chat View Specifics */
    .chat-container {
        flex-direction: column;
        position: relative;
    }

    .chat-sidebar {
        display: none !important;
        /* Default hidden on mobile unless overridden */
        position: fixed;
        top: 60px;
        left: 0;
        width: 100% !important;
        height: calc(100vh - 60px) !important;
        background: #0f0f13 !important;
        z-index: 2000;
        /* High z-index to overlay everything */
    }

    .chat-sidebar.show-mobile {
        display: flex !important;
        animation: slideInLeft 0.3s ease;
    }

    @keyframes slideInLeft {
        from {
            transform: translateX(-100%);
        }

        to {
            transform: translateX(0);
        }
    }

    /* Override Desktop Styles for Sidebar */
    /* This ensures inline styles don't bleed through on mobile */
    .chat-sidebar-desktop {
        /* This class will be added dynamically or used via JS */
    }

    /* Layout Logic */
    /* Mobile: Stack vertically */
    .mobile-vertical-stack {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .mobile-vertical-stack>* {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }

    .chat-main {
        height: calc(100vh - 60px) !important;
    }

    /* GPT-Style Input Area (Mobile adjustment) */
    .chat-input-container {
        padding: 0.5rem !important;
    }

    #chat-form {
        max-width: 100% !important;
    }

    /* Toast Position */
    #toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        width: auto;
    }

    /* --- View Specific Mobile Fixes --- */

    /* Digital Footprint */
    #footprint-form {
        grid-template-columns: 1fr !important;
    }

    .footprint-checkbox-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Network Scan Results */
    .scan-result-grid {
        grid-template-columns: 1fr !important;
    }

    /* Security Audit */
    .audit-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .audit-controls select,
    .audit-controls input,
    .audit-controls button {
        width: 100% !important;
    }

    /* Phishing Detector */
    .phishing-container {
        padding: 0 !important;
    }

    .url-check-box {
        flex-direction: column;
        gap: 1rem;
    }

    .url-check-box input,
    .url-check-box button {
        width: 100%;
        border-radius: 6px !important;
    }

    /* File Analysis */
    .file-upload-area {
        padding: 1rem !important;
    }

    .hash-row {
        flex-direction: column;
    }

    .hash-row input {
        border-radius: 6px !important;
        margin-bottom: 0.5rem;
    }

    /* VPN View */
    .vpn-server-list {
        grid-template-columns: 1fr !important;
    }

    .vpn-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .vpn-connect-btn {
        width: 100% !important;
    }

    /* Settings / Profile */
    .profile-grid {
        grid-template-columns: 1fr !important;
    }

    .settings-form .form-group {
        margin-bottom: 1rem;
    }

    /* Admin User Row - Mobile Stack */
    .user-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .user-row>div {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
}