/* Ported Design System from portfolio-tau-two-nisfaoe6cp.vercel.app */
:root {
    --bg-color: #000000;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, .6);
    --text-muted: rgba(255, 255, 255, .35);
    
    --font-serif: "Playfair Display", serif;
    --font-sans: "Inter", sans-serif;
    
    --glass-bg: rgba(255, 255, 255, .05);
    --glass-border: rgba(255, 255, 255, .1);
    --glass-border-hover: rgba(255, 255, 255, .25);
    
    --accent-blue: #38bdf8;
    --accent-violet: #a78bfa;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    
    --blue-glow: rgba(56, 189, 248, 0.2);
    --violet-glow: rgba(167, 139, 250, 0.2);
    --green-glow: rgba(52, 211, 153, 0.25);
}

/* Reset and Global Elements */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    background: radial-gradient(circle at 50% 50%, #111, #000 70%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 5rem;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* Navigation / Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 1.25rem 2.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    margin-bottom: 1rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo-icon {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-style: italic;
    color: var(--text-primary);
}

.header-title-wrapper h1 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.subtitle {
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: .2em;
    font-size: .65rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.system-status {
    display: flex;
    gap: 1.25rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    padding: 0.45rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.green {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.yellow {
    background-color: var(--accent-yellow);
    box-shadow: 0 0 8px var(--accent-yellow);
}

.status-dot.red {
    background-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

/* Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 2.5rem;
}

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.column-left, .column-right {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* Cards System */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 2.5rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    transition: transform .5s cubic-bezier(.16,1,.3,1), border-color .5s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--glass-border-hover);
}

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

.card-header h2 {
    font-family: var(--font-serif);
    font-size: 1.65rem;
    font-weight: 400;
    color: var(--text-primary);
}

.section-label {
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: .2em;
    font-size: .7rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Forms & Inputs */
.simulator-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-group label {
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: .15em;
    font-size: .65rem;
    font-weight: 500;
    color: var(--text-secondary);
}

textarea, input[type="text"], select {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 300;
    outline: none;
    transition: border-color 0.3s, background-color 0.3s;
}

textarea {
    resize: none;
    height: 110px;
    line-height: 1.6;
}

textarea:focus, input[type="text"]:focus, select:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.04);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* Range Slider */
.slider-container {
    height: 44px;
    display: flex;
    align-items: center;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    height: 3px;
    border-radius: 99px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(.16,1,.3,1);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.4);
}

/* Action Buttons (Vercel Portfolio CTA style) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: .15em;
    font-size: .75rem;
    font-weight: 500;
    padding: 1.1rem 2.25rem;
    border-radius: 100px;
    border: none;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s cubic-bezier(.16,1,.3,1), border-color 0.3s;
    outline: none;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-color);
}

.btn-primary:hover {
    background: #dddddd;
    transform: scale(1.03);
}

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.25);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.18);
    border-color: var(--accent-red);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    font-size: 0.9rem;
    border-radius: 50%;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Spinner */
.spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    border-top-color: black;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.metric-box {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: center;
}

.metric-label {
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: .15em;
    font-size: .6rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 2rem;
    font-weight: 300;
    font-family: var(--font-sans);
}

.text-glow-blue {
    color: var(--accent-blue);
    text-shadow: 0 0 10px var(--blue-glow);
}

.text-glow-green {
    color: var(--accent-green);
    text-shadow: 0 0 10px var(--green-glow);
}

.text-glow-purple {
    color: var(--accent-violet);
    text-shadow: 0 0 10px var(--violet-glow);
}

/* Latency Savings Tracker */
.latency-savings-bar {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
}

.latency-saved-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 300;
    margin-bottom: 0.9rem;
    color: var(--text-secondary);
}

.latency-saved-label strong {
    font-weight: 500;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 99px;
    transition: width 0.5s ease-out;
}

/* Pipeline Flow Visualizer */
.pipeline-visualizer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    margin-bottom: 1.75rem;
    position: relative;
}

.pipeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    z-index: 2;
    text-align: center;
    position: relative;
    width: 75px;
}

.node-icon {
    width: 46px;
    height: 46px;
    background: #080808;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.4s cubic-bezier(.16,1,.3,1), border-color 0.4s, box-shadow 0.4s;
}

.pipeline-node span {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.node-meta {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    position: absolute;
    bottom: -1.25rem;
    white-space: nowrap;
}

/* Active Pipeline States */
.pipeline-node.active .node-icon {
    border-color: var(--text-primary);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    transform: scale(1.12);
}

.pipeline-node.active span {
    color: var(--text-primary);
}

.pipeline-node.success-glow.active .node-icon {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.35);
}

