/* ============================================================
   Design tokens
   ============================================================ */
:root {
    --font-display: 'Rubik', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --c-teal: #015c63;
    --c-green: #08856D;
    --c-green-bright: #16DC80;
    --c-purple: #5625cf;
    --c-red: #8a2c22;

    --c-bg: #ffffff;
    --c-bg-sunken: #FAFAF9;
    --c-border: #E7E5E2;
    --c-text: #1C2624;
    --c-text-muted: #6B7573;

    --radius-sm: 0.4rem;
    --radius-md: 0.6rem;

    --rail-width: 60px;
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --footer-height: 40px;
    --widget-width: 220px;

    --bs-primary: #015c63;
    --bs-primary-rgb: 8, 133, 109;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-display);
    margin: 0;
    padding: 0;
    color: var(--c-text);
    background: var(--c-bg);
    display: grid;
    grid-template-rows: var(--topbar-height) 1fr var(--footer-height);
    min-height: 100vh;
}

::selection {
    background: var(--c-green-bright);
    color: var(--c-teal);
}

:focus-visible {
    outline: 2px solid var(--c-green);
    outline-offset: 2px;
}

/* ============================================================
   Top navigation
   ============================================================ */
.logo-img {
    height: 40px;
    width: auto;
    margin-right: 10px;
}

.topbar {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
    z-index: 20;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.topbar a {
    text-decoration: none;
}

.topbar-brand .brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: var(--c-teal);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--c-text-muted);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.15s;
}

.topbar-btn:hover {
    background: var(--c-bg-sunken);
    color: var(--c-teal);
}

.topbar-btn.account {
    border: 1px solid var(--c-border);
    color: var(--c-teal);
}
/* ============================================================
   App body: rail/sidebar + main + widgets
   ============================================================ */
.app-body {
    grid-row: 2;
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    min-height: 0;
    transition: grid-template-columns 0.25s ease;
}

.app-body.sidebar-expanded {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* ---- Sidebar ---- */
.Sidebar {
    grid-column: 1;
    background: var(--c-bg-sunken);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    /*overflow: hidden;*/
    min-height: 0;
    transition: width 0.3s ease;
    position: relative;


}

.sidebar-tabs {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 1.5rem;
    padding: 0.75rem 0;
    gap: 0.15rem;
    flex-shrink: 0;
}
.sidebar-tabs.disabled {
    display: none !important;
}

.sidebar-tab {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem var(--rail-width) 0.55rem 0;
    padding-left: calc((var(--rail-width) - 20px) / 2);
    background: transparent;
    border: none;
    color: var(--c-text-muted);
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.sidebar-tab.disabled{
    display: none !important;
}
.sidebar-tab .tab-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-tab .tab-label {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.app-body.sidebar-expanded .sidebar-tab .tab-label {
    opacity: 1;
}

.sidebar-tab:hover {
    color: var(--c-teal);
}

.sidebar-tab.active {
    color: var(--c-teal);
    border-left-color: var(--c-green);
    background: rgba(8, 133, 109, 0.07);
}

.sidebar-panels {
    flex: 1;
    overflow-y: auto;
    /*overflow: hidden;*/
    padding: 0 1rem 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.sidebar-panels.disabled {
   display: none !important;
}

.app-body.sidebar-expanded .sidebar-panels {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-panel {
    display: none;
}

.sidebar-panel.active {
    display: block;
}

.sidebar-panel h5 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--c-text-muted);
    font-family: var(--font-mono);
    margin: 1rem 0 0.5rem;
}

.sidebar-panel h5:first-child {
    margin-top: 0.25rem;
}

.sidebar-pin {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--c-text-muted);
    cursor: pointer;
    padding: 0.2rem;
    flex-shrink: 0;
    display: none;
}

.app-body.sidebar-expanded .sidebar-pin {
    display: inline-flex;
}

.sidebar-pin.pinned {
    color: var(--c-green);
}

/* ---- Main ---- */
.Main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem 2rem 2rem;
    gap: 1.25rem;
}

.main-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.work-row {
    display: block;
    position: relative;

    grid-template-columns: minmax(0, 1fr) var(--widget-width);
    gap: 1.25rem;
    align-items: start;
}
.work-main {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}
.section-header {
    color: var(--c-teal);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}







/* Mode dropdown next to the process button */
.mode-select-wrap {
    position: relative;
    width: 170px;
    min-width: 0px;
    max-width: 170px;
    flex: 1 1 0;
}

.mode-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;

    width: 100%;
    height: 40px;
    padding: 0 0.7rem;

    border: none;
    border-radius: 0.8rem;

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

    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 400;

    cursor: pointer;
}
.mode-select-arrow {
    flex: 0 0 auto;

    width: 6px;
    height: 6px;

    border-right: 1.5px solid var(--c-text-muted);
    border-bottom: 1.5px solid var(--c-text-muted);

    transform: translateY(-2px) rotate(45deg);
    transition: transform 150ms ease;
}

