/* ==========================================================================
   AdTech SQL Masterclass - ChatGPT Style Dark Learning Interface
   ========================================================================== */

:root {
    --chat-bg: #0d0d0d;
    --chat-surface: #171717;
    --chat-surface-hover: #1f1f1f;
    --chat-border: #2e2e2e;
    --chat-border-subtle: #242424;
    --chat-text: #ececec;
    --chat-text-muted: #9ca3af;
    --chat-text-dim: #6b7280;
    --chat-pill-bg: #262626;
    --chat-code-header: #212121;
    --chat-accent-blue: #38bdf8;
    --chat-accent-pink: #f472b6;
    --chat-accent-green: #4ade80;
    --chat-accent-orange: #fb923c;
    --chat-accent-purple: #c084fc;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
    scroll-padding-bottom: 160px;
}

body.chatgpt-learning-body {
    background-color: var(--chat-bg) !important;
    color: var(--chat-text) !important;
    font-family: Söhne, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, "Helvetica Neue", Arial;
    line-height: 1.7;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* Ensure global footer is never covered or cut off */
body.chatgpt-learning-body footer.site-footer {
    padding-bottom: 140px !important;
    position: relative;
    z-index: 10;
}

/* Container mimicking ChatGPT conversation stream */
.chat-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 32px 20px 220px; /* Generous bottom clearance */
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: normal;
}

/* Chat Header Banner */
.chat-header-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(192, 132, 252, 0.05) 100%);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 14px;
    margin-bottom: 32px;
}

.chat-header-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    line-height: 1.35;
}

.chat-header-subtitle {
    font-size: 0.85rem;
    color: var(--chat-text-muted);
    margin: 2px 0 0;
    line-height: 1.4;
}

.chat-nav-shortcuts {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #212121;
    color: #d1d5db;
    border: 1px solid #333;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.chat-nav-btn:hover {
    background: #2a2a2a;
    color: #fff;
    border-color: #444;
}

/* Section block */
.chat-section {
    margin-bottom: 48px;
    scroll-margin-top: 90px;
    overflow-wrap: break-word;
    word-break: normal;
}

.chat-section-divider {
    height: 1px;
    background: var(--chat-border-subtle);
    margin: 44px 0;
}

.chat-h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 16px 0;
    letter-spacing: -0.02em;
    line-height: 1.35;
    overflow-wrap: break-word;
}

.chat-h2 {
    font-size: 1.35rem;
    font-weight: 600;
    color: #ffffff;
    margin: 28px 0 12px 0;
    letter-spacing: -0.01em;
    line-height: 1.4;
    overflow-wrap: break-word;
}

.chat-h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f3f4f6;
    margin: 20px 0 10px 0;
    line-height: 1.45;
    overflow-wrap: break-word;
}

.chat-p {
    font-size: 1.02rem;
    color: var(--chat-text);
    margin: 0 0 14px 0;
    line-height: 1.75;
    overflow-wrap: break-word;
}

/* Arrow Flows & Sequences */
.chat-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: #141414;
    border: 1px solid #282828;
    padding: 12px 16px;
    border-radius: 10px;
    margin: 14px 0 18px;
    font-size: 0.96rem;
    line-height: 1.5;
}

.chat-flow strong {
    color: #ffffff;
}

.chat-flow-arrow {
    color: var(--chat-accent-blue);
    font-weight: 700;
    user-select: none;
}

.chat-flow-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #141414;
    border: 1px solid #282828;
    padding: 18px 20px;
    border-radius: 12px;
    margin: 16px 0 20px;
    gap: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.chat-flow-step {
    padding: 6px 14px;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    color: #f3f4f6;
    font-size: 0.95rem;
    min-width: 220px;
    max-width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.chat-flow-step.highlight {
    border-color: var(--chat-accent-blue);
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    font-weight: 600;
}

.chat-flow-down {
    color: var(--chat-accent-blue);
    font-size: 1.2rem;
    line-height: 1;
}

/* Tag / Pill badges for SQL keywords */
.chat-tag {
    display: inline-block;
    background: var(--chat-pill-bg);
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88em;
    font-weight: 600;
    border: 1px solid #383838;
    vertical-align: baseline;
    line-height: 1.2;
    white-space: nowrap;
}

/* Callouts / Interview Questions */
.chat-callout {
    background: #15181e;
    border-left: 3px solid var(--chat-accent-blue);
    border-radius: 0 10px 10px 0;
    padding: 16px 20px;
    margin: 20px 0;
    overflow-wrap: break-word;
}

.chat-callout-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--chat-accent-blue);
    font-size: 0.95rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-callout-q {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 10px 0;
    line-height: 1.45;
}

