/*
 * TTasks — Stylesheet
 *
 * Port direto das CSS variables do index.css original (Tailwind → Vanilla CSS).
 * Mantém a mesma identidade visual: JetBrains Mono, dark/light themes, animações.
 */

/* ─── CSS Variables: Light Theme ─── */
:root {
    --background: 210 17% 98%;
    --foreground: 210 11% 15%;
    --card: 0 0% 100%;
    --card-foreground: 210 11% 15%;
    --popover: 0 0% 100%;
    --popover-foreground: 210 11% 15%;
    --primary: 210 11% 15%;
    --primary-foreground: 0 0% 100%;
    --secondary: 210 14% 93%;
    --secondary-foreground: 210 11% 25%;
    --muted: 210 14% 93%;
    --muted-foreground: 215 14% 45%;
    --accent: 210 14% 90%;
    --accent-foreground: 210 11% 15%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 100%;
    --border: 214 20% 88%;
    --input: 214 20% 88%;
    --ring: 215 14% 45%;
    --radius: 0.5rem;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ─── CSS Variables: Dark Theme ─── */
.dark {
    --background: 0 0% 0%;
    --foreground: 0 0% 90%;
    --card: 0 0% 5%;
    --card-foreground: 0 0% 90%;
    --popover: 0 0% 5%;
    --popover-foreground: 0 0% 90%;
    --primary: 0 0% 100%;
    --primary-foreground: 0 0% 0%;
    --secondary: 0 0% 10%;
    --secondary-foreground: 0 0% 80%;
    --muted: 0 0% 12%;
    --muted-foreground: 0 0% 50%;
    --accent: 0 0% 15%;
    --accent-foreground: 0 0% 90%;
    --destructive: 0 60% 50%;
    --destructive-foreground: 0 0% 100%;
    --border: 0 0% 20%;
    --input: 0 0% 12%;
    --ring: 0 0% 40%;
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-color: hsl(var(--border));
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
    transition: none !important;
}

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased; /* Deixa a fonte "limpa" como na Apple */
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em; /* Ajuste fino para o visual premium */
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
}

input, textarea {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased; /* Deixa a fonte "limpa" como na Apple */
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em; /* Ajuste fino para o visual premium */
        color: hsl(var(--foreground));
}

::selection {
    background: hsl(215 14% 60%);
    color: hsl(0 0% 100%);
}

.dark ::selection {
    background: hsl(0 0% 30%);
    color: hsl(0 0% 100%);
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--border));
    border-radius: 2px;
}

/* ─── Login Page ─── */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 24rem;
}

.login-title {
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: hsl(var(--foreground) / 0.8);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.4);
    letter-spacing: 0.1em;
    margin-bottom: 2rem;
}

.login-error {
    font-size: 0.75rem;
    color: hsl(var(--destructive) / 0.8);
    padding: 0 0.25rem;
    margin-bottom: 0.75rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-input {
    width: 100%;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: hsl(var(--card));
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    outline: none;
    transition: border-color 0.2s ease;
}

.login-input::placeholder {
    color: hsl(var(--muted-foreground) / 0.4);
}

.login-input:focus {
    border-color: hsl(var(--muted-foreground) / 0.4);
}

.login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.login-button:hover {
    opacity: 0.9;
}

.login-toggle {
    text-align: center;
    margin-top: 1.5rem;
}

.login-toggle a {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.5);
    transition: color 0.2s ease;
}

.login-toggle a:hover {
    color: hsl(var(--foreground));
}

/* ─── App Container ─── */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4rem 1rem 6rem;
}

@media (min-width: 640px) {
    .app-container {
        padding: 6rem 1rem 6rem;
    }
}

/* ─── Header ─── */
.app-header {
    width: 100%;
    max-width: 32rem;
    margin-bottom: 2.5rem;
}

.app-title {
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: hsl(var(--foreground) / 0.8);
    margin-bottom: 1rem;
}

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

