/* ==========================================================================
   MACROCHART — PUBLISHING STUDIO
   Administrator Interface
   ========================================================================== */


/* ==========================================================================
   DESIGN TOKENS
   ========================================================================== */

:root {
    --background: #f8f9fb;
    --surface: #ffffff;

    --text: #202329;
    --muted: #747982;

    --border: #e5e7eb;

    --dark: #26272d;

    --blue: #638cf5;
    --amber: #f2be80;

    --radius: 10px;

    --header-height: 66px;
}


/* ==========================================================================
   RESET
   ========================================================================== */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;

    min-height: 100vh;

    background: var(--background);
    color: var(--text);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}


/* ==========================================================================
   HEADER
   ========================================================================== */

.admin-header {
    height: var(--header-height);

    padding: 0 2.5%;

    display: flex;
    justify-content: space-between;
    align-items: center;

    background: var(--surface);

    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;

    color: var(--text);

    text-decoration: none;

    font-size: 20px;
    font-weight: 850;

    letter-spacing: -0.8px;
}

.brand span {
    color: var(--blue);
}

.brand-logo {
    display: block;

    height: 34px;
    width: auto;

    max-width: 230px;

    object-fit: contain;
}

.header-right {
    display: flex;
    align-items: center;

    gap: 20px;
}

.admin-badge,
.eyebrow {
    font-size: 10px;

    font-weight: 750;

    letter-spacing: 1.4px;

    color: var(--muted);
}

#signOutButton {
    padding: 9px 14px;

    border: 1px solid var(--border);
    border-radius: 6px;

    background: white;

    color: var(--text);

    font-size: 12px;
    font-weight: 650;
}


/* ==========================================================================
   MAIN ADMIN LAYOUT
   ========================================================================== */

.admin-layout {
    width: min(1920px, 96%);

    margin: 22px auto;
}

.studio {
    width: 100%;
}


/* ==========================================================================
   PAGE HEADING
   ========================================================================== */

.page-heading {
    margin-bottom: 20px;
}

.page-heading h1 {
    font-size: 30px;

    letter-spacing: -1.2px;

    margin: 8px 0;
}

.page-heading p {
    margin: 0;

    font-size: 13px;
}

h1 {
    font-size: clamp(28px, 3vw, 40px);

    letter-spacing: -1.5px;

    margin: 12px 0;
}

h2 {
    font-size: 19px;

    letter-spacing: -0.6px;

    margin: 12px 0 20px;
}

h3 {
    margin-top: 24px;
    margin-bottom: 12px;

    font-size: 13px;

    letter-spacing: -0.2px;
}

p {
    color: var(--muted);

    line-height: 1.6;
}


/* ==========================================================================
   HORIZONTAL WORKSPACE
   ========================================================================== */

.workspace {
    display: grid;

    grid-template-columns:
        minmax(230px, 0.85fr) minmax(280px, 1fr) minmax(380px, 1.5fr);

    gap: 16px;

    align-items: start;
}

.workspace>.panel {
    min-width: 0;
}


/* ==========================================================================
   PANELS
   ========================================================================== */

.panel {
    padding: 22px;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius);
}

.research-panel,
.results-panel,
.preview-panel {
    min-width: 0;
}


/* ==========================================================================
   AUTHENTICATION
   ========================================================================== */

.auth-panel {
    max-width: 440px;

    margin: 80px auto;

    padding: 30px;
}

.auth-panel h1 {
    font-size: 30px;
}

.auth-panel p {
    font-size: 13px;
}


/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */

label {
    display: block;

    font-size: 12px;

    font-weight: 650;

    margin: 16px 0 8px;
}

input,
textarea,
select {
    width: 100%;

    padding: 11px 12px;

    border: 1px solid var(--border);

    border-radius: 7px;

    background: white;

    color: var(--text);

    outline: none;

    font-size: 13px;
}

textarea {
    resize: vertical;

    min-height: 100px;

    line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
}

input::placeholder,
textarea::placeholder {
    color: #a1a5ad;
}


/* ==========================================================================
   RESEARCH PANEL
   ========================================================================== */

.research-panel {
    display: flex;
    flex-direction: column;
}

