/* ----------------------------------------------------
   Gherkio Interactive Playground: Premium Style Sheet
------------------------------------------------------- */

:root {
    /* Design Tokens - Dark Mode Default */
    --bg-color: hsl(222, 47%, 6%);
    --panel-bg: hsla(222, 47%, 10%, 0.7);
    --card-bg: hsla(223, 47%, 12%, 0.85);
    --border-color: hsla(222, 30%, 20%, 0.6);
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 15%, 55%);
    
    --accent-gradient: linear-gradient(135deg, hsl(263, 90%, 65%), hsl(280, 90%, 60%));
    --accent-color: hsl(263, 90%, 65%);
    --accent-glow: hsla(263, 90%, 65%, 0.25);
    
    --success-color: hsl(142, 70%, 50%);
    --success-bg: hsla(142, 70%, 50%, 0.15);
    --error-color: hsl(0, 84%, 60%);
    --error-bg: hsla(0, 84%, 60%, 0.15);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --font-code: 'Courier New', Courier, monospace;
}

body.light-mode {
    /* Light Mode Palette overrides */
    --bg-color: hsl(220, 20%, 97%);
    --panel-bg: hsla(220, 20%, 92%, 0.8);
    --card-bg: hsl(0, 0%, 100%);
    --border-color: hsl(220, 20%, 85%);
    --text-primary: hsl(222, 47%, 12%);
    --text-secondary: hsl(220, 15%, 35%);
    --text-muted: hsl(220, 10%, 55%);
    --accent-glow: hsla(263, 90%, 65%, 0.1);
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Immersive background glow */
.glow-bg {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, hsla(263, 90%, 65%, 0.15) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

/* Layout Hierarchy */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 700px;
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    animation: rotateGlow 6s infinite linear;
}

.main-header h1 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    background: var(--accent-gradient);
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.badge.success {
    background: var(--success-bg);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.badge.error {
    background: var(--error-bg);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success-color);
    animation: pulse 1.8s infinite;
}

.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.theme-toggle:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Layout Grid */
.main-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    flex-grow: 1;
    min-height: 0; /* Important for scroll container behavior */
}

/* Sidebar */
.sidebar-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-height: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
}

.doc-nav {
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}

.nav-cat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cat-title {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
    padding-left: 8px;
}

.nav-link {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: hsla(222, 30%, 20%, 0.4);
    color: var(--text-primary);
}

.nav-link.active {
    background: hsla(263, 90%, 65%, 0.15);
    color: var(--text-primary);
    border-left: 3px solid var(--accent-color);
    font-weight: 500;
}

/* Main Content Panel */
.content-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Tabs */
.tab-header {
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: hsla(222, 30%, 20%, 0.3);
}

.tab-btn.active {
    background: var(--accent-gradient);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Tab Panel States */
.tab-content {
    display: none;
    flex-grow: 1;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Doc Reader Content */
.doc-container {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    padding: 36px;
    overflow-y: auto;
    flex-grow: 1;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.category-eyebrow {
    font-family: var(--font-heading);
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: inline-block;
    margin-bottom: 8px;
}

.chapter-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
}

/* Markdown Styling */
.markdown-body {
    line-height: 1.7;
    font-size: 16px;
    color: var(--text-secondary);
}

.markdown-body h2 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 14px;
}

.markdown-body p {
    margin-bottom: 16px;
}

.markdown-body blockquote {
    background: hsla(222, 30%, 20%, 0.3);
    border-left: 4px solid var(--accent-color);
    padding: 12px 18px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 20px;
    font-style: italic;
}

.markdown-body ul {
    margin-left: 24px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.markdown-body code {
    font-family: var(--font-code);
    background: hsla(222, 30%, 20%, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
}

.markdown-body pre {
    background: hsla(222, 47%, 4%, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 24px;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

/* Table styling in markdown */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
}

.markdown-body th {
    background: hsla(222, 30%, 15%, 0.5);
    color: var(--text-primary);
    font-weight: 600;
}

/* Stepper Visualizer Layout */
.visualizer-grid, .converter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    flex-grow: 1;
    min-height: 0;
}

/* Editor & Flow Card containers */
.editor-card, .flow-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: hsla(222, 30%, 15%, 0.2);
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.title-with-icon h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
}

.dropdown-container select {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
}

.card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}

.helper-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Monaco-style raw textareas */
textarea {
    flex-grow: 1;
    background: hsl(222, 47%, 4%);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: #e2e8f0;
    padding: 16px;
    font-family: var(--font-code);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Stepper Node flow outputs */
.step-node {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

.step-node:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.step-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: hsla(222, 30%, 15%, 0.1);
}

.step-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-index {
    width: 24px;
    height: 24px;
    background: var(--accent-gradient);
    border-radius: 50%;
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-method {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.step-method.post { background: hsla(263, 90%, 65%, 0.2); color: hsl(263, 90%, 75%); }
.step-method.get { background: hsla(142, 70%, 50%, 0.2); color: hsl(142, 70%, 60%); }
.step-method.delete { background: hsla(0, 84%, 60%, 0.2); color: hsl(0, 84%, 70%); }
.step-method.put { background: hsla(37, 90%, 50%, 0.2); color: hsl(37, 90%, 60%); }
.step-method.use { background: hsla(215, 90%, 50%, 0.2); color: hsl(215, 90%, 70%); }

.step-url {
    font-family: var(--font-code);
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.step-body-collapsed {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: hsla(222, 47%, 4%, 0.4);
    display: none;
}

.step-body-collapsed.active {
    display: block;
}

.block-title {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.block-content {
    background: hsl(222, 47%, 4%);
    padding: 10px;
    border-radius: 6px;
    font-family: var(--font-code);
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

/* Arrow between steps */
.step-arrow {
    display: flex;
    justify-content: center;
    margin: -8px 0 8px 0;
    color: var(--border-color);
    animation: pulseArrow 2s infinite ease-in-out;
}

/* Converter Actions & Styles */
.converter-grid textarea {
    margin-bottom: 16px;
}

.btn {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px var(--accent-glow);
}

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

.btn-secondary:hover {
    border-color: var(--accent-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Animations */
@keyframes rotateGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 hsla(142, 70%, 50%, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px hsla(142, 70%, 50%, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 hsla(142, 70%, 50%, 0); }
}

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

@keyframes pulseArrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}