.date-nav-btn {
    color: hsl(var(--muted-foreground) / 0.5);
    padding: 0.25rem;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.date-nav-btn:hover {
    color: hsl(var(--foreground));
}

.date-display {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: hsl(var(--foreground));
}

.header-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.task-count {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.5);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon-btn {
    color: hsl(var(--muted-foreground) / 0.4);
    transition: color 0.2s ease;
    padding: 0.375rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    position: relative;
}

.header-icon-btn:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--accent));
}

/* Theme toggle icon states */
.dark .icon-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0);
    position: absolute;
}

.dark .icon-moon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.icon-sun {
    opacity: 1;
    transform: rotate(0) scale(1);
    transition: all 0.3s ease;
}

.icon-moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
    position: absolute;
    transition: all 0.3s ease;
}

/* Calendar wrapper */
.calendar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.date-picker-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.date-picker-input::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.today-badge {
    font-size: 10px;
    letter-spacing: 0.1em;
    color: hsl(var(--muted-foreground) / 0.5);
    border: 1px solid hsl(var(--border));
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    line-height: 1;
}

.today-btn {
    font-size: 10px;
    letter-spacing: 0.1em;
    color: hsl(var(--muted-foreground) / 0.4);
    border: 1px solid hsl(var(--border));
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    line-height: 1;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.today-btn:hover {
    color: hsl(var(--muted-foreground));
    border-color: hsl(var(--muted-foreground) / 0.3);
}

/* ─── Task Input ─── */
.task-input-wrapper {
    width: 100%;
    max-width: 32rem;
    margin-bottom: 2rem;
}

.task-input-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: hsl(var(--card));
    transition: border-color 0.2s ease;
}

.task-input-box:focus-within {
    border-color: hsl(var(--muted-foreground) / 0.4);
}

.task-input-icon {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.task-input {
    flex: 1;
    background: transparent;
    font-size: 0.875rem;
    border: none;
    outline: none;
}

.task-input::placeholder {
    color: hsl(var(--muted-foreground) / 0.4);
}

/* ─── Section Tabs ─── */
.sections-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 32rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
    padding-bottom: 0.5rem;
    overflow-x: auto;
}

.section-tab {
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.section-tab:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--accent));
}

.section-tab.active {
    color: hsl(var(--foreground));
    background: hsl(var(--accent));
}

