/* --- CSS Variables & Theming --- */
:root {
    --bg-main: #f8fafc;
    --bg-sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #f8fafc;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --code-bg: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --header-bg: #ffffff;
    --hover-bg: #f1f5f9;
    --flow-shift: 45px;
    /* Increased shift for a "stretched" horizontal look */
    --highlight-bg: #fef08a;
    /* Custom highlight color (yellow) */
    --highlight-color: #854d0e;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-sidebar: #020617;
    --sidebar-hover: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-light: #f8fafc;
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --border-color: #334155;
    --card-bg: #1e293b;
    --code-bg: #0f172a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --header-bg: #1e293b;
    --hover-bg: #334155;
    --highlight-bg: #854d0e;
    /* Dark mode highlight color */
    --highlight-color: #fef08a;
}

/* --- Base Reset --- */
/* Update the Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* This applies the new font to everything: buttons, inputs, etc. */
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    /* Smooth font rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    /* Tighter spacing for a pro look */
}

.sidebar-header h2 {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 18px;
}

.nav-links li {
    font-weight: 500;
    font-size: 14px;
}

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

/* --- Sidebar & Overlay --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 1000;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    font-size: 24px;
    color: var(--primary-color);
}

.nav-links {
    list-style: none;
    padding: 20px 0;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-links li {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: #cbd5e1;
    font-weight: 500;
    border-right: 4px solid transparent;
}

.nav-links li:hover,
.nav-links li.active {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    border-right-color: var(--primary-color);
}

.user-profile {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-info .name {
    font-size: 14px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-info .role {
    font-size: 12px;
    color: #94a3b8;
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

/* Top Header Area */
.top-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
}

.mobile-menu-btn {
    display: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    margin-right: auto;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 20px;
    background-color: var(--bg-main);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.datetime-display {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    color: var(--primary-color);
}

/* Universal Search Bar */
.search-container {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-clear-btn {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    display: none;
}

.search-clear-btn:hover {
    color: var(--primary-color);
}

.search-clear-btn.visible {
    display: block;
}

.search-shortcut {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    pointer-events: none;
}

#universal-search {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

#universal-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* --- Scrollable Content Wrapper --- */
.content-wrapper {
    padding: 40px;
    overflow-y: auto;
    flex-grow: 1;
}

.content-section {
    display: none;
    animation: fadeIn 0.3s ease;
    margin-bottom: 24px;
}

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

.search-hidden {
    display: none !important;
}

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

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

.section-header {
    margin-bottom: 24px;
}

.section-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

#search-results-header {
    display: none;
    margin-bottom: 30px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
}

/* --- Reusable Cards --- */
.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-tag {
    display: inline-block;
    background-color: var(--hover-bg);
    color: var(--primary-color);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

/* --- Highlighting Styles --- */
.search-highlight {
    background-color: var(--highlight-bg);
    color: var(--highlight-color);
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
    transition: none;
    /* Prevent weird visual bugs during typing */
}

/* =======================================================
           DYNAMIC DIAGONAL FLOWCHART (STRETCHED & SINGLE-LINE)
           ======================================================= */
.dynamic-flow-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 30px 20px;
    overflow-x: auto;
    background-color: var(--bg-main);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    -webkit-overflow-scrolling: touch;
}

.flow-step-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    margin-left: calc(var(--index) * var(--flow-shift));
}

.dynamic-node {
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    z-index: 2;

    /* FORCES TEXT TO STAY ON ONE LINE */
    white-space: nowrap;
    text-align: center;
    min-width: 200px;
    /* max-width removed to allow unlimited single-line expansion */

    line-height: 1.4;
    cursor: default;

    /* Animations */
    opacity: 0;
    animation: fadeSlideUp 0.6s ease forwards;
    animation-delay: calc(var(--index) * 0.3s);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.dynamic-node:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
}

