:root {
    --bg-dark: #020617;
    --sidebar-bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.6);
    --primary: #22d3ee;
    --accent: #3b82f6;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --success: #10b981;
    --danger: #f43f5e;
    --border: rgba(255, 255, 255, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: radial-gradient(circle at 50% -20%, #1e1b4b 0%, var(--bg-dark) 50%, #000 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(34, 211, 238, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(34, 211, 238, 0.4);
}

.app-container {
    display: flex;
    height: 100%;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.logo-shield {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.brand h2 {
    font-weight: 700;
    line-height: 1.2;
    background: linear-gradient(to right, #fff, var(--primary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    padding-right: 5px;
}

nav::-webkit-scrollbar {
    width: 4px;
}

nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-item {
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text-dim);
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(34, 211, 238, 0.1);
    color: var(--primary);
}

.icon {
    font-weight: bold;
    opacity: 0.7;
}

.status-panel {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    margin-right: 10px;
}

.indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(34, 211, 238, 0.05), transparent 25%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.05), transparent 25%);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.badge {
    background: rgba(34, 211, 238, 0.1);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.desc {
    color: var(--text-dim);
    margin-bottom: 2rem;
}

.kem-visualizer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3rem 0;
    padding: 0 4rem;
}

.node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-6px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.card,
.glass-panel {
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.node-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    border: 2px solid var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.2);
    animation: float 4s ease-in-out infinite;
}

.logo-shield {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation: pulse-glow 3s infinite;
}

.connection-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 2rem;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.packet {
    position: absolute;
    padding: 4px 8px;
    background: var(--accent);
    border-radius: 4px;
    font-size: 0.75rem;
    opacity: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: 0.3s;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.secret-val {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--primary);
}

.btn-action {
    background: linear-gradient(135deg, var(--primary) 0%, #06b6d4 100%);
    color: #000;
    border: none;
    padding: 12px 28px;
    border-radius: 12px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
    margin: 6px;
    position: relative;
    overflow: hidden;
}

.btn-action::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    transition: 0s;
}

.btn-action:hover::after {
    transform: translateX(100%);
    transition: 0.5s;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(34, 211, 238, 0.6);
        transform: scale(1.02);
    }

    100% {
        box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
    }
}

.btn-pulse {
    animation: pulse-glow 2s infinite;
}

.btn-action:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(34, 211, 238, 0.6);
    filter: brightness(1.1);
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.console-box {
    background: #000;
    border-radius: 8px;
    padding: 1rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: #a5f3fc;
    border: 1px solid var(--border);
    min-height: 100px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-width: 100%;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 1rem;
}

table {
    min-width: 600px;
    /* Force scroll on small screens */
}

.workflow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
    margin-top: 2rem;
}

.step-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
    position: relative;
}

.step-num {
    position: absolute;
    top: -10px;
    right: 10px;
    font-size: 3rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.03);
}

.hash-text {
    word-break: break-all;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 10px;
    border-left: 2px solid var(--border);
    padding-left: 8px;
}

.btn-subtle {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    margin: 6px;
    width: auto;
    min-width: 140px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.btn-subtle:hover:not(:disabled) {
    background: rgba(34, 211, 238, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.1);
    transform: translateY(-1px);
}

.btn-subtle.active {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    color: #10b981;
}

.result-badge {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 10px;
}

.drop-interface {
    display: flex;
    flex-wrap: wrap;
    gap: 3rem;
    margin-top: 2rem;
}

.drop-zone {
    flex: 1;
    min-width: 300px;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
}

input[type="text"],
select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    padding: 8px;
    color: var(--text-main);
    border-radius: 4px;
    margin: 10px 0;
}

.content-full-width {
    grid-column: 1 / -1;
    border: 1px solid rgba(244, 63, 94, 0.3);
    background: rgba(244, 63, 94, 0.05);
}

.hacker-controls {
    display: flex;
    gap: 1rem;
}

.hacker-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    transition: all 0.3s;
}

