/* Global variables reflecting the reference theme */
:root {
    --bg-color: #0f172a;
    /* Deep Charcoal/Dark Blue */
    --card-bg: rgba(30, 41, 59, 0.7);
    /* Slightly lighter transparent for cards */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    --accent-cyan: #2dd4bf;
    /* Cyan/Turquoise */
    --accent-purple: #a855f7;
    /* Electric Purple */

    --font-family: 'Inter', sans-serif;
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    line-height: 1.6;
    padding: 2rem;
    min-height: 100vh;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* App Header Structure */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--card-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Landing Page Specific Sizing */
.landing-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hero-section {
    text-align: center;
    padding: 6rem 1rem 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-headline {
    font-size: 3.5rem;
    line-height: 1.1;
    letter-spacing: -1px;
    margin-bottom: 1.5rem;
    background: linear-gradient(90deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    max-width: 800px;
}

.hero-subheadline {
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto 3rem;
    color: var(--text-secondary);
}

.hero-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.about-section {
    margin-top: -2rem;
}

.about-text p {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.header-logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-user {
    display: flex;
    align-items: center;
}

/* Dashboard Layout Structure */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* User Badge & Cabinet Toggle Button */
.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cabinet-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    padding: 0.4rem 1.2rem 0.4rem 0.4rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: left;
}

.cabinet-toggle-btn:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.2);
}

.user-avatar {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 50%;
    font-size: 1rem;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#user-email-display {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.1;
}

.balance-text {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 600;
    line-height: 1.1;
    margin-top: 2px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.4rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-speed);
}

.btn-ghost:hover {
    color: #ef4444;
    /* Subtle red tint on hover to signify logout */
    background: rgba(239, 68, 68, 0.1);
}

/* Header styling (Page Level) */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.title-section h1 {
    font-size: 2rem;
    letter-spacing: -0.5px;
}

.session-badge span {
    background-color: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Common Card Style */
.card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border */
    border-radius: var(--border-radius);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    /* Glassmorphic effect */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Metric Summary Row */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.metric-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Main Content Grid */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Metaprograms Section */
.metaprograms-section {
    display: flex;
    flex-direction: column;
}

.card-header {
    margin-bottom: 2rem;
}

/* Progress List Group (Reusable) */
.progress-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Responsive Grid List */
.grid-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Individual Progress Item */
.progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

/* The actual bar container */
.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    /* Very faint grey track */
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

/* The filled part of the bar */
.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    /* Default gradient: cyan on left, blending towards purple or fading */
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.4);
    /* subtle glow */
    transition: width 1s ease-in-out;
}