.mode-select-wrap.open .mode-select-arrow {
    transform: translateY(2px) rotate(225deg);
}

.mode-options {
    width: 100%;
    box-sizing: border-box;
    position: absolute;
    z-index: 100;

    top: calc(100% + 4px);
    left: 0;
    right: 0;

    padding: 0.25rem;

    border-radius: var(--radius-md);
    background: white;

    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);

    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;

    transition:
            opacity 120ms ease,
            transform 120ms ease;
}

.mode-select-wrap.open .mode-options {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mode-option {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);

    color: var(--c-text);
    font-family: var(--font-display);
    font-size: 0.82rem;

    cursor: pointer;
}

.mode-option:hover {
    background: var(--c-bg-sunken);
    color: var(--c-teal);
}

/**
both the mode select and the process button are in here
 */
.process-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    width: 50%;
    min-width: 0;
}

.mode-select-wrap {
    position: relative;

    flex: 1 1 0;
    min-width: 0;
}

.mode-select {
    width: 100%;
    min-width: 0;
}

#process-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: none;
}

/* Hide Queue / Output until they actually have content */
.Queue.is-empty,
.Output.is-empty {
    display: none;
}

/* Input card */
.Input {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    background: var(--c-bg);
}

.input-method-row {
    display: flex;
    align-items: center;
    height: 35px;
    min-height: 20px;
    margin: 0;
    gap: 0.5rem;

    padding: 0;
}

.input-method-row .modality-select-container {
    order: -1;

    width: 65px;
    min-width: 65px;
    max-width: 65px;

    flex: 0 0 65px;

    margin: 0;
    padding: 0;
}
.input-method-row #modality-select-wrap {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: none;
    margin: 0;
    padding: 0;
}

.input-method-row #modality-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;

    width: 100%;
    height: 35px;
    padding: 0 0.7rem;

    border: none;
    border-radius: 0.8rem;



    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 400;

    cursor: pointer;
}
.input-panel {
    display: none;
}

.input-panel.active {
    display: block;
}

/* Queue - slim strip under the input card */
.Queue {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.Queue .section-header {
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--c-text-muted);
}

/* Output */
.Output {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.output-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.2rem;
    color: var(--c-text-muted);
    font-size: 0.7rem;
    font-weight: 200;
    font-style: italic;
    opacity: 0.5;
}

.output-meta span {
    white-space: nowrap;
}

/* Popups */
.Popups {
    position: fixed;
    top: calc(var(--topbar-height) + 1rem);
    right: 1.5rem;
    z-index: 1050;
    width: 320px;
    pointer-events: none;
}

.Popups .alert {
    pointer-events: auto;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
    grid-row: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    border-top: 1px solid var(--c-border);
    background: var(--c-bg-sunken);
    color: var(--c-text-muted);
    font-size: 0.78rem;
}

.footer a {
    color: var(--c-text-muted);
    text-decoration: none;
}

.footer a:hover {
    color: var(--c-teal);
}


/* failed queue items and such */
/* todo make this look nicer idk */
.queue-item.failed {
    color: var(--c-red);
    border: 1px solid var(--c-red);
    background: rgba(192, 57, 43, 0.08);
}

.queue-error {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 16px;
    height: 16px;
    margin-right: 0.5rem;
    padding: 0;

    border: 0;
    border-radius: 50%;

    background: var(--c-red);
    color: white;

    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;
}

.queue-error:hover {
    background:var(--c-red);
}

.queue-error:focus-visible {
    outline: 2px solid var(--c-red);
    outline-offset: 2px;
}

/** MODALITY PLACEHOLDER ***/

#modality-select {
    width: 100%;
    height: 40px;
    padding: 0 0.7rem;

    display: inline-flex;
    align-items: center;
    justify-content: right;
    gap: 0.5rem;



    color: var(--c-text);
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 500;
}
#modality-select .modality-select-label {
    margin: 0;
    padding: 0;
}

#modality-options {
    width: 120px;
}

#modality-select {
    width: 85px;
}


/** Output scaling of media **/
.output-media {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

/* ==== USER SETTINGS STYLING ==== */
.settings-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--c-border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row .btn-toggle,
.settings-row .btn-danger {
    margin-left: auto;
}
/* cards */

.card-danger {
    border-color: var(--c-red);
}

.card-danger .card-title {
    color: var(--c-red);
}
/* stats cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.stat-tile {
    padding: 0.9rem 1rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    background: var(--c-bg-sunken);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--c-teal);
}

.stat-label {
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--c-text-muted);
}


/* stat table */
/* ======= DATA TABLE ======= */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.8rem;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
}

.data-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--c-text-muted);
    border-bottom: 1px solid var(--c-border);
}

.data-table td {
    color: var(--c-text);
    border-bottom: 1px solid var(--c-border);
}

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

.data-table tbody tr:hover {
    background: var(--c-bg-sunken);
}