#researchPrompt {
    min-height: 200px;

    resize: vertical;

    font-size: 13px;

    line-height: 1.7;
}

/* ==========================================================================
   AI RESEARCH MODEL SELECTOR
   ========================================================================== */

.research-model-field {
    display: flex;
    flex-direction: column;

    gap: 8px;

    margin-top: 18px;
}

.research-model-field label {
    font-size: 12px;

    font-weight: 600;

    color: var(--text);
}

#researchModel {
    width: 100%;

    padding: 11px 12px;

    border: 1px solid var(--border);

    border-radius: 7px;

    background: #ffffff;

    color: var(--text);

    font-size: 12px;

    cursor: pointer;
}

#researchModel:focus {
    border-color: var(--blue);

    outline: none;
}

#researchButton {
    margin-top: 18px;

    width: 100%;
}

#researchStatus {
    margin-bottom: 0;
}


/* ==========================================================================
   BUTTONS
   ========================================================================== */

.primary-button,
.secondary-button {
    border-radius: 7px;

    padding: 11px 16px;

    font-size: 12px;

    font-weight: 700;

    border: 1px solid transparent;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        opacity 0.15s ease;
}

.primary-button {
    background: var(--text);

    color: white;
}

.primary-button:hover:not(:disabled) {
    background: #373b43;
}

.secondary-button {
    background: white;

    color: var(--text);

    border-color: var(--border);
}

.secondary-button:hover:not(:disabled) {
    background: #f4f5f7;
}

button:disabled {
    opacity: 0.4;

    cursor: not-allowed;
}


/* ==========================================================================
   STATUS MESSAGES
   ========================================================================== */

.status-message {
    font-size: 12px;

    line-height: 1.6;

    margin-top: 14px;
}


/* ==========================================================================
   RESEARCH RESULTS PANEL
   ========================================================================== */

.results-panel {
    min-width: 0;
}

#researchResults {
    min-width: 0;
}

.results-panel textarea {
    min-height: 105px;
}

.empty-state {
    padding: 55px 18px;

    text-align: center;

    background: #fafafa;

    border: 1px dashed var(--border);

    border-radius: 8px;

    color: var(--muted);

    font-size: 13px;
}


/* ==========================================================================
   FIELD GRID
   ========================================================================== */

.field-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr) minmax(0, 1fr);

    gap: 12px;
}

.field-grid>div {
    min-width: 0;
}


/* ==========================================================================
   RESEARCH DATA TABLE
   ========================================================================== */

#dataResults {
    width: 100%;

    overflow-x: auto;
}

.data-table {
    width: 100%;

    border-collapse: collapse;

    font-size: 12px;
}

.data-table th,
.data-table td {
    padding: 10px 8px;

    text-align: left;

    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);

    font-weight: 700;
}

.data-table td {
    color: var(--text);
}


/* ==========================================================================
   SOURCE REFERENCES
   ========================================================================== */

#sourceResults {
    max-height: 170px;

    overflow-y: auto;

    padding-right: 5px;
}

#sourceResults a {
    display: block;

    margin: 9px 0;

    font-size: 12px;

    line-height: 1.5;

    color: #3765d5;

    overflow-wrap: anywhere;

    text-decoration: none;
}

#sourceResults a:hover {
    text-decoration: underline;
}


/* ==========================================================================
   RESEARCH WARNINGS
   ========================================================================== */

.warning {
    padding: 12px;

    background: #fff5e7;

    border: 1px solid #f5dfbd;

    border-radius: 6px;

    margin-top: 12px;

    font-size: 12px;

    line-height: 1.6;
}


/* ==========================================================================
   PUBLISHING ACTIONS
   ========================================================================== */

.action-row {
    display: flex;

    gap: 10px;

    flex-wrap: wrap;

    margin-top: 24px;
}

.action-row button {
    flex: 1 1 auto;
}


/* ==========================================================================
   CHART PREVIEW PANEL
   ========================================================================== */

.preview-panel {
    margin-top: 0;

    min-width: 0;
}

.preview-heading {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;
}

.preview-heading h2 {
    margin-bottom: 18px;
}