.hacker-input:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.2);
}

.btn-danger {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.4);
}

.small-desc {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

#msg-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    margin-bottom: 10px;
    transition: all 0.3s;
}

#msg-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.1);
    outline: none;
}

.drop-zone {
    margin-bottom: 20px;
}

.drop-area {
    margin-top: 20px;
    border: 2px dashed var(--border);
    padding: 2rem;
    text-align: center;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    transition: 0.2s;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    background-image: url('/static/avatar.png');
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.hacker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--danger);
    margin-bottom: 0.5rem;
}

.drag-drop-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: 0.3s;
    background: rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    margin-top: 20px;
    position: relative;
    overflow: hidden;
}

.drag-drop-area:hover:not(.disabled),
.drag-drop-area.highlight {
    border-color: var(--primary);
    background: rgba(34, 211, 238, 0.05);
}

.drag-drop-area.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.3);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.sub-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    display: block;
    margin-top: 5px;
}

.file-display {
    text-align: center;
    font-size: 0.9rem;
    color: var(--success);
    margin-bottom: 1rem;
    min-height: 1.2em;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.full-width {
    width: 100%;
}

.btn-action.small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.mobile-only {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        z-index: 1000;
        transition: 0.3s ease;
        padding-top: 1rem;
    }

    .sidebar.active {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .mobile-only {
        display: block;
    }

    .top-bar h1 {
        font-size: 1.2rem;
    }

    .content-area {
        padding: 1rem;
    }

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

    .drop-interface {
        flex-direction: column;
    }

    .drop-zone {
        min-width: 0;
    }

    .kem-visualizer {
        flex-direction: column;
        gap: 2rem;
        padding: 0;
    }

    .connection-line {
        width: 2px;
        height: 50px;
        margin: 1rem 0;
    }

    .btn-action,
    .btn-subtle {
        width: 100%;
        margin: 6px 0;
        min-height: 48px;
        /* Better touch target */
    }

    .hacker-controls {
        flex-direction: column;
    }

    .drop-zone {
        padding: 1rem;
    }

    .card,
    .glass-panel {
        padding: 1rem;
    }

    /* Fix Stego Canvas */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Fix PKI Textareas */
    textarea {
        max-width: 100%;
    }

    /* Network Guard Chart */
    .chart-container {
        min-height: 250px;
        margin-top: 1rem !important;
    }

    /* Fix long hashes in mobile */
    .hash-text {
        font-size: 0.7rem;
        word-break: break-all;
    }
}

.chart-container {
    min-height: 400px;
    margin-top: 20px;
}

#tab-network .step-num {
    font-size: 1.8rem;
    position: relative;
    top: auto;
    right: auto;
    color: var(--text-main);
    margin: 10px 0;
    width: 100%;
}

#tab-network .step-card,
#tab-health .step-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#tab-health .step-num {
    font-size: 2rem;
    position: relative;
    top: auto;
    right: auto;
    color: var(--text-main);
    margin: 10px 0;
    width: 100%;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    background: #0f172a;
    border: 1px solid var(--primary);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: 0.2s;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    color: var(--text-main);
    line-height: 1.6;
    word-break: break-word;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    text-align: right;
}

@keyframes moveRight {
    0% {
        left: 0;
        opacity: 1;
        transform: translateY(-150%) translateX(0);
    }

    90% {
        opacity: 1;
    }

    100% {
        left: 100%;
        opacity: 0;
        transform: translateY(-150%) translateX(-100%);
    }
}

@keyframes moveLeft {
    0% {
        left: 100%;
        opacity: 1;
        transform: translateY(50%) translateX(0);
    }

    90% {
        opacity: 1;
    }

    100% {
        left: 0;
        opacity: 0;
        transform: translateY(50%) translateX(-100%);
    }
}

.packet.animate-right {
    animation: moveRight 1.5s ease-in-out forwards;
}

.packet.animate-left {
    animation: moveLeft 1.5s ease-in-out forwards;
}