:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: rgb(82, 212, 252);
    --secondary-color: #03dac6;
    --text-color: #e0e0e0;
    --error-color: #cf6679;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}


.top-nav {
    background-color: var(--surface-color);
    padding: 20px;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.nav-main {
    display: flex;
    align-items: center;
    gap: 2rem;
    white-space: nowrap;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
}

.nav-link:hover,
.nav-logout:hover {
    opacity: 0.85;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user-email {
    margin-right: 0.25rem;
}

.nav-logout {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-left: 0.5rem;
}

.nav-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.nav-toggle-bar {
    width: 22px;
    height: 2px;
    background-color: var(--text-color);
    border-radius: 999px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.main-content {
    flex: 1;
    margin-top: 2rem;
}

.site-footer {
    background-color: var(--surface-color);
    padding: 16px 0;
    margin-top: 3rem;
    color: #aaa;
    font-size: 0.85rem;
}

.site-footer .container {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

.card {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.workspace-create-form {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.workspace-create-form input[type="text"] {
    margin-bottom: 0;
    flex: 1;
}

.workspace-card {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.workspace-card > div {
    min-width: 0;
}


input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
    background-color: #2c2c2c;
    border: 1px solid #333;
    color: var(--text-color);
    padding: 10px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
}

input[type="file"] {
    width: 100%;
    max-width: 100%;
    color: var(--text-color);
    background-color: transparent;
    border: 1px dashed #444;
    padding: 10px;
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.9;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-reset {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}

.btn-reset:hover:not(:disabled) {
    background-color: rgba(82, 212, 252, 0.15);
    color: var(--primary-color);
}

.btn-reset:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.workspace-train-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: opacity 0.2s;
}

.workspace-train-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.workspace-train-btn:disabled {
    background-color: #555;
    color: #bbb;
    border: 1px solid #777;
    cursor: not-allowed;
}

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

.flash-messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.alert-danger {
    background-color: var(--error-color);
    color: #000;
}

.alert-info {
    background-color: var(--secondary-color);
    color: #000;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.95rem;
}

.field-hint {
    color: #888;
    font-size: 0.8rem;
}

.full-width {
    width: 100%;
}


.inference-layout {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 2rem;
    align-items: start;
}

.inference-preview {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 24px;
}

.inference-preview__info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.inference-preview__image {
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.inference-preview__image img {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 220px);
    object-fit: contain;
}

.inference-pill {
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.inference-score {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-color);
}

.inference-preview__placeholder {
    color: #666;
    text-align: center;
    padding: 3rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inference-threshold {
    gap: 0.75rem;
}

.inference-threshold__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 20px;
}

.inference-threshold input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.inference-threshold__value {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.threshold-slider-wrapper {
    position: relative;
    padding-top: 12px;
}

.threshold-pin {
    position: absolute;
    top: 6px;
    transform: translate(-50%, -100%);
    background-color: var(--primary-color);
    color: #000;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    white-space: nowrap;
}

.threshold-pin::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -8px;
    transform: translateX(-50%);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 8px solid var(--primary-color);
}

.threshold-pin__value {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.threshold-scale {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: #999;
}

.threshold-scale__item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.threshold-scale__label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.threshold-scale__value {
    font-family: 'Inter', sans-serif;
}

.threshold-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 360px;
    font-size: 0.82rem;
    color: #aaa;
}

.threshold-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    text-align: right;
}

.threshold-display__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
}

.threshold-display__value {
    font-weight: 600;
    font-size: 1rem;
}

@media (max-width: 1024px) {
    .inference-layout {
        grid-template-columns: 1fr;
    }

    .inference-preview {
        padding: 20px;
    }

    .inference-preview__info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

@media (max-width: 900px) {
    .container {
        padding: 12px 16px;
        box-sizing: border-box;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 0.95rem;
    }

    .top-nav {
        padding: 16px;
    }

    .nav-content {
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
    }

    .nav-main {
        flex: 1 1 auto;
        display: flex;
        flex-wrap: nowrap;
        gap: 0.75rem;
        min-width: 0;
    }

    .nav-actions {
        margin-left: auto;
        position: relative;
        gap: 0.5rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-user {
        display: none;
        position: absolute;
        top: calc(100% + 0.75rem);
        right: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 12px 16px;
        min-width: 200px;
        background-color: var(--surface-color);
        border: 1px solid #2a2a2a;
        border-radius: 8px;
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
        z-index: 20;
    }

    .nav-user.is-open {
        display: flex;
    }

    .nav-user-email {
        margin-right: 0;
    }

    .nav-logout {
        width: 100%;
        text-align: left;
    }

    .card {
        padding: 16px;
    }

    .page-header h1 {
        font-size: 1.6rem;
    }

    .workspace-create-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .workspace-card {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .workspace-train-controls {
        width: 100%;
    }

    .workspace-train-controls form,
    .workspace-train-controls button,
    .workspace-card form {
        width: 100%;
    }

    .inference-preview {
        padding: 16px;
    }

    .inference-preview__info {
        width: 100%;
        align-items: flex-start;
    }

    .inference-score {
        flex-direction: row;
        gap: 1rem;
    }
}

@media (max-width: 540px) {
    .nav-main a {
        font-size: 0.95rem;
    }

    .card {
        padding: 14px;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .page-header a {
        width: 100%;
        text-align: center;
    }

    .inference-preview__info {
        gap: 0.5rem;
    }

    .inference-score {
        flex-direction: column;
        gap: 0.25rem;
    }

    .threshold-pin {
        font-size: 0.72rem;
        padding: 4px 10px;
    }

    .threshold-scale {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .inference-preview__image {
        padding: 12px;
    }
}

@media (max-width: 420px) {
    .nav-user {
        min-width: 160px;
    }

    .nav-logout {
        width: 100%;
    }

    .threshold-slider-wrapper {
        padding-top: 20px;
    }

    .threshold-pin {
        top: 0;
    }

    button,
    .btn-reset {
        padding: 10px 16px;
    }
}
