/* Vibes Todo - Clean Design System */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* ==========================================
   CSS Variables
   ========================================== */
:root {
    /* Colors - Monochrome */
    --color-bg: #ffffff;
    --color-surface: #eeeeee;
    --color-text: #18181b;
    --color-text-muted: #71717a;
    --color-text-faint: #a1a1aa;
    --color-border: #dddddd;

    /* Accent - Fuschia (used sparingly) */
    --color-accent: #ef4687;
    --color-accent-muted: #fcabc6;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "SF Mono", "Monaco", "Courier New", monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

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

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* ==========================================
   App Layout
   ========================================== */
.app {
    display: flex;
    flex-direction: column;
    max-width: 48rem;
    margin: 0 auto;
    padding: var(--space-xl);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: var(--space-md);
}

.app-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.auth-section {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-handle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.btn-link {
    text-decoration: none;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.btn-link:hover {
    color: var(--color-text);
    background-color: var(--color-surface);
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: var(--space-sm);
}

.content-scroll::-webkit-scrollbar {
    width: 6px;
}

.content-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.content-scroll::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 999px;
}

.content-scroll::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-text-faint);
}

/* ==========================================
   Base Components - Row
   ========================================== */
.row {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-top: 1px solid var(--color-border);
    transition: background-color var(--transition-fast);
}

.category>.row {
    padding: var(--space-md);
}

.row:has(.drag-handle:hover) {
    background-color: var(--color-surface);
}

.row>*:not(.drag-handle, .expand-toggle-btn) {
    margin-block: auto;
}

/* Hover reveal utility */
.hover-reveal {
    opacity: 0;
    color: var(--color-text-faint);
    transition:
        opacity var(--transition-fast),
        color var(--transition-fast);
}

.row:hover .hover-reveal {
    opacity: 1;
}

.hover-reveal:hover {
    color: var(--color-text);
}

/* Row content - clickable area for details */
.row-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.row-content:hover .item-name,
.row-content:hover .category-name {
    text-decoration: underline;
    text-decoration-color: var(--color-text-muted);
    text-underline-offset: 2px;
}

/* Suppress content hover when drag handle is hovered */
.row:has(.drag-handle:hover) .row-content:hover .item-name,
.row:has(.drag-handle:hover) .row-content:hover .category-name {
    text-decoration: none;
}

.row-content-arrow {
    color: var(--color-text);
    flex-shrink: 0;
    margin-left: var(--space-sm);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.row:hover .row-content-arrow {
    opacity: 1;
}

/* Hide arrow when drag handle or expand toggle is hovered */
.row:has(.drag-handle:hover) .row-content-arrow,
.row:has(.expand-toggle-btn:hover) .row-content-arrow {
    opacity: 0;
}

/* ==========================================
   Base Components - Buttons
   ========================================== */
.btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.btn:hover {
    color: var(--color-text);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: var(--space-sm) var(--space-md);
    color: #ffffff;
    background-color: var(--color-text);
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition:
        background-color var(--transition-fast),
        color var(--transition-fast);
}

.btn-primary:hover {
    color: #ffffff;
    background-color: var(--color-accent);
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs);
}

.btn-add .arrow {
    display: inline-block;
    transition: transform var(--transition-fast);
    width: 14px;
    text-align: center;
}

.btn-add:hover .arrow {
    transform: translateX(4px);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: #dc2626;
    border: 1px solid #dc2626;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--font-size-sm);
    transition:
        background-color var(--transition-fast),
        color var(--transition-fast);
}

.btn-danger:hover {
    background-color: #dc2626;
    color: white;
}

/* ==========================================
   Lists
   ========================================== */
.categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--color-border);
}

.message-page {
    max-width: 34rem;
    padding-top: var(--space-2xl);
}

.message-page-home {
    padding-top: 16vh;
}

.message-kicker {
    margin-bottom: var(--space-sm);
    color: var(--color-accent);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.message-title {
    margin-bottom: var(--space-md);
    font-size: var(--font-size-2xl);
    line-height: 1.15;
}

.message-body {
    max-width: 30rem;
    color: var(--color-text-muted);
}

.message-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    flex-wrap: wrap;
}

.projects-list,
.tasks-list {
    list-style: none;
    margin: 0;
    padding: 0;
    margin-left: var(--space-xl);
    margin-bottom: var(--space-md);
    border-left: 1px solid var(--color-border);
}

/* ==========================================
   Shared Item Styles
   ========================================== */