.sections-container {
    width: 100%;
    max-width: 32rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.section-pane {
    width: 100%;
    animation: fadeIn 0.2s ease;
}

.section-pane .task-list {
    max-width: 100%;
    margin-bottom: 2rem;
}

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

/* ─── Task List ─── */
.task-list {
    width: 100%;
    max-width: 32rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 4rem;
    list-style: none;
}

.task-item {
    border-radius: var(--radius);
    transition: background-color 0.15s ease;
}

.task-item:hover {
    background: hsl(var(--card));
}

.task-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

/* Drag handle */
.drag-handle {
    flex-shrink: 0;
    opacity: 0;
    color: hsl(var(--muted-foreground) / 0.3);
    cursor: grab;
    transition: opacity 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.task-item:hover .drag-handle {
    opacity: 1;
}

.drag-handle:hover {
    color: hsl(var(--muted-foreground));
}

/* Status button */
.task-status-btn {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    border: 1px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    transition: all 0.15s ease;
}

.status-todo {
    border-color: hsl(var(--muted-foreground) / 0.4);
}

.status-todo:hover {
    border-color: hsl(var(--muted-foreground));
}

.status-completed {
    background: hsl(var(--foreground));
    border-color: hsl(var(--foreground));
    color: hsl(var(--background));
}

.status-onhold {
    border-color: hsl(45 100% 50% / 0.7);
    color: hsl(45 100% 50%);
}

.status-onhold:hover {
    border-color: hsl(45 100% 50%);
}

.status-migrated {
    border-color: hsl(217 91% 60% / 0.7);
    color: hsl(217 91% 60%);
}

.status-migrated:hover {
    border-color: hsl(217 91% 60%);
}

/* Task text */
.task-text-btn {
    flex: 1;
    text-align: left;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s ease;
    color: hsl(var(--foreground));
    cursor: pointer;
}

.task-text-completed {
    text-decoration: line-through;
    color: hsl(var(--muted-foreground) / 0.4);
}

.task-text-onhold {
    color: hsl(45 100% 50% / 0.7);
}

.task-text-content {
    flex: 1;
}

/* Hashtag tags */
.task-tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.45rem;
    border-radius: 1rem;
    background: hsl(217 91% 60% / 0.12);
    color: hsl(217 91% 55%);
    white-space: nowrap;
    vertical-align: middle;
    margin-left: 0.15rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.task-tag:hover {
    background: hsl(217 91% 60% / 0.22);
}

.dark .task-tag {
    background: hsl(217 91% 60% / 0.18);
    color: hsl(217 91% 70%);
}

.dark .task-tag:hover {
    background: hsl(217 91% 60% / 0.3);
}

/* Recurring badge */
.task-recurring {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.45rem;
    border-radius: 1rem;
    background: hsl(142 71% 45% / 0.12);
    color: hsl(142 71% 35%);
    white-space: nowrap;
    vertical-align: middle;
    margin-left: 0.15rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.dark .task-recurring {
    background: hsl(142 71% 45% / 0.18);
    color: hsl(142 71% 60%);
}

.task-has-notes-icon {
    color: hsl(var(--muted-foreground) / 0.4);
    flex-shrink: 0;
}

.task-expand-icon {
    color: hsl(var(--muted-foreground) / 0.3);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.task-item:hover .task-expand-icon {
    opacity: 1;
}

.task-item.expanded .task-expand-icon {
    opacity: 1;
    transform: rotate(180deg);
}

/* Edit input (injected by JS) */
.task-edit-input {
    flex: 1;
    background: transparent;
    font-size: 0.875rem;
    font-family: var(--font-mono);
    color: hsl(var(--foreground));
    outline: none;
    border: none;
    border-bottom: 1px solid hsl(var(--muted-foreground) / 0.4);
    padding: 0;
}

/* Move to section */
.task-move-wrapper {
    position: relative;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s ease;
    display: flex;
    align-items: center;
}

.task-item:hover .task-move-wrapper {
    opacity: 1;
}

.task-move-btn {
    flex-shrink: 0;
    color: hsl(var(--muted-foreground) / 0.4);
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
    padding: 0;
    line-height: 1;
}

.task-move-btn:hover {
    color: hsl(var(--foreground));
}

.task-move-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 4px 20px hsl(var(--foreground) / 0.1);
    z-index: 100;
    min-width: 11rem;
    overflow: hidden;
}

.task-move-wrapper.open .task-move-dropdown {
    display: block;
    animation: fadeIn 0.15s ease;
}

.task-move-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: hsl(var(--foreground));
    transition: background 0.1s ease;
    white-space: nowrap;
    cursor: pointer;
}

.task-move-option:hover {
    background: hsl(var(--accent));
}

/* Delete */
.task-delete-btn {
    flex-shrink: 0;
    opacity: 0;
    color: hsl(var(--muted-foreground) / 0.4);
    transition: opacity 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    padding: 0;
    line-height: 1;
}

.task-item:hover .task-delete-btn {
    opacity: 1;
}

.task-delete-btn:hover {
    color: hsl(var(--destructive));
}

/* Notes panel */
.task-notes {
    padding: 0 1rem 0.75rem 2.75rem;
    border-left: 2px solid hsl(var(--border));
    margin-left: 23px;
    animation: notesSlideDown 0.15s ease-out;
}

.task-notes-textarea {
    width: 100%;
    background: transparent;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    border: none;
    outline: none;
    resize: none;
    min-height: 60px;
}

.task-notes-textarea::placeholder {
    color: hsl(var(--muted-foreground) / 0.3);
}

@keyframes notesSlideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
    }
}

/* Dragging state */
.task-dragging {
    opacity: 0.85;
    box-shadow: 0 4px 16px hsl(var(--foreground) / 0.08);
    background: hsl(var(--card));
    border-radius: var(--radius);
    z-index: 50;
}