.chat-callout-a {
    font-size: 1rem;
    color: #d1d5db;
    margin: 0;
    line-height: 1.7;
}

.chat-quote {
    border-left: 2px solid #404040;
    padding: 6px 16px;
    margin: 12px 0;
    color: #d4d4d8;
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 6px 6px 0;
    overflow-wrap: break-word;
}

/* Ordered/Unordered Lists */
.chat-ol, .chat-ul {
    padding-left: 24px;
    margin: 14px 0 18px;
    color: var(--chat-text);
}

.chat-ol li, .chat-ul li {
    margin-bottom: 8px;
    line-height: 1.65;
    overflow-wrap: break-word;
}

.chat-ol li strong, .chat-ul li strong {
    color: #ffffff;
}

/* Tables */
.chat-table-wrapper {
    position: relative;
    background: #171717;
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    overflow: hidden;
    margin: 18px 0 24px;
}

.chat-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--chat-code-header);
    border-bottom: 1px solid var(--chat-border);
    font-size: 0.8rem;
    color: var(--chat-text-muted);
}

.chat-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

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

.chat-table th {
    background: #1e1e1e;
    color: #ffffff;
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid #2e2e2e;
    white-space: nowrap;
}

.chat-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #242424;
    color: #d1d5db;
    white-space: nowrap;
}

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

.chat-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Code Blocks */
.chat-code-block {
    position: relative;
    background: #171717;
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    margin: 16px 0 22px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* CRITICAL FIX: Suppress any rogue injected duplicate copy buttons */
.chat-code-block .code-copy-btn,
.chat-code-pre .code-copy-btn {
    display: none !important;
    visibility: hidden !important;
}

.chat-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--chat-code-header);
    border-bottom: 1px solid #282828;
    color: var(--chat-text-muted);
    font-size: 0.82rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.chat-code-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #9ca3af;
    font-weight: 600;
}

.chat-code-lang svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.chat-code-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-btn-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}

.chat-btn-action:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.chat-btn-run {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.chat-btn-run:hover {
    color: #ffffff;
    background: rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.4);
}

.chat-code-pre {
    margin: 0;
    padding: 16px 18px;
    overflow-x: auto;
    font-family: "JetBrains Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #f3f4f6;
    tab-size: 4;
    white-space: pre;
    -webkit-overflow-scrolling: touch;
}