.dynamic-node.final-node {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.dynamic-node.final-node:hover {
    background-color: var(--primary-hover);
    color: #ffffff;
    border-color: var(--primary-hover);
}

/* SVG Arrow styles - Made much shorter vertically */
.diag-arrow-svg {
    width: 100px;
    height: 25px;
    z-index: 1;
    margin-top: -3px;
    margin-bottom: -3px;
}

.diag-line {
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 2.5;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawLine 0.4s ease forwards;
    animation-delay: calc(var(--index) * 0.3s + 0.2s);
}

.diag-head {
    fill: var(--text-secondary);
    opacity: 0;
    animation: fadeInArrow 0.2s ease forwards;
    animation-delay: calc(var(--index) * 0.3s + 0.5s);
}

/* Flowchart Keyframes */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

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

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes fadeInArrow {
    to {
        opacity: 1;
    }
}


/* --- SQL Blocks & Other Elements --- */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.copy-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.copy-btn:hover {
    background-color: var(--hover-bg);
}

.code-block {
    background-color: var(--code-bg);
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-main);
    font-weight: 600;
    color: var(--text-secondary);
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.link-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
}

.link-card > div:first-child {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.link-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.link-icon {
    font-size: 24px;
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1);
    padding: 12px;
    border-radius: 8px;
}

.link-info {
    flex-grow: 1;
}

.link-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.link-info p {
    font-size: 13px;
    color: var(--text-secondary);
}


/* --- Number-Based Icon Block --- */
.link-number-icon {
    font-size: 26px;
    font-weight: 800;
    /* Extra bold to make it pop */
    color: var(--primary-color);
    background-color: rgba(59, 130, 246, 0.1);
    /* Fixed width and height ensure it remains a perfect square */
    min-width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
    /* Prevents the box from shrinking if the text next to it is long */
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* --- Database Tables Grid & Upgrades --- */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
}

.table-header-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.table-name-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.copy-table-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.5;
}

.card:hover .copy-table-btn {
    opacity: 1;
    /* Appears clearly when hovering over the card */
}

.copy-table-btn:hover {
    color: var(--primary-color);
    background-color: var(--hover-bg);
}

.env-badges {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.env-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-family: 'Courier New', Courier, monospace;
}

.env-live {
    background-color: #dcfce3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.env-test {
    background-color: #fef08a;
    color: #854d0e;
    border: 1px solid #fde047;
}

/* --- Grouped Tables UI --- */
.grouped-table-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
}

.grouped-table-header h2 {
    font-size: 20px;
    margin-top: 8px;
    color: var(--text-primary);
}

.table-list-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.table-list-item {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 6px;
    padding: 16px;
    transition: all 0.2s ease;
}

.table-list-item:hover {
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
    /* Slight hover pop to the right */
    border-color: var(--primary-color);
}