.preview-dimensions {
    font-size: 11px;

    font-weight: 750;

    color: var(--muted);

    white-space: nowrap;
}


/* ==========================================================================
   AXIS CONTROLS
   ========================================================================== */

.axis-fields {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr) minmax(0, 1fr);

    gap: 12px;

    margin-bottom: 16px;
}

.axis-fields>div {
    min-width: 0;
}

.axis-fields label {
    margin-top: 0;

    font-size: 11px;
}

.axis-fields input {
    min-width: 0;

    padding: 10px 11px;

    font-size: 12px;
}


/* ==========================================================================
   SQUARE CHART PREVIEW
   1:1 ASPECT RATIO — 1080 × 1080 EXPORT
   ========================================================================== */

.chart-preview {
    position: relative;

    width: 100%;

    aspect-ratio: 1 / 1;

    min-height: 0;

    padding: 0;

    overflow: hidden;

    background: var(--dark);

    border-radius: 8px;
}

.chart-preview canvas {
    display: block;

    width: 100% !important;

    height: 100% !important;

    max-height: none;
}


/* ==========================================================================
   PREVIEW FOOTER
   ========================================================================== */

.preview-footer {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 14px;

    margin-top: 14px;
}

.preview-note {
    margin: 0;

    font-size: 11px;

    line-height: 1.5;

    flex: 1;
}

#downloadChartButton {
    white-space: nowrap;
}


/* ==========================================================================
   DESKTOP HEIGHT MANAGEMENT
   ========================================================================== */

@media (min-width: 1251px) {

    .research-panel,
    .results-panel {
        max-height: calc(100vh - var(--header-height) - 130px);

        overflow-y: auto;
    }

    .research-panel {
        overflow-x: hidden;
    }

    .results-panel {
        overflow-x: hidden;
    }

}


/* ==========================================================================
   MEDIUM DESKTOP / LAPTOP
   ========================================================================== */

@media (max-width: 1250px) {

    .workspace {
        grid-template-columns:
            minmax(250px, 1fr) minmax(300px, 1fr);
    }

    .preview-panel {
        grid-column: 1 / -1;

        width: min(100%, 680px);

        justify-self: center;
    }

    .admin-layout {
        width: 96%;
    }

}


/* ==========================================================================
   TABLET
   ========================================================================== */

@media (max-width: 900px) {

    .workspace {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        grid-column: auto;

        width: 100%;
    }

    .admin-layout {
        width: 94%;

        margin: 20px auto;
    }

    .panel {
        padding: 20px;
    }

    .field-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-badge {
        display: none;
    }

}


/* ==========================================================================
   MOBILE
   ========================================================================== */

@media (max-width: 600px) {

    .admin-header {
        padding: 0 4%;
    }

    .admin-layout {
        width: 94%;
    }

    .page-heading h1 {
        font-size: 27px;
    }

    .panel {
        padding: 16px;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .axis-fields {
        grid-template-columns: 1fr;
    }

    .preview-footer {
        flex-direction: column;

        align-items: stretch;
    }

    #downloadChartButton {
        width: 100%;
    }

    .action-row {
        flex-direction: column;
    }

    .action-row button {
        width: 100%;
    }

    #researchPrompt {
        min-height: 160px;
    }

}

/* ==========================================================================
   MACROCHART — COMPACT PUBLISHING WORKSPACE
   ========================================================================== */

/* Remove unnecessary space above workspace */

.studio {
    min-height: 0;
}

.workspace {
    margin-top: 0;
}


/* Publishing controls */

.publishing-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;

    margin: 16px 0 22px;
    padding-bottom: 18px;

    border-bottom: 1px solid #e7e9ed;
}

.publishing-toolbar button {
    flex: 1;
    min-width: 0;

    padding: 11px 9px;

    font-size: 11px;
    font-weight: 700;

    white-space: nowrap;
}

