/* ============================================
   Text Humanizer - Dark Theme
   Matches DAT Workspace design language
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #222636;
    --bg-input: #2a2e3f;
    --border: #2e3348;
    --text-primary: #f5f6fa;
    --text-secondary: #cdd1e0;
    --text-muted: #a0a4b8;
    --accent: #6c8cff;
    --accent-hover: #8ba4ff;
    --green: #4ade80;
    --yellow: #facc15;
    --red: #f87171;
    --orange: #fb923c;
    --purple: #a78bfa;
    --radius: 8px;

    --header-height: 52px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
.header {
    background: rgba(15, 17, 23, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(108, 140, 255, 0.1);
    padding: 0 20px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.header__back:hover {
    background: rgba(108, 140, 255, 0.15);
    color: var(--text-primary);
}

.header__back svg {
    width: 20px;
    height: 20px;
}

.header__title {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 50%, var(--orange) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header__spacer {
    flex: 1;
}

/* ---------- Main Content ---------- */
.main-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
}

.humanizer-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.humanizer-container {
    flex: 1;
    min-width: 0;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---------- Step Indicator ---------- */
.steps-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 8px 0 4px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.step-item--active {
    opacity: 1;
}

.step-item--done {
    opacity: 0.7;
}

.step-item__number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(108, 140, 255, 0.12);
    border: 1px solid rgba(108, 140, 255, 0.2);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    transition: background 0.3s, border-color 0.3s;
}