/* SortableJS ghost class */
.sortable-ghost {
    opacity: 0.3;
}

.sortable-chosen {
    opacity: 0.85;
    box-shadow: 0 4px 16px hsl(var(--foreground) / 0.08);
    background: hsl(var(--card));
    border-radius: var(--radius);
}

/* ─── Empty State ─── */
.empty-state {
    width: 100%;
    max-width: 32rem;
    padding: 4rem 0;
    text-align: center;
}

.empty-state p {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.3);
    letter-spacing: 0.1em;
}

/* ─── Daily Notes ─── */
.daily-notes-section {
    width: 100%;
    max-width: 32rem;
    margin-bottom: 5rem;
}

.daily-notes-card {
    border: 1px solid hsl(var(--border));
    border-left: 3px dashed hsl(var(--border));
    border-radius: var(--radius);
    background: linear-gradient(135deg,
        hsl(var(--card) / 0.6),
        hsl(var(--card) / 0.3));
    padding: 1rem 1.25rem;
}

.daily-notes-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.5);
    font-size: 11px;
    letter-spacing: 0.1em;
}

.daily-note-textarea {
    width: 100%;
    background: transparent;
    font-size: 0.875rem;
    border: none;
    outline: none;
    resize: none;
    min-height: 100px;
    color: hsl(var(--foreground));
}

.daily-note-textarea::placeholder {
    color: hsl(var(--muted-foreground) / 0.25);
}

/* ─── Footer ─── */
.app-footer {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
}

.export-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.5);
    transition: color 0.2s ease;
}

.export-button:hover {
    color: hsl(var(--muted-foreground));
}

/* ─── Pomodoro ─── */
.pomodoro-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.pomodoro-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 180px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) * 1.5);
    box-shadow: 0 8px 32px hsl(var(--foreground) / 0.1);
    padding: 1.25rem 1rem 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Ring */
.pomodoro-ring-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pomodoro-ring {
    transform: rotate(-90deg);
    overflow: visible;
}

.pomodoro-ring-bg {
    fill: none;
    stroke: hsl(var(--border));
    stroke-width: 6;
}

.pomodoro-ring-progress {
    fill: none;
    stroke: hsl(var(--foreground));
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 276.46;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.pomodoro-ring-progress.running {
    stroke: hsl(217 91% 60%);
}

.pomodoro-ring-progress.done {
    stroke: hsl(142 71% 45%);
}

.pomodoro-display {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    letter-spacing: 0.05em;
}

/* Presets */
.pomodoro-presets {
    display: flex;
    gap: 0.4rem;
    width: 100%;
}

.pomodoro-preset {
    flex: 1;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.3rem 0;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    color: hsl(var(--muted-foreground));
    transition: all 0.15s ease;
    cursor: pointer;
}

.pomodoro-preset:hover,
.pomodoro-preset.active {
    border-color: hsl(var(--foreground));
    color: hsl(var(--foreground));
    background: hsl(var(--accent));
}

/* Controls */
.pomodoro-controls {
    display: flex;
    gap: 0.4rem;
    width: 100%;
}

.pomodoro-btn-primary {
    flex: 1;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.4rem 0;
    border-radius: var(--radius);
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    transition: opacity 0.15s ease;
    cursor: pointer;
}

.pomodoro-btn-primary:hover {
    opacity: 0.85;
}

.pomodoro-btn-secondary {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    color: hsl(var(--muted-foreground));
    transition: all 0.15s ease;
    cursor: pointer;
}

.pomodoro-btn-secondary:hover {
    color: hsl(var(--foreground));
    border-color: hsl(var(--foreground));
}

/* Active indicator on header button */
#pomodoro-btn.pomodoro-active {
    color: hsl(217 91% 60%);
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    .app-container {
        padding: 2rem 0.75rem 6rem;
    }

    .task-row {
        padding: 0.625rem 0.75rem;
    }
}