.publishing-toolbar button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 1100px) {
    .publishing-toolbar {
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   MACROCHART — ADMINISTRATOR NAVIGATION & CONTENT LIBRARY
   ========================================================================== */


/* ==========================================================================
   HEADER
   ========================================================================== */

.admin-header {
    position: relative;
    z-index: 100;
}

.brand {
    gap: 12px;
}

.brand-name {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--text) !important;
}

.header-right {
    gap: 28px;
}


/* ==========================================================================
   HAMBURGER BUTTON
   ========================================================================== */

.menu-toggle {
    width: 42px;
    height: 42px;

    padding: 10px 7px;

    border: none;
    background: transparent;

    display: flex;
    flex-direction: column;
    justify-content: center;

    gap: 6px;
}

.menu-toggle span {
    display: block;

    width: 100%;
    height: 2px;

    background: var(--text);

    transition: transform 0.2s ease;
}

.menu-toggle:hover span {
    background: var(--blue);
}

body.menu-open {
    overflow: hidden;
}


/* ==========================================================================
   NAVIGATION OVERLAY
   ========================================================================== */

.menu-overlay {
    position: fixed;
    inset: 0;

    background: rgba(20, 22, 28, 0.42);

    z-index: 150;
}


/* ==========================================================================
   NAVIGATION PANEL
   ========================================================================== */

.navigation-panel {
    position: fixed;

    top: 0;
    right: 0;
    bottom: 0;

    width: min(460px, 100%);

    padding: 35px;

    background: var(--surface);

    z-index: 200;

    display: flex;
    flex-direction: column;

    transform: translateX(100%);

    transition: transform 0.3s ease;

    box-shadow: -15px 0 45px rgba(0, 0, 0, 0.04);
}

.navigation-panel.is-open {
    transform: translateX(0);
}


/* ==========================================================================
   NAVIGATION HEADING
   ========================================================================== */

.navigation-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding-bottom: 35px;

    border-bottom: 1px solid var(--border);
}

.navigation-heading>span {
    color: var(--text);

    font-size: 11px;
    font-weight: 750;

    letter-spacing: 1.4px;
}

.menu-close {
    padding: 0;

    border: none;
    background: transparent;

    color: var(--text);

    font-size: 32px;
    line-height: 1;
}

.menu-close:hover {
    color: var(--blue);
}


/* ==========================================================================
   NAVIGATION LINKS
   ========================================================================== */

.navigation-links {
    display: flex;
    flex-direction: column;

    padding-top: 35px;
}

.navigation-links button,
.navigation-links a {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 25px;

    padding: 20px 0;

    border: none;
    border-bottom: 1px solid var(--border);

    border-radius: 0;

    background: transparent;

    color: var(--text);

    text-align: left;
    text-decoration: none;

    font-size: 26px;
    font-weight: 700;

    letter-spacing: -0.8px;

    transition: color 0.2s ease;
}

.navigation-links button:hover,
.navigation-links a:hover,
.navigation-links button.is-active {
    color: var(--blue);
}

.navigation-links button>span,
.navigation-links a>span {
    color: var(--blue);

    font-size: 11px;
    font-weight: 750;

    letter-spacing: 0;
}


/* ==========================================================================
   NAVIGATION FOOTER
   ========================================================================== */

.navigation-footer {
    margin-top: auto;

    padding-top: 25px;

    display: flex;
    flex-direction: column;

    align-items: flex-start;

    gap: 20px;

    border-top: 1px solid var(--border);
}

.navigation-footer>span {
    color: var(--muted);

    font-size: 10px;
    font-weight: 700;

    letter-spacing: 1.2px;
}

.navigation-signout {
    width: 100%;

    padding: 13px 16px !important;

    border: 1px solid var(--border) !important;
    border-radius: 6px !important;

    background: var(--surface) !important;

    color: var(--text);

    text-align: left;

    font-size: 12px;
    font-weight: 700;
}

.navigation-signout:hover {
    border-color: var(--blue) !important;
    color: var(--blue) !important;
}


/* ==========================================================================
   ADMINISTRATOR VIEW SWITCHING
   ========================================================================== */

.admin-view {
    width: 100%;
    min-width: 0;
}

.admin-view:not(.is-active) {
    display: none;
}

.admin-view.is-active {
    display: block;
}


/* ==========================================================================
   CONTENT LIBRARY HEADING
   ========================================================================== */

.library-heading {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 24px;

    padding: 8px 0 22px;

    border-bottom: 1px solid var(--border);
}

