/* --- 0. FONTS --- */
@font-face {
    font-family: 'YekanBakh';
    src: url('https://files.imeow.ir/dl/default/YekanBakh.woff') format('woff');
    font-weight: 400;
}

@font-face {
    font-family: 'YekanBakh';
    src: url('https://files.imeow.ir/dl/default/YekanBakh-Bold.woff') format('woff');
    font-weight: 700;
}

/* --- 1. MONOCHROME TOKENS --- */
:root {
    --ease-ios: cubic-bezier(0.19, 1, 0.22, 1);
    --bg-body: #FFFFFF;
    --bg-surface: #F4F4F4;
    --bg-sheet: #FFFFFF;
    --border-heavy: #000000;
    --border-light: #E0E0E0;
    --text-primary: #000000;
    --text-secondary: #757575;
    --text-inverse: #FFFFFF;
    --shadow-card: 0 4px 0 rgba(0, 0, 0, 1);
    --radius-lg: 20px;
    --radius-md: 12px;
}

[data-theme="dark"] {
    --bg-body: #000000;
    --bg-surface: #1C1C1E;
    --bg-sheet: #121212;
    --border-heavy: #FFFFFF;
    --border-light: #333333;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --text-inverse: #000000;
    --shadow-card: 0 0 0 1px #333;
}

/* --- 2. GLOBAL RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg-body);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.4s ease;
}

body[dir="rtl"] {
    font-family: 'YekanBakh', sans-serif !important;
}

body[dir="rtl"] h1,
body[dir="rtl"] .serif {
    font-family: 'YekanBakh', sans-serif !important;
    font-weight: 700;
}

/* --- 3. LAYOUT --- */
#app-frame {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s;
}

#app-frame.loaded {
    opacity: 1;
}

/* --- 4. HEADER --- */
.solid-header {
    margin-top: 43px;
    padding-top: max(20px, env(safe-area-inset-top));
    background: var(--bg-body);
    border-bottom: 2px solid var(--border-heavy);
    padding-bottom: 8px;
    z-index: 20;
}

.header-top {
    padding: 10px 24px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.date {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

h1 {
    font-family: 'Fraunces', serif;
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

.profile-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--text-primary);
    overflow: hidden;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.profile-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 4px;
    margin: 0 24px 12px;
    background: var(--bg-surface);
    padding: 4px;
    border-radius: 12px;
}

.vt-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.vt-btn.active {
    background: var(--bg-body);
    color: var(--text-primary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Tabs */
.tabs-container {
    padding: 0 24px 12px;
    overflow-x: auto;
    display: flex;
    gap: 8px;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab-pill {
    padding: 8px 18px;
    border-radius: 100px;
    border: 1px solid var(--border-light);
    background: var(--bg-body);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: 0.2s;
}

.tab-pill.active {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

/* --- 5. TASK LIST --- */
.board-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 120px;
}

.task-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
    transition: all 0.2s;
    animation: slideUp 0.3s var(--ease-ios) backwards;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
}

.task-card:active {
    transform: scale(0.98);
    background: var(--border-light);
}

.task-card.done-card {
    opacity: 0.6;
    filter: grayscale(1);
}

.card-check {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-primary);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: 0.2s;
    background: var(--bg-body);
}

.card-check.checked {
    background: var(--text-primary);
}

.card-check.checked::after {
    content: '✓';
    color: var(--text-inverse);
    font-size: 14px;
    font-weight: bold;
}

.card-body {
    flex: 1;
}

.tag {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    border: 1px solid var(--text-primary);
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 8px;
}

.t-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
    color: var(--text-primary);
}

.t-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    font-weight: 500;
    align-items: center;
}

.icon-meta {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-meta svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 6. FAB --- */
.fab-container {
    position: fixed;
    bottom: 32px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 30;
}

.fab {
    pointer-events: auto;
    background: var(--text-primary);
    color: var(--text-inverse);
    height: 60px;
    padding: 0 32px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: 0.2s;
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* --- 7. SHEETS --- */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    backdrop-filter: blur(4px);
}

.sheet-overlay.open {
    opacity: 1;
    visibility: visible;
}

.sheet-card {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-sheet);
    border-top: 2px solid var(--text-primary);
    border-radius: 32px 32px 0 0;
    padding: 12px 0 40px;
    transform: translateY(100%);
    transition: transform 0.5s var(--ease-ios);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.sheet-overlay.open .sheet-card {
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 6px;
    background: var(--border-light);
    border-radius: 100px;
    margin: 0 auto 20px;
}

.sheet-content {
    padding: 0 24px;
    overflow-y: auto;
    flex: 1;
}

/* Attachments Grid */
.attach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.attach-item {
    aspect-ratio: 1;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
}

.attach-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-file-icon {
    font-size: 24px;
    color: var(--text-primary);
}

.attach-del {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    cursor: pointer;
}

/* Inputs */
.input-lg {
    width: 100%;
    background: transparent;
    border: none;
    font-family: 'Fraunces', serif;
    font-size: 26px;
    color: var(--text-primary);
    outline: none;
    margin-bottom: 20px;
    resize: none;
}

.btn-block {
    width: 100%;
    padding: 18px;
    border-radius: 16px;
    background: var(--text-primary);
    color: var(--text-inverse);
    font-size: 16px;
    font-weight: 700;
    border: none;
    margin-top: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn-block.secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn-outline {
    border: 1px solid var(--border-light);
    background: transparent;
    padding: 12px;
    border-radius: 12px;
    width: 100%;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Subtasks */
.subtask-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.st-check {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.st-check.checked {
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.st-check.checked::after {
    content: '✓';
    color: var(--text-inverse);
    font-size: 14px;
    font-weight: bold;
}

.st-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
}

.st-input.done {
    text-decoration: line-through;
    color: var(--text-secondary);
}

/* Settings Toggle */
.toggle-switch {
    width: 50px;
    height: 30px;
    background: var(--border-light);
    border-radius: 100px;
    position: relative;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-knob {
    width: 26px;
    height: 26px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: 0.3s var(--ease-ios);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active {
    background: var(--text-primary);
}

.toggle-switch.active .toggle-knob {
    transform: translateX(20px);
}

[dir="rtl"] .toggle-switch.active .toggle-knob {
    transform: translateX(-20px);
}

/* Menu Grid */
.sel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.sel-card {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
}

.sel-card:hover {
    border-color: var(--text-primary);
}

.sel-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

/* LOGIN OVERLAY */
#login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.login-card {
    background: var(--bg-surface);
    padding: 40px;
    border-radius: 32px;
    border: 1px solid var(--border-light);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
}

/* LOADING SPINNER */
#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}