.item-name {
    font-size: var(--font-size-base);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.private-icon {
    margin-left: var(--space-xs);
    color: var(--color-text-muted);
    flex-shrink: 0;
    vertical-align: middle;
}

.item-spacer {
    flex: 1;
    min-width: 0;
}

.item-percent {
    font-size: var(--font-size-xs);
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    min-width: 2rem;
    text-align: right;
}

.item-slider {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 160px;
}

/* ==========================================
   Category
   ========================================== */
.category {
    list-style: none;
}

.category-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.category-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.category-name {
    font-size: var(--font-size-lg);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.category-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.category.collapsed>.projects-list {
    display: none;
}

/* ==========================================
   Project
   ========================================== */
.project-item {
    list-style: none;
}

.project-item .task-indicator {
    display: none;
}

.project-item.collapsed>.tasks-list {
    display: none;
}

.project-item.collapsed .task-indicator {
    display: inline;
}

/* ==========================================
   Add Items
   ========================================== */
.add-item {
    display: list-item;
    list-style: none;
    padding: var(--space-sm) 0;
    padding-left: calc(14px + 2 * var(--space-sm));
    opacity: 0.7;
    transition: opacity 0.2s;
}

.add-item:hover {
    opacity: 1;
}

/* ==========================================
   Progress Bar
   ========================================== */
.progress-bar {
    height: 4px;
    width: 160px;
    background-color: var(--color-surface);
    border-radius: 999px;
    margin-top: var(--space-sm);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--color-text);
    transition: width var(--transition-normal);
}

/* ==========================================
   Range Slider
   ========================================== */
.range-slider {
    --slider-height: 24px;
    --slider-thumb-width: 4px;
    --slider-radius: 4px;

    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: var(--slider-height);
    cursor: pointer;
    width: 100%;
    display: block;
    overflow: hidden;
    border-radius: var(--slider-radius);
}

.range-slider:focus {
    outline: none;
}

/* Webkit (Chrome, Safari, Edge) */
.range-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: var(--slider-height);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--slider-radius);
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: var(--slider-height);
    width: var(--slider-thumb-width);
    background: var(--color-text);
    border: none;
    border-radius: 0;
    box-shadow: -100vw 0 0 100vw var(--color-text-muted);
    transition: transform var(--transition-fast);
}

.range-slider:hover::-webkit-slider-thumb {
    background: var(--color-text);
}

/* Firefox */
.range-slider::-moz-range-track {
    width: 100%;
    height: var(--slider-height);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--slider-radius);
}

.range-slider::-moz-range-thumb {
    height: var(--slider-height);
    width: var(--slider-thumb-width);
    border: none;
    border-radius: 0;
    background: var(--color-text);
    box-shadow: -100vw 0 0 100vw var(--color-text-muted);
}

/* Compact variant */
.range-slider-compact {
    --slider-height: 20px;
    --slider-thumb-width: 3px;
    --slider-radius: 3px;
}

/* ==========================================
   Drag Handle
   ========================================== */
.drag-handle {
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.drag-handle::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 0%;
    width: calc(100% + var(--space-md) + calc(var(--space-sm) / 2));
    height: calc(100% + calc(var(--space-sm) * 2));
    transform: translate(calc(0.5 * var(--space-sm)), -50%);
}

/* SortableJS Classes for Grabbing State */
.sortable-chosen,
.sortable-drag {
    cursor: grabbing !important;
}

.category-header.sortable-chosen,
.project-item.sortable-chosen,
.task.sortable-chosen {
    cursor: grabbing !important;
}

/* ==========================================
   Expand Toggle
   ========================================== */
.expand-toggle-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

/* Expanded click target */
.expand-toggle-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0%;
    width: calc(100% + var(--space-sm) + calc(var(--space-sm) / 2));
    height: calc(100% + calc(2 * var(--space-sm)));
    transform: translate(calc(-0.5 * var(--space-sm)), -50%);
}

/* Expand toggle icon */
.expand-toggle-icon {
    flex-shrink: 0;
    color: var(--color-text-faint);
    transition:
        transform var(--transition-fast),
        color var(--transition-fast);
}

:is(.category, .project-item).collapsed .expand-toggle-icon {
    transform: rotate(-90deg);
}

.expand-toggle-btn:hover .expand-toggle-icon {
    color: var(--color-text);
}

/* Task count indicator */
.task-indicator {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0 var(--space-xs);
    min-width: 1.25rem;
    text-align: center;
    line-height: 1.4;
    margin-left: var(--space-sm);
    flex-shrink: 0;
}

/* ==========================================
   Drag & Drop States
   ========================================== */
.sortable-ghost {
    background-color: var(--color-surface);
    opacity: 0.8;
}

/* ==========================================
   Slideover Panel
   ========================================== */