.library-heading h2 {
    margin: 10px 0 8px;

    font-size: clamp(25px, 2.5vw, 34px);
    font-weight: 750;

    letter-spacing: -1.2px;
}

.library-heading p {
    margin: 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.6;
}

.library-heading .secondary-button {
    flex-shrink: 0;
}


/* ==========================================================================
   ADMINISTRATOR CHART GALLERY
   ========================================================================== */

.admin-chart-gallery {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 18px;

    align-items: stretch;
}

.admin-chart-gallery>.empty-state {
    grid-column: 1 / -1;

    min-height: 280px;

    display: flex;
    align-items: center;
    justify-content: center;
}


/* ==========================================================================
   ADMINISTRATOR CHART CARDS
   ========================================================================== */

.admin-chart-card {
    min-width: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.admin-chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 12px;

    padding: 16px 18px;

    border-bottom: 1px solid var(--border);
}

.admin-chart-card-category {
    color: var(--blue);

    font-size: 10px;
    font-weight: 750;

    letter-spacing: 1px;
    text-transform: uppercase;
}

.admin-chart-card-date {
    color: var(--muted);

    font-size: 10px;
    font-weight: 650;
}

.admin-chart-card-preview {
    position: relative;

    width: 100%;

    aspect-ratio: 1 / 1;

    overflow: hidden;

    background: var(--dark);
}

.admin-chart-card-preview canvas {
    display: block;

    width: 100% !important;
    height: 100% !important;
}

.admin-chart-card-content {
    padding: 18px;
}

.admin-chart-card-content h3 {
    margin: 0 0 10px;

    color: var(--text);

    font-size: 16px;
    font-weight: 750;

    line-height: 1.4;
    letter-spacing: -0.4px;
}

.admin-chart-card-content p {
    margin: 0;

    color: var(--muted);

    font-size: 12px;
    line-height: 1.7;
}

.admin-chart-card-actions {
    display: flex;
    flex-wrap: wrap;

    gap: 8px;

    padding: 0 18px 18px;
}

.admin-chart-card-actions button {
    flex: 1 1 auto;
}


/* ==========================================================================
   STATUS BADGES
   ========================================================================== */

.chart-status {
    display: inline-flex;
    align-items: center;

    padding: 6px 9px;

    border-radius: 4px;

    font-size: 10px;
    font-weight: 750;

    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.chart-status.is-draft {
    background: #fff2df;
    color: #98631c;
}

.chart-status.is-published {
    background: #eaf5ef;
    color: #28744b;
}


/* ==========================================================================
   RESPONSIVE — LAPTOP
   ========================================================================== */

@media (max-width: 1200px) {

    .admin-chart-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}


/* ==========================================================================
   RESPONSIVE — TABLET
   ========================================================================== */

@media (max-width: 800px) {

    .admin-chart-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .navigation-panel {
        padding: 28px;
    }

    .navigation-links button,
    .navigation-links a {
        font-size: 23px;
    }

}


/* ==========================================================================
   RESPONSIVE — MOBILE
   ========================================================================== */

@media (max-width: 600px) {

    .brand-name {
        display: none;
    }

    .header-right {
        gap: 14px;
    }

    .menu-toggle {
        width: 38px;
    }

    .navigation-panel {
        padding: 25px;
    }

    .navigation-links {
        padding-top: 20px;
    }

    .navigation-links button,
    .navigation-links a {
        padding: 19px 0;

        font-size: 22px;

        gap: 18px;
    }

    .library-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .library-heading .secondary-button {
        width: 100%;
    }

    .admin-chart-gallery {
        grid-template-columns: 1fr;
    }

    .admin-chart-card-header {
        padding: 14px;
    }

    .admin-chart-card-content {
        padding: 15px;
    }

    .admin-chart-card-actions {
        padding: 0 15px 15px;
    }

}

/* ==========================================================
   MACROCHART — PUBLISHED CHART CARD ALIGNMENT
   ========================================================== */

#publishedGallery .admin-chart-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#publishedGallery .admin-chart-card-content {
    flex: 1;
}

#publishedGallery .admin-chart-card-actions {
    margin-top: auto;
}