/* Syntax Highlighting Colors */
.tok-kw { color: #f472b6; font-weight: 600; } /* Pink keywords */
.tok-fn { color: #38bdf8; font-weight: 600; } /* Cyan functions */
.tok-str { color: #4ade80; } /* Green strings */
.tok-num { color: #fb923c; } /* Orange numbers */
.tok-typ { color: #818cf8; } /* Indigo types */
.tok-cmt { color: #71717a; font-style: italic; } /* Comments */
.tok-op { color: #cbd5e1; } /* Operators */
.tok-id { color: #e2e8f0; } /* Identifiers */

/* Interactive Query Result Container */
.chat-query-result {
    display: none;
    background: #11141a;
    border-top: 1px solid #2a303c;
    padding: 12px 16px;
    animation: fadeIn 0.2s ease-in-out;
}

.chat-query-result.active {
    display: block;
}

.chat-query-result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #94a3b8;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

/* Exercises Accordion / Interactive Reveal */
.chat-exercise-card {
    background: #171717;
    border: 1px solid #2d2d2d;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.chat-exercise-card:hover {
    border-color: #3d3d3d;
}

.chat-exercise-card.is-interview {
    border-left: 3px solid #fb923c;
}

.chat-exercise-card.is-solution-engineer {
    border-left: 3px solid #ec4899;
}

.chat-exercise-header {
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    background: #171717;
    gap: 12px;
}

.chat-exercise-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chat-exercise-num {
    background: #262626;
    color: #e5e7eb;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

.chat-exercise-title {
    font-size: 1.02rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    line-height: 1.4;
    overflow-wrap: break-word;
}

.chat-exercise-toggle-icon {
    font-size: 0.85rem;
    color: #9ca3af;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.chat-exercise-card.open .chat-exercise-toggle-icon {
    transform: rotate(180deg);
}

.chat-exercise-body {
    display: none;
    padding: 16px 18px 20px;
    border-top: 1px solid #282828;
    background: #141414;
    overflow-wrap: break-word;
}

.chat-exercise-card.open .chat-exercise-body {
    display: block;
}

/* ==========================================================================
   FLOATING BOTTOM PROMPT BAR (FIXED: NON-INTRUSIVE, ZERO TEXT CUTTING)
   ========================================================================== */
.chat-bottom-bar-wrap {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent; /* Removed huge opaque gradient that masked text! */
    padding: 0 16px 16px;
    z-index: 100;
    pointer-events: none; /* Allows scrolling & clicks underneath */
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.chat-bottom-bar-wrap.minimized {
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
}

.chat-bottom-bar {
    max-width: 768px;
    margin: 0 auto;
    position: relative;
    pointer-events: auto;
    background: rgba(24, 24, 27, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid #333333;
    border-radius: 24px;
    padding: 10px 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
}

/* Quick prompt chips - CRITICAL FIX: flex-shrink: 0 so chip text never clips! */
.chat-quick-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    margin-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: #383838 transparent;
    -webkit-overflow-scrolling: touch;
}

.chat-quick-chips::-webkit-scrollbar {
    height: 4px;
}

.chat-quick-chips::-webkit-scrollbar-thumb {
    background: #383838;
    border-radius: 4px;
}

.chat-chip {
    white-space: nowrap;
    flex-shrink: 0 !important; /* CRITICAL: Never truncate words inside chips! */
    background: #202023;
    border: 1px solid #383838;
    color: #e5e7eb;
    padding: 5px 14px;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    transition: all 0.15s ease;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.chat-chip:hover {
    background: #2b2b30;
    border-color: #555;
    color: #ffffff;
}

/* Input pill */
.chat-input-pill {
    background: #18181b;
    border: 1px solid #383838;
    border-radius: 20px;
    padding: 6px 10px 6px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.chat-input-pill:focus-within {
    border-color: #555;
    background: #1f1f23;
}

.chat-input-pill-left {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #9ca3af;
}

.chat-btn-plus {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #2a2a2e;
    border: none;
    color: #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.chat-btn-plus:hover {
    background: #3a3a40;
    color: #fff;
}

.chat-input-field {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.94rem;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.chat-input-field::placeholder {
    color: #888888;
}

.chat-input-pill-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-pill-think {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #2a2a2e;
    color: #e5e7eb;
    border: 1px solid #3a3a40;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    cursor: pointer;
    font-weight: 500;
}

.chat-pill-think:hover {
    background: #383840;
}

.chat-btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.chat-btn-icon:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.chat-btn-submit {
    background: #3b82f6;
    color: #ffffff;
}

.chat-btn-submit:hover {
    background: #2563eb;
}

/* Minimize / Close button on floating bar */
.chat-btn-minimize {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    margin-left: 2px;
    font-size: 1rem;
    line-height: 1;
}

.chat-btn-minimize:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

/* Floating button to restore minimized assistant */
.chat-bar-open-pill {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #212124;
    border: 1px solid #383838;
    color: #f3f4f6;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 99;
    display: none;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.chat-bar-open-pill:hover {
    background: #2a2a30;
    border-color: var(--chat-accent-blue);
    color: #ffffff;
    transform: translateY(-2px);
}

/* Floating Scroll to Bottom Chevron */
.chat-scroll-down-btn {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #26262a;
    border: 1px solid #3d3d42;
    color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-scroll-down-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.chat-scroll-down-btn:hover {
    background: #333338;
    color: #fff;
    transform: translateX(-50%) translateY(-2px);
}

/* Assistant Modal */
.chat-ai-modal {
    display: none;
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 32px));
    background: #171717;
    border: 1px solid #333333;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.6);
    z-index: 101;
    overflow: hidden;
    animation: slideUp 0.25s ease-out;
}

.chat-ai-modal.active {
    display: block;
}

.chat-ai-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #212121;
    border-bottom: 1px solid #2d2d2d;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f3f4f6;
}

.chat-ai-modal-close {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.chat-ai-modal-close:hover {
    color: #ffffff;
}

.chat-ai-modal-body {
    padding: 18px 20px;
    max-height: 420px;
    overflow-y: auto;
    font-size: 0.95rem;
    color: #e5e7eb;
    line-height: 1.65;
    overflow-wrap: break-word;
}

/* Toast notification */
.chat-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: #22c55e;
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.25s ease;
    z-index: 999;
    pointer-events: none;
}

.chat-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Keyframes */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 15px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 640px) {
    .chat-container {
        padding: 20px 14px 220px;
    }
    .chat-header-banner {
        flex-direction: column;
        align-items: flex-start;
    }
    .chat-code-header {
        font-size: 0.76rem;
    }
    .chat-code-pre {
        font-size: 0.84rem;
        padding: 12px 14px;
    }
    .chat-flow {
        font-size: 0.88rem;
    }
    .chat-scroll-down-btn {
        bottom: 80px;
    }
}