.step-item--active .step-item__number {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.step-item--done .step-item__number {
    background: rgba(74, 222, 128, 0.15);
    border-color: rgba(74, 222, 128, 0.3);
    color: var(--green);
}

.step-item__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.step-item--active .step-item__label {
    color: var(--text-primary);
}

.step-item--clickable {
    cursor: pointer;
}

.step-item--clickable:hover {
    opacity: 0.9;
}

.step-item--clickable:hover .step-item__number {
    border-color: var(--accent);
}

.step-item__line {
    width: 48px;
    height: 1px;
    background: var(--border);
    margin: 0 12px;
}

/* ---------- Description ---------- */
.description {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding: 0 20px;
}

/* ---------- Upload Zone ---------- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: rgba(34, 38, 54, 0.4);
}

.upload-zone:hover {
    border-color: var(--accent);
    background: rgba(108, 140, 255, 0.05);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(108, 140, 255, 0.1);
    border-style: solid;
}

.upload-icon {
    width: 56px;
    height: 56px;
    color: var(--text-muted);
    margin-bottom: 14px;
    opacity: 0.6;
}

.upload-title {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ---------- Upload Progress ---------- */
.upload-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px;
    background: rgba(34, 38, 54, 0.6);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.upload-progress__text {
    color: var(--accent);
    font-size: 0.95rem;
}

/* ---------- Divider ---------- */
.divider-or {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0;
}

.divider-or::before,
.divider-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider-or span {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* ---------- Paste Area ---------- */
.paste-area {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.paste-area__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* ---------- View Jobs Link ---------- */
.view-jobs-link {
    display: flex;
    justify-content: center;
    padding: 4px 0;
}

/* ---------- Review Header ---------- */
.review-header {
    text-align: center;
    padding: 0 20px;
}

.review-header__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.review-header__hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ---------- Chunk Estimate ---------- */
.chunk-estimate {
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(108, 140, 255, 0.1);
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid rgba(108, 140, 255, 0.15);
}

/* ---------- Review Actions ---------- */
.review-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* ---------- Panels ---------- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel__title svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.panel__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- Text Areas ---------- */
.text-area {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

.text-area--large {
    min-height: 320px;
}

.text-area::placeholder {
    color: var(--text-muted);
}

.output-area {
    min-height: 200px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-area .placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* ---------- Processing Card ---------- */
.processing-card {
    background: rgba(34, 38, 54, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.processing-status {
    color: var(--accent);
    font-size: 1rem;
    font-weight: 500;
}

/* ---------- Progress Bar ---------- */
.progress-bar-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    border-radius: 4px;
    transition: width 0.4s ease;
}

.progress-bar__label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Queue Info ---------- */
.queue-info {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 8px 20px;
    background: rgba(108, 140, 255, 0.1);
    border: 1px solid rgba(108, 140, 255, 0.2);
    border-radius: 8px;
}

/* ---------- Jobs Header ---------- */
.jobs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.jobs-header__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---------- Jobs Table ---------- */
.jobs-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jobs-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: rgba(34, 38, 54, 0.4);
    border: 1px dashed var(--border);
    border-radius: 12px;
}

/* ---------- Job Row ---------- */
.job-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}

.job-row--clickable {
    cursor: pointer;
}

.job-row--clickable:hover {
    border-color: var(--accent);
    background: rgba(108, 140, 255, 0.05);
}

.job-row__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.job-row__right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.job-row__info {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.job-row__time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.job-row__arrow {
    color: var(--text-muted);
    opacity: 0.5;
    flex-shrink: 0;
}

.job-row--clickable:hover .job-row__arrow {
    color: var(--accent);
    opacity: 1;
}

/* ---------- Job Status Badge ---------- */
.job-status {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.job-status--pending {
    color: var(--yellow);
    background: rgba(250, 204, 21, 0.1);
    border: 1px solid rgba(250, 204, 21, 0.2);
}

.job-status--running {
    color: var(--accent);
    background: rgba(108, 140, 255, 0.1);
    border: 1px solid rgba(108, 140, 255, 0.2);
}

.job-status--completed {
    color: var(--green);
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.job-status--failed {
    color: var(--red);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

/* ---------- Back to Jobs ---------- */
.back-to-jobs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    margin-bottom: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s;
}

.back-to-jobs:hover {
    color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn--accent {
    background: var(--accent);
    color: #fff;
}

.btn--accent:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn--large {
    padding: 14px 32px;
    font-size: 15px;
}

.btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 14px;
    font-size: 13px;
}

.btn--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn--small {
    padding: 6px 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn--small:hover:not(:disabled) {
    background: rgba(108, 140, 255, 0.15);
    color: var(--accent);
    border-color: var(--accent);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn--small svg {
    width: 14px;
    height: 14px;
}

/* ---------- Access Denied ---------- */
.access-denied {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex: 1;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.access-denied h2 {
    color: var(--red);
    font-size: 1.3rem;
}

.access-denied p {
    font-size: 0.9rem;
    max-width: 300px;
}

.access-denied svg {
    color: var(--red);
    opacity: 0.6;
}

/* ---------- Spinner ---------- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.toast--success {
    border-color: var(--green);
}

.toast--error {
    border-color: var(--red);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Login Overlay ---------- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 17, 23, 0.95);
    backdrop-filter: blur(8px);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card__title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-card__subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-card__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
}

.login-card__field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-card__field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.login-card__field input:focus {
    border-color: var(--accent);
}

.login-card__error {
    color: var(--red);
    font-size: 0.8rem;
    min-height: 1.2em;
}

/* ---------- History Sidebar ---------- */
.history-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.history-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.history-sidebar__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-sidebar__list {
    max-height: 520px;
    overflow-y: auto;
}

.history-sidebar__empty {
    padding: 32px 14px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(46, 51, 72, 0.5);
    cursor: pointer;
    transition: background 0.12s;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: rgba(108, 140, 255, 0.06);
}

.history-item__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-item__dot--pending { background: var(--yellow); }
.history-item__dot--running { background: var(--accent); animation: pulse 1.5s infinite; }
.history-item__dot--completed { background: var(--green); }
.history-item__dot--failed { background: var(--red); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.history-item__info {
    flex: 1;
    min-width: 0;
}

.history-item__preview {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.history-item__meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .main-wrapper {
        padding: 16px 12px;
    }

    .humanizer-container {
        gap: 16px;
    }

    .upload-zone {
        padding: 32px 20px;
    }

    .steps-indicator {
        gap: 0;
    }

    .step-item__label {
        display: none;
    }

    .step-item__line {
        width: 32px;
        margin: 0 8px;
    }

    .review-actions {
        flex-direction: column;
    }

    .btn--large {
        width: 100%;
    }

    .panel__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .panel__actions {
        width: 100%;
        justify-content: space-between;
    }

    .paste-area__footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .job-row__left {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .job-row__right {
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
    }

    .history-sidebar {
        display: none;
    }
}
