/* ====================================
   TaskMaster PWA - Main Stylesheet
   ==================================== */

/* CSS Variables for Theming */
:root {
    /* Primary Colors */
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    
    /* Secondary Colors */
    --secondary-color: #8b5cf6;
    --secondary-dark: #7c3aed;
    --secondary-light: #a78bfa;
    
    /* Accent Colors */
    --accent-color: #10b981;
    --accent-dark: #059669;
    --accent-light: #34d399;
    
    /* Neutral Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.3s ease;
    
    /* Z-Index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* Dark Theme */
.theme-dark {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    
    --border-color: #374151;
    --border-hover: #4b5563;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

.loader-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-bottom-color: var(--secondary-color);
    animation: spin 0.7s linear infinite reverse;
}

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

.loading-screen p {
    margin-top: var(--spacing-lg);
    color: var(--text-secondary);
    font-weight: 500;
}

/* Install Prompt */
.install-prompt {
    position: fixed;
    bottom: var(--spacing-lg);
    left: var(--spacing-lg);
    right: var(--spacing-lg);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-lg);
    z-index: var(--z-fixed);
    animation: slideUp 0.3s ease;
}

.install-prompt.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-prompt-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.install-prompt-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: 0.875rem;
}

.install-prompt-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Auth Screen */
.auth-screen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: var(--spacing-lg);
}

.auth-screen.hidden {
    display: none;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-2xl);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.app-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-lg);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-xl);
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-logo svg {
    width: 48px;
    height: 48px;
    stroke: white;
    stroke-width: 2.5;
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-form {
    animation: fadeIn 0.3s ease;
}

.auth-form.hidden {
    display: none;
}

.auth-form h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

/* Form Styles */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="datetime-local"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group.checkbox {
    display: flex;
    align-items: center;
}

.form-group.checkbox label {
    display: flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
}

.form-group.checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-left: var(--spacing-sm);
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--accent-dark);
}

.btn-danger {
    background: var(--error);
    color: white;
}

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

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.btn-text:hover {
    color: var(--primary-color);
    background: var(--bg-tertiary);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.btn-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--text-primary);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.btn-icon .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--error);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    padding: 0 4px;
}

.auth-switch {
    text-align: center;
    margin-top: var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* App Layout */
.app {
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main";
    grid-template-columns: 280px 1fr;
    grid-template-rows: 64px 1fr;
    height: 100vh;
    background: var(--bg-secondary);
}

.app.hidden {
    display: none;
}

/* Header */
.app-header {
    grid-area: header;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: var(--spacing-lg);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-xl);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item .count {
    margin-right: auto;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.nav-item .count.alert {
    background: var(--error);
    color: white;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item.active .count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: var(--spacing-xl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
}

.section-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.groups-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.group-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.group-item:hover {
    background: var(--bg-tertiary);
}

.group-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 500;
}

.group-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    grid-area: main;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
}

.content-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Tasks Container */
.tasks-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Task Card */
.task-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.task-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.task-card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.task-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.task-checkbox:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.task-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
}

.task-checkbox.checked svg {
    display: block;
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 3;
}

.task-checkbox svg {
    display: none;
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    word-wrap: break-word;
}

.task-card.completed .task-title {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.task-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    line-height: 1.6;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    align-items: center;
}

.task-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.task-badge svg {
    width: 14px;
    height: 14px;
}

.task-badge.priority-urgent {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.task-badge.priority-high {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.task-badge.priority-medium {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.task-badge.priority-low {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

.task-badge.group {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    stroke: var(--text-tertiary);
    margin-bottom: var(--spacing-lg);
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* FAB */
.fab {
    position: fixed;
    bottom: var(--spacing-xl);
    left: var(--spacing-xl);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary-color);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: var(--z-fixed);
}

.fab svg {
    width: 28px;
    height: 28px;
    stroke: white;
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

/* Toast */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: var(--z-tooltip);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
    border-right: 4px solid var(--primary-color);
}

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

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

.toast.warning {
    border-right-color: var(--warning);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    font-size: 0.875rem;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

/* Responsive */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }
    
    .sidebar {
        position: fixed;
        right: 0;
        top: 64px;
        bottom: 0;
        width: 280px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: var(--z-fixed);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
    
    .content-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .content-actions .btn {
        flex: 1;
    }
    
    .fab {
        bottom: var(--spacing-lg);
        left: var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }
    
    .main-content {
        padding: var(--spacing-md);
    }
    
    .toast-container {
        right: var(--spacing-sm);
        left: var(--spacing-sm);
    }
    
    .toast {
        min-width: 0;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Print Styles */
@media print {
    .app-header,
    .sidebar,
    .fab,
    .install-prompt {
        display: none !important;
    }
    
    .main-content {
        grid-column: 1 / -1;
        padding: 0;
    }
}