/* Helper to color bars differently based on section or value if needed */
.progress-bar-fill.purple-dominant {
    background: linear-gradient(90deg, var(--accent-purple), #d8b4fe);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

.progress-bar-fill.cyan-dominant {
    background: linear-gradient(90deg, #5eead4, var(--accent-cyan));
}


/* Right Column Layout */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Charts Grid Section (2x2 Layout) */
.charts-grid-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .charts-grid-section {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    position: relative;
    height: auto;
    min-height: 300px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.chart-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.chart-type-select {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-family: var(--font-family);
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.chart-type-select:hover {
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.chart-type-select option {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

canvas {
    max-height: 250px;
    width: 100% !important;
    /* Force fit inside container */
}



/* Input / Output Elements */
.text-input {
    width: 100%;
    min-height: 120px;
    background-color: rgba(15, 23, 42, 0.8);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
    font-family: var(--font-family);
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-speed);
    margin-bottom: 1rem;
}

.text-input:focus {
    border-color: var(--accent-cyan);
}

.action-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.primary-btn {
    background: linear-gradient(90deg, var(--accent-cyan), #0d9488);
    color: #0f172a;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.3);
}

.pulse-glow {
    background: linear-gradient(90deg, var(--accent-purple), #7e22ce);
    color: white;
}

.pulse-glow:hover {
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
}

/* Base Loader */
.loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-bottom-color: var(--accent-cyan);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

.hidden {
    display: none !important;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Range Slider Styling */
.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: transparent;
    outline: none;
    position: absolute;
    /* Overlay on top of the visual progress bar */
    top: 0;
    left: 0;
    margin: 0;
    z-index: 2;
    cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--accent-cyan);
    transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-slider.purple-thumb::-webkit-slider-thumb {
    border: 2px solid var(--accent-purple);
}

/* Relative positioning for the progress item to hold the absolute slider */
.progress-bar-container {
    position: relative;
    width: 100%;
    height: 8px;
    border-radius: 4px;
}

/* Compact Mode for Sliders */
.compact-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
    width: 100%;
}

.compact-mode .progress-item {
    margin-bottom: 0;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
}

.compact-mode .progress-bar-bg {
    display: none;
    /* Hide visual bars in compact mode */
}

/* Make range slider relative so it sits normally in document flow in compact mode */
.compact-mode .range-slider {
    position: relative;
    margin-top: 5px;
    height: 6px;
}

/* Radio Button Styling */
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.radio-label:hover {
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    accent-color: var(--accent-cyan);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Tooltip Styles */
.info-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: bold;
    cursor: help;
    margin-left: 6px;
    position: relative;
    vertical-align: middle;
    transition: background 0.2s, color 0.2s;
}

.info-icon:hover {
    background: var(--accent-cyan);
    color: #0f172a;
}

.block-info-icon {
    width: 20px;
    height: 20px;
    font-size: 0.85rem;
    margin-left: 8px;
    vertical-align: text-bottom;
}

/* The actual tooltip box */
.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: normal;
    font-family: var(--font-family);
    line-height: 1.5;
    white-space: pre-line;
    /* important for newlines in tooltip text */
    width: max-content;
    max-width: 300px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    z-index: 9999;
    pointer-events: none;
    text-align: left;
}

/* Arrow pointing down */
.info-icon::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 9999;
}

.info-icon:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -8px);
}

.info-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* --- LANDING PAGE OVERLAY --- */
.blurred-background {
    filter: blur(8px) brightness(0.6);
    pointer-events: none;
    transition: filter 0.6s ease, brightness 0.6s ease;
}

.intent-grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.85);
    /* Dark base */
    backdrop-filter: blur(15px);
    /* Strong glass effect */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.intent-grid-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.intent-grid-overlay .overlay-headline {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 2.5rem;
    text-align: center;
    letter-spacing: -0.5px;
    font-weight: 600;
}

.intent-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    max-width: 800px;
    width: 90%;
}

.grid-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 2rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

/* Subtle glow behind card */
.grid-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.grid-card:hover {
    transform: translateY(-5px);
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.grid-card:hover::before {
    opacity: 1;
}

/* Specific glows based on intent */
.card-read:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 10px 30px rgba(45, 212, 191, 0.15);
}

.card-test:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.15);
}

.card-api:hover {
    border-color: #3b82f6;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.15);
}

.card-ad:hover {
    border-color: #f59e0b;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.15);
}

.grid-card h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.grid-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    flex-grow: 1;
    position: relative;
    z-index: 1;
}

.grid-cta {
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    margin-top: auto;
    position: relative;
    z-index: 1;
}

.card-read .grid-cta {
    color: var(--accent-cyan);
}

.card-test .grid-cta {
    color: var(--accent-purple);
}

.card-api .grid-cta {
    color: #3b82f6;
}

.card-ad .grid-cta {
    color: #f59e0b;
}

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

    .intent-grid-overlay .overlay-headline {
        font-size: 2rem;
    }
}

/* ─── Landing Page Navigation ─── */
.landing-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.6rem 2rem;
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 73px;
    /* below the app-header */
    z-index: 90;
    flex-wrap: wrap;
}

.landing-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.landing-nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
}

.primary-nav-link {
    color: var(--accent-cyan) !important;
    border: 1px solid rgba(45, 212, 191, 0.3);
}

.primary-nav-link:hover {
    background: rgba(45, 212, 191, 0.1) !important;
    border-color: var(--accent-cyan);
}

/* ─── Developer Section: Code Block ─── */
.dev-code-block {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #080f1e;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    position: relative;
}

.dev-code-label {
    color: var(--accent-cyan) !important;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 0.78rem !important;
    font-weight: 600;
    margin-bottom: 0.6rem;
    letter-spacing: 0.02em;
}

.dev-code-pre {
    color: #94a3b8;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 0.82rem;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.65;
    margin: 0;
    padding: 0;
}

.dev-cta-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

@media (max-width: 600px) {
    .landing-nav {
        gap: 0.1rem;
        padding: 0.5rem 1rem;
    }

    .landing-nav-link {
        font-size: 0.78rem;
        padding: 0.3rem 0.6rem;
    }
}