.pipeline-node.error-glow.active .node-icon {
    border-color: var(--accent-red);
    box-shadow: 0 0 15px rgba(248, 113, 113, 0.35);
}

/* SVG Pipeline Connectors */
.pipeline-line {
    stroke: var(--glass-border);
    stroke-width: 1.5px;
    fill: none;
    transition: stroke 0.3s, stroke-width 0.3s, stroke-dasharray 0.3s, filter 0.3s;
}

.pipeline-line.active {
    stroke: var(--accent-blue);
    stroke-width: 2.5px;
    stroke-dasharray: 6;
    animation: pipelineDash 1.2s linear infinite;
    filter: drop-shadow(0 0 5px var(--blue-glow));
}

#connector-hit-1.active, #connector-hit-2.active {
    stroke: var(--accent-green);
    filter: drop-shadow(0 0 6px var(--green-glow));
}

#connector-miss-1.active, #connector-miss-2.active, #connector-miss-3.active, #connector-miss-4.active {
    stroke: var(--accent-violet);
    filter: drop-shadow(0 0 6px var(--violet-glow));
}

@keyframes pipelineDash {
    to {
        stroke-dashoffset: -12;
    }
}

/* Split Pathways */
.pipeline-split-container {
    display: flex;
    flex-direction: column;
    gap: 2.75rem;
    flex-grow: 2.2;
    position: relative;
}

.split-path {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hit-path {
    justify-content: center;
}

/* Performance Alert Panel */
.performance-panel {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(52, 211, 153, 0.02);
    border: 1px solid rgba(52, 211, 153, 0.15);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.75rem;
}

.performance-panel.miss-alert {
    background: rgba(167, 139, 250, 0.02);
    border-color: rgba(167, 139, 250, 0.15);
}

.performance-panel.hidden {
    display: none;
}

.perf-metric {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.perf-metric strong {
    color: var(--text-primary);
}

.perf-divider {
    width: 1px;
    height: 16px;
    background: var(--glass-border);
}

/* Console Output Component */
.console-output {
    background: #050505;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
}

.console-header {
    background: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--glass-border);
    padding: 0.6rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
}

.console-timestamp {
    color: var(--text-muted);
}

.console-text {
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.7;
    height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* Cache Inspector (Bottom layout) */
.bottom-card {
    padding: 2.25rem 2.5rem;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.invalidation-form {
    display: flex;
    gap: 0.6rem;
}

.invalidation-form input {
    height: 38px;
    width: 160px;
    font-size: 0.8rem;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.invalidation-form .btn {
    padding: 0.5rem 1.25rem;
}

/* Keys Table */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.2);
}

.keys-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.keys-table th {
    background: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-weight: 500;
    padding: 1rem 1.5rem;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}

.keys-table td {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-weight: 300;
}

.keys-table tbody tr {
    transition: background-color 0.3s;
}

.keys-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

.keys-table tr:last-child td {
    border-bottom: none;
}

.font-mono {
    font-family: var(--font-mono);
}

.empty-state {
    text-align: center;
    padding: 4rem !important;
    color: var(--text-muted);
    font-style: italic;
}

.btn-delete-row {
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: transparent;
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: #fca5a5;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-delete-row:hover {
    background: rgba(248, 113, 113, 0.12);
    border-color: var(--accent-red);
}

/* Responsive & Mobile Optimization Styles */
.pipeline-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1.5rem; /* Space for horizontal scrollbar */
    margin-bottom: 0.5rem;
}

.pipeline-visualizer {
    min-width: 850px; /* Prevent visualizer from crushing on small screens */
}

/* Tablet and Smartphone Layout Tweaks */
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 1.25rem;
        padding: 1.5rem;
        border-radius: 24px;
        text-align: center;
    }
    
    .system-status {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .logo-area {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card {
        padding: 1.75rem;
        border-radius: 24px;
    }
    
    .performance-panel {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding: 1.25rem;
    }
    
    .perf-divider {
        display: none; /* Hide vertical dividers when stacked */
    }
    
    .perf-metric {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
}

@media (max-width: 576px) {
    .app-container {
        padding: 1rem 0.75rem;
        gap: 1.25rem;
    }
    
    .card {
        padding: 1.25rem;
        border-radius: 20px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .simulator-form .form-row {
        flex-direction: column;
        gap: 1.25rem;
    }
    
    .invalidation-form {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .invalidation-form input {
        width: 100% !important;
    }
    
    .invalidation-form .btn {
        width: 100%;
    }
    
    .header-right {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .header-right .btn {
        width: 100%;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr; /* Single column of stats on very narrow mobile */
        gap: 0.75rem;
    }
}