.slideover {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 28rem;
    background: var(--color-bg);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.slideover-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
}

.slideover-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
}

.slideover-close {
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.slideover-close:hover {
    color: var(--color-text);
}

.slideover-body {
    flex: 1;
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.slideover-footer {
    margin-top: auto;
    padding-top: var(--space-xl);
}

/* ==========================================
   Form Fields
   ========================================== */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.field-label {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.field-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-sm) 0;
    font-family: inherit;
    font-size: var(--font-size-lg);
    color: var(--color-text);
    transition: border-color var(--transition-fast);
}

.field-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.field-textarea {
    width: 100%;
    background: var(--color-surface);
    border: none;
    border-radius: 4px;
    padding: var(--space-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--color-text-muted);
    line-height: 1.6;
    resize: vertical;
    transition: box-shadow var(--transition-fast);
}

.field-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-accent-muted);
}

.field-textarea::placeholder {
    color: var(--color-text-faint);
}

.field-value {
    font-size: var(--font-size-base);
    color: var(--color-text);
    padding: var(--space-sm) 0;
}

.field-value em {
    color: var(--color-text-faint);
    font-style: italic;
}

/* ==========================================
   Log Styles
   ========================================== */
.work-log-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--color-border);
}

.section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Compact Form */
.work-log-form {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.form-row-inline {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.form-row-inline:last-child {
    margin-bottom: 0;
}

.form-field-compact {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.form-field-compact:first-child {
    flex: 1;
}

.slider-compact {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.slider-compact .range-slider-compact {
    flex: 1;
}

.percent-display-compact {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    min-width: 2.5rem;
    text-align: right;
}

.input-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.input-box:focus {
    outline: none;
    border-color: var(--color-accent);
}

.input-box::placeholder {
    color: var(--color-text-faint);
}

.field-input-compact {
    width: 4rem;
    padding: var(--space-xs) var(--space-sm);
    text-align: center;
}

.field-input-description {
    flex: 1;
    padding: var(--space-sm);
}

.btn-log {
    background-color: var(--color-accent);
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: 3px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}

.btn-log:hover {
    opacity: 0.9;
}

/* Form Expandable Section */
.form-more-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    cursor: pointer;
    user-select: none;
    transition: opacity var(--transition-fast);
}

.form-more-toggle:hover {
    opacity: 0.7;
}

.form-more-line {
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* Extends .field-label pattern */
.form-more-text {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-text-muted);
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.form-more-toggle.open .form-more-text {
    color: var(--color-text);
}

.form-more-toggle.open .form-more-text::before {
    content: "− ";
}

.form-more-toggle:not(.open) .form-more-text::before {
    content: "+ ";
}

.form-expandable {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal) ease-out;
}

.form-expandable.open {
    max-height: 150px;
}

/* Extends .form-field pattern (flex column with gap) */
.form-expandable-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md) 4px 4px 4px;
}

/* Toggle Switch - built on .field-label and accent colors */
.toggle-switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    cursor: pointer;
    user-select: none;
}

/* Extends .field-label pattern */
.toggle-switch-text {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
}

.toggle-switch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Uses design system colors: surface, border, accent */
.toggle-switch-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 11px;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.toggle-switch-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: var(--color-text-muted);
    border-radius: 50%;
    transition: transform var(--transition-fast), background-color var(--transition-fast);
}

.toggle-switch-input:checked + .toggle-switch-slider {
    background-color: var(--color-accent-muted);
    border-color: var(--color-accent);
}

.toggle-switch-input:checked + .toggle-switch-slider::before {
    transform: translateX(18px);
    background-color: var(--color-accent);
}

.toggle-switch-input:focus + .toggle-switch-slider {
    box-shadow: 0 0 0 2px var(--color-accent-muted);
}

/* Extends .input-box - only adds datetime-specific sizing */
.datetime-field {
    width: 100%;
    padding: var(--space-sm);
}

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

/* Log Entries */
.work-log-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.work-log-entry {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.work-log-entry:last-child {
    border-bottom: none;
}

.work-log-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
    flex-wrap: wrap;
}

.work-log-date {
    font-size: var(--font-size-xs);
    color: var(--color-text-faint);
}

.badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px var(--space-xs);
    border-radius: 2px;
    font-weight: 500;
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-project {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.badge-task {
    background-color: var(--color-accent-muted);
    color: var(--color-accent);
}

.work-log-stats {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-xs);
}

.work-log-hours {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-text);
}

.work-log-arrow {
    opacity: 0.4;
}

.work-log-completion {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-text);
}

.work-log-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* ==========================================
   Utilities
   ========================================== */
.hidden {
    display: none !important;
}