.table-list-item p {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Premium SQL IDE & Grid Styles --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 28px;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

/* Risk Badges */
.risk-badge {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.risk-safe {
    background-color: #dcfce3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.risk-warn {
    background-color: #fef08a;
    color: #854d0e;
    border: 1px solid #fde047;
}

.risk-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Code Editor UI */
.ide-container {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-top: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ide-header {
    background-color: var(--hover-bg);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.ide-db-target i {
    color: var(--primary-color);
    margin-right: 6px;
}

.ide-copy-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.ide-copy-btn:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Code Block & Syntax Highlighting */
.code-block {
    background-color: var(--code-bg);
    padding: 20px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
}

.code-block pre {
    margin: 0;
    color: #e2e8f0;
}

.kw {
    color: #c678dd;
    font-weight: bold;
}

/* Keywords: SELECT, FROM */
.str {
    color: #98c379;
}

/* Strings: 'text' */
.var {
    color: #e06c75;
}

/* Variables: @id */
.fn {
    color: #61afef;
}

/* Tables/Functions */
.cm {
    color: #5c6370;
    font-style: italic;
}

/* Comments */
.num {
    color: #d19a66;
}

/* Numbers */

/* --- Premium SQL IDE & Responsive Grid Styles --- */
.grid-container {
    display: grid;
    /* Changed from 400px to 300px so it scales smoothly on smaller tablets/phones */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    /* Allows badges to wrap to the next line on very small screens */
    flex-wrap: wrap;
    gap: 12px;
}

/* Risk Badges */
.risk-badge {
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    /* Prevents badge from squishing */
}

.risk-safe {
    background-color: #dcfce3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.risk-warn {
    background-color: #fef08a;
    color: #854d0e;
    border: 1px solid #fde047;
}

.risk-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Code Editor UI */
.ide-container {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-top: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.ide-header {
    background-color: var(--hover-bg);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    flex-wrap: wrap;
    gap: 10px;
}

.ide-db-target {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.ide-db-target i {
    color: var(--primary-color);
    margin-right: 6px;
}

.ide-copy-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 12px;
}

.ide-copy-btn:hover {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Code Block & Syntax Highlighting */
.code-block {
    background-color: var(--code-bg);
    padding: 16px;
    /* CRITICAL FOR MOBILE: Allows horizontal swiping of code */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    width: 100%;
}

.code-block pre {
    margin: 0;
    color: #e2e8f0;
    width: max-content;
}

.kw {
    color: #c678dd;
    font-weight: bold;
}

/* Keywords: SELECT, FROM */
.str {
    color: #98c379;
}

/* Strings: 'text' */
.var {
    color: #e06c75;
}

/* Variables: @id */
.fn {
    color: #61afef;
}

/* Tables/Functions */
.cm {
    color: #5c6370;
    font-style: italic;
}

/* Comments */
.num {
    color: #d19a66;
}

/* Numbers */

/* --- Welcome Message --- */
.welcome-header {
    margin-bottom: 4px;
}

.welcome-text {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* --- Dynamic Color Theme Variables --- */

/* 1. Corporate Teal (Kept class name as 'indigo' so your HTML/JS doesn't break) */
[data-color="indigo"] {
    --primary-color: #ff00a6;
    --primary-hover: #ff00a6;
    /* Perfectly calculated darker teal for hover */
    --theme-glow: rgba(10, 101, 118, 0.2);
    /* Matched teal glow */
}

/* 2. Ocean Blue */
[data-color="ocean"] {
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --theme-glow: rgba(14, 165, 233, 0.2);
}

/* 3. Emerald Green */
[data-color="emerald"] {
    --primary-color: #10b981;
    --primary-hover: #059669;
    --theme-glow: rgba(16, 185, 129, 0.2);
}

/* 4. Sunset Orange */
[data-color="sunset"] {
    --primary-color: #f97316;
    --primary-hover: #ea580c;
    --theme-glow: rgba(249, 115, 22, 0.2);
}

/* --- Premium 3-Stop Gradient Colors for the Dots --- */
.dot-indigo {
    /* Beautiful teal gradient shifting from dark to light */
    background: linear-gradient(135deg, #ff00a6, #ff00a6, #1693a8);
}

.dot-ocean {
    /* Deep blue to bright sky blue */
    background: linear-gradient(135deg, #0284c7, #0ea5e9, #38bdf8);
}

.dot-emerald {
    /* Rich forest green to bright emerald */
    background: linear-gradient(135deg, #059669, #10b981, #34d399);
}

.dot-sunset {
    /* Deep burnt orange to bright sunset orange */
    background: linear-gradient(135deg, #ea580c, #f97316, #fb923c);
}

/* --- Theme Color Picker UI --- */
.theme-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.theme-dot:hover {
    transform: scale(1.2);
}

.theme-dot.active {
    border-color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--bg-main);
}


/* --- Premium System Path Display --- */
.doc-path-wrapper {
    margin-top: 24px;
    /* Increased space between series codes and the path */
    width: 100%;
}

.doc-path-text {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background-color: var(--bg-main);
    padding: 12px 16px;
    border-radius: 8px;
    /* Added a beautiful full border with a striking left accent */
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.doc-path-text:hover {
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
    /* Lights up the entire border on hover */
    border-color: var(--primary-color);
}

.doc-path-icon {
    color: var(--primary-color);
    font-size: 16px;
    margin-top: 2px;
}

.doc-path-content {
    line-height: 1.6;
    font-weight: 400;
    /* Made the path text un-bold (normal text) */
}

.doc-path-label {
    font-weight: 700;
    /* Kept the badge bold */
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
    margin-right: 8px;
    background-color: var(--theme-glow);
    padding: 4px 8px;
    border-radius: 4px;
}

.p-arrow {
    color: var(--primary-color);
    opacity: 0.6;
    margin: 0 6px;
    font-size: 10px;
}


/* =======================================================
           MOBILE RESPONSIVE MEDIA QUERIES 
           ======================================================= */
@media (max-width: 768px) {
    :root {
        --flow-shift: 25px;
    }

    .diag-arrow-svg {
        transform: scaleX(0.55);
        transform-origin: 30px 0;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active-mobile {
        left: 0;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .mobile-menu-btn {
        display: block;
    }

    .top-header {
        padding: 16px 20px;
    }

    .content-wrapper {
        padding: 20px 15px;
    }

    .card {
        padding: 16px;
        margin-bottom: 20px;
    }

    .datetime-display {
        font-size: 12px;
    }

    .search-shortcut {
        display: none;
    }

    .controls-right {
        gap: 12px;
        padding: 6px 12px;
    }

    .dynamic-node {
        min-width: 150px;
        /* Max width removed for mobile as well to prevent wrapping */
        padding: 10px 16px;
        font-size: 13px;
    }

    /* --- Structured Table Section Styles --- */
    .table-name-title {
        display: flex;
        align-items: center;
        gap: 10px;
        font-family: 'Courier New', Courier, monospace;
        /* Gives a technical database feel */
        color: var(--primary-color);
        margin-top: 4px;
    }

    .table-description-box {
        margin-top: 15px;
        padding: 12px 16px;
        background-color: var(--bg-main);
        border-left: 4px solid var(--primary-color);
        border-radius: 4px;
    }

    .table-description-box strong {
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        color: var(--text-secondary);
        margin-bottom: 5px;
        letter-spacing: 0.5px;
    }

    .table-description-box p {
        margin: 0;
        font-size: 14px;
        line-height: 1.6;
        color: var(--text-primary);
    }

    .tables-grid {
        grid-template-columns: 1fr;
        /* Stacks on mobile */
    }

    .grid-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .ide-header {
        padding: 8px 12px;
    }

    .code-block {
        padding: 12px;
        font-size: 12px;
    }

    /* Keep the theme picker visible on mobile */
    .theme-picker {
        display: flex;
        gap: 6px;
        padding-left: 8px;
    }

    /* Make the dots slightly smaller for phone screens */
    .theme-dot {
        width: 14px;
        height: 14px;
    }

    /* Hide the clock text (keep only the icon) on mobile to make room for the colors */
    .datetime-display span {
        display: none;
    }

    .welcome-text {
        font-size: 24px;
    }

    

}

/* =======================================================
   IMAGE GALLERY & LIGHTBOX MODAL
   ======================================================= */

/* --- Gallery Grid --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.gallery-card {
    padding: 0; /* Remove padding for edge-to-edge image */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gallery-img-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9; /* Perfect widescreen ratio */
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Image Hover Overlay --- */
.gallery-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    transition: all 0.3s ease;
}

.gallery-card:hover .gallery-overlay {
    opacity: 1;
}

.gallery-card:hover .gallery-img {
    transform: scale(1.08); /* Smooth zoom effect */
}

/* --- Action Buttons (View/Download) --- */
.gallery-action-btn {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transform: translateY(15px); /* Start slightly lower */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.gallery-action-btn:hover {
    background-color: #fff;
    color: var(--primary-color);
    transform: translateY(-3px) scale(1.1) !important;
}

.gallery-card:hover .gallery-action-btn {
    transform: translateY(0); /* Slide up into place on hover */
}

.gallery-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* =======================================================
   LIGHTBOX MODAL
   ======================================================= */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    opacity: 0;
    animation: fadeInBg 0.3s ease forwards;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    z-index: 10000;
    opacity: 0;
    transform: scale(0.9);
    animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#modal-full-img {
    max-width: 100%;
    max-height: calc(90vh - 80px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

/* Modal Close Button */
.modal-close {
    position: absolute;
    top: -16px;
    right: -16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    z-index: 2;
}

.modal-close:hover {
    transform: scale(1.1) rotate(90deg);
}

/* Modal Footer & Description */
.modal-footer {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    color: white;
}

#modal-caption {
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.modal-download-action {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.modal-download-action:hover {
    background-color: #fff;
    color: var(--primary-color);
}

/* Modal Animations */
@keyframes fadeInBg {
    to { opacity: 1; }
}

@keyframes popIn {
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* --- Mobile Responsiveness for Gallery & Modal --- */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr; /* Stack images on mobile */
    }

    .modal-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .modal-close {
        top: -40px;
        right: 0;
    }
}