@font-face {
    font-family: 'Anjoman';
    src: url('fonts/Anjoman-Medium.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #0f172a;
    --gray: #64748b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --body-bg: #f1f5f9;
    --text: #1e293b;
    --text-light: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 1rem;
    --radius-sm: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Anjoman', 'Vazir', 'IRANSans', 'Tahoma', sans-serif;
    background: var(--body-bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

/* تغییر دارک مود به ریشه HTML برای جلوگیری از پرش استایل */
html.dark-mode {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --light: #1e293b;
    --border: #334155;
    --card-bg: #1e293b;
    --body-bg: #0f172a;
    --text: #f1f5f9;
    --text-light: #94a3b8;
}

html.dark-mode .sidebar,
html.dark-mode .stat-card,
html.dark-mode .form-card,
html.dark-mode .charts-row,
html.dark-mode .task-item,
html.dark-mode .modal-content,
html.dark-mode .dropdown-content,
html.dark-mode .category-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(26, 31, 46, 0.9) 100%);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

html.dark-mode .form-control {
    background: #334155;
    color: var(--text);
    border-color: #475569;
}

.app {
    display: flex;
    min-height: 100vh;
    padding: 10px;
    gap: 20px;
}

.sidebar {
    width: 250px;
    background: rgba(255, 255, 255, 0.7); /* ارتقا به حالت شیشه‌ای مدرن */
    border-radius: 28px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 10px;
    height: calc(100vh - 20px);
    padding: 1.5rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--primary);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scaleX(0);
    width: 3px;
    height: 70%;
    background: var(--primary);
    border-radius: 3px;
    transition: transform 0.2s ease;
}

.nav-item:hover::before,
.nav-item.active::before {
    transform: translateY(-50%) scaleX(1);
}

.nav-item:hover {
    background: var(--light);
    color: var(--primary);
    transform: translateX(-5px);
}

.nav-item.active {
    background: var(--primary-light);
    color: white;
}

.nav-item.logout {
    color: var(--danger);
}
.nav-item.logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.theme-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--light);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: all 0.2s ease;
    margin-top: auto;
    margin-bottom: 1rem;
}

.theme-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.sidebar-footer {
    display: none;
}

.main-content {
    flex: 1;
    background: var(--card-bg);
    border-radius: 28px;
    padding: 2rem;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.main-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-name-simple {
    background: var(--light);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 500;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    transition: all 0.2s ease;
}

.stat-card:hover .stat-value {
    color: var(--primary-dark);
    transform: scale(1.05);
    display: inline-block;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.charts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.chart-box {
    flex: 1;
    text-align: center;
}

.chart-box canvas {
    max-width: 200px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.chart-box canvas:hover {
    transform: scale(1.02);
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.required {
    color: var(--danger);
    font-size: 1rem;
}

.input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.input-group .form-control {
    flex: 1;
    min-width: 120px;
}

.color-picker {
    width: 50px;
    height: 42px;
    padding: 0.25rem;
    cursor: pointer;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
    height: 100%;
}

.form-buttons .btn {
    flex: 1;
    justify-content: center;
}

textarea.form-control {
    resize: vertical;
    min-height: 42px;
    font-family: inherit;
}

.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.form-card:hover {
    box-shadow: var(--shadow-lg);
}

.form-card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Anjoman', sans-serif;
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: 'Anjoman', sans-serif;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: var(--light);
    color: var(--text);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--light);
    border-color: var(--primary);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.search-box {
    flex: 2;
    min-width: 200px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 3;
}

.filter-group select, .filter-group button {
    flex: 1;
    min-width: 100px;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

.task-item:hover {
    transform: translateX(-5px) translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.task-item:active {
    cursor: grabbing;
}

.task-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.checkbox-container {
    display: inline-block;
    position: relative;
    cursor: pointer;
    font-size: 1.25rem;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: relative;
    display: inline-block;
    height: 22px;
    width: 22px;
    background-color: var(--light);
    border: 2px solid var(--primary);
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.checkbox-container:hover .checkmark {
    transform: scale(1.1);
    background-color: var(--primary-light);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
    animation: pulse 0.3s ease;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
}

.task-title.completed {
    text-decoration: line-through;
    opacity: 0.6;
}

.task-priority {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.priority-high { background: var(--danger); }
.priority-medium { background: var(--warning); }
.priority-low { background: var(--secondary); }

.task-category {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    align-items: center;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
    margin-right: auto;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background: var(--light);
    transform: scale(1.1);
}

#message-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    max-width: 400px;
}

.message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--card-bg);
    padding: 0.75rem 1.25rem;
    border-radius: 3rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 0.5rem;
    border-right: 4px solid;
    animation: slideIn 0.3s ease;
}

.message-success { border-right-color: var(--secondary); }
.message-error { border-right-color: var(--danger); }
.message-warning { border-right-color: var(--warning); }

.message-close {
    margin-right: auto;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 25px;
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
}

.category-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--light);
    padding: 10px 15px;
    border-radius: 16px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.delete-cat-btn {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-cat-btn:hover {
    transform: scale(1.05);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); background: var(--primary-light); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

@media (max-width: 768px) {
    .app {
        flex-direction: column;
        padding: 10px;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 1rem;
        margin-bottom: 1rem;
    }
    .nav {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .main-content {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .controls-row {
        flex-direction: column;
    }
    .filter-group {
        width: 100%;
    }
    .form-row-2col,
    .form-row-3col {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .input-group {
        flex-wrap: wrap;
    }
    .color-picker {
        width: 60px;
    }
    .form-buttons {
        flex-direction: column;
    }
    .form-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .form-card {
        padding: 1rem;
    }
    .input-group {
        flex-direction: column;
    }
    .input-group .form-control,
    .color-picker {
        width: 100%;
    }
    .category-grid {
        grid-template-columns: 1fr;
    }
}

@media print {
    .sidebar,
    .header-actions,
    .controls-row,
    .form-card,
    .theme-btn,
    .task-actions,
    .btn-icon,
    .charts-row,
    .user-dropdown {
        display: none !important;
    }
    .main-content {
        padding: 0;
    }
    .task-item {
        break-inside: avoid;
        border: 1px solid #ddd;
    }
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-wrapper {
    width: 100%;
    max-width: 450px;
    padding: 1rem;
}

.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    color: var(--primary);
    margin-top: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
}

.profile-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-family: 'Anjoman', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.tab-btn:hover::after,
.tab-btn.active::after {
    transform: scaleX(1);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-content {
    display: none;
    animation: slideUp 0.3s ease;
}

.tab-content.active {
    display: block;
}

.date-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.date-wrapper .datepicker-input {
    flex: 1;
    padding-left: 40px;
    cursor: pointer;
    background-color: var(--card-bg);
    direction: ltr;
    text-align: right;
}

.date-wrapper .date-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    pointer-events: none;
    opacity: 0.6;
}

.datepicker-input[readonly] {
    background-color: var(--card-bg);
    cursor: pointer;
}

.favicon-upload {
    margin-top: 0.5rem;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.upload-btn {
    background: var(--primary);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border: none;
}

.upload-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.upload-btn input {
    display: none;
}

.file-name {
    color: var(--text-light);
    font-size: 0.85rem;
    background: var(--light);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    word-break: break-all;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.current-favicon {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--light);
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.favicon-img {
    height: 32px;
    width: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: white;
    padding: 2px;
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.02);
}

html.dark-mode .file-name,
html.dark-mode .current-favicon {
    background: #334155;
    color: #e2e8f0;
}

html.dark-mode .favicon-img {
    background: #1e293b;
}