/* ═══════════════════════════════════════════
   دستیار شخصی شاهرخی - Main Stylesheet
   Theme: Modern Glassmorphism + Card UI
   Direction: RTL / Mobile First
   ═══════════════════════════════════════════ */

/* --- CSS Variables --- */
:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-bg: rgba(37, 99, 235, 0.08);

    --success: #16a34a;
    --success-light: #22c55e;
    --success-bg: rgba(22, 163, 74, 0.08);

    --danger: #dc2626;
    --danger-light: #ef4444;
    --danger-bg: rgba(220, 38, 38, 0.08);

    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.08);

    --info: #0ea5e9;
    --info-bg: rgba(14, 165, 233, 0.08);

    --bg: #f5f7fb;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-sidebar: rgba(255, 255, 255, 0.95);
    --bg-header: rgba(255, 255, 255, 0.8);
    --bg-input: rgba(255, 255, 255, 0.9);

    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --border: rgba(226, 232, 240, 0.8);
    --border-light: rgba(226, 232, 240, 0.5);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
    --shadow: 0 4px 6px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.03);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.06), 0 4px 8px rgba(0,0,0,0.03);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.08), 0 8px 16px rgba(0,0,0,0.04);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;

    --sidebar-width: 260px;
    --header-height: 70px;

    --font-family: 'Vazirmatn', Tahoma, sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    --primary-bg: rgba(59, 130, 246, 0.15);

    --bg: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.95);
    --bg-glass: rgba(30, 41, 59, 0.7);
    --bg-sidebar: rgba(15, 23, 42, 0.95);
    --bg-header: rgba(15, 23, 42, 0.8);
    --bg-input: rgba(51, 65, 85, 0.6);

    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border: rgba(51, 65, 85, 0.6);
    --border-light: rgba(51, 65, 85, 0.4);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow: 0 4px 6px rgba(0,0,0,0.2);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.3);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.4);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
ul { list-style: none; }

/* --- App Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-light);
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text) !important;
}

.sidebar-logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-section-title {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.sidebar-nav ul {
    padding: 0.5rem;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.sidebar-nav a:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.sidebar-nav a.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    right: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-width: 0;
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Top Header --- */
.top-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-card);
    color: var(--text);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

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

/* --- Notifications --- */
.notification-wrapper {
    position: relative;
}

.notification-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    border: none;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.notification-btn:hover {
    background: var(--bg-card);
    color: var(--text);
}

.notification-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 360px;
    max-height: 480px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: dropDown 0.2s ease-out;
}

@keyframes dropDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.notification-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.notification-list {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 0.75rem;
}

.notification-item:hover { background: var(--primary-bg); }
.notification-item.unread { background: var(--primary-bg); }

.notification-item-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

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

.notification-item-content p {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.notification-item-content span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notification-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.notification-empty i { font-size: 2rem; margin-bottom: 0.5rem; }

/* --- User Menu --- */
.user-menu-wrapper {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
    font-size: 0.85rem;
    color: var(--text);
}

.user-menu-btn:hover {
    background: var(--bg-card);
    border-color: var(--border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 220px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    animation: dropDown 0.2s ease-out;
}

.user-dropdown a,
.user-dropdown button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: none;
    background: none;
    color: var(--text);
    font-family: var(--font-family);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-align: right;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 0.25rem 0;
}

.user-dropdown .logout-form button { color: var(--danger); }
.user-dropdown .logout-form button:hover { background: var(--danger-bg); }

/* --- Page Content --- */
.page-content {
    padding: 1.5rem;
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.card-body { padding: 1.25rem; }
.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-light);
    background: rgba(0,0,0,0.01);
}

/* --- Stats Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-card-icon.blue { background: var(--primary-bg); color: var(--primary); }
.stat-card-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-card-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-card-icon.purple { background: rgba(124, 58, 237, 0.08); color: #7c3aed; }

.stat-card-content { flex: 1; }
.stat-card-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-card-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* --- Alerts --- */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    animation: alertSlideIn 0.3s ease-out;
    position: relative;
}

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

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(22,163,74,0.2); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,0.2); }
.alert-warning { background: var(--warning-bg); color: #b45309; border: 1px solid rgba(245,158,11,0.2); }
.alert-info { background: var(--info-bg); color: #0369a1; border: 1px solid rgba(14,165,233,0.2); }

.alert-close {
    margin-right: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0.25rem;
}

.alert-close:hover { opacity: 1; }

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

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; box-shadow: 0 4px 12px rgba(22,163,74,0.3); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,0.3); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0284c7; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.75rem; font-size: 1rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }
.btn-text { background: none; border: none; color: var(--primary); cursor: pointer; font-family: var(--font-family); font-size: 0.8rem; }
.btn-text:hover { text-decoration: underline; }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    backdrop-filter: blur(4px);
    color: var(--text);
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-input::placeholder { color: var(--text-muted); }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 0.75rem center; padding-left: 2rem; }

.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    top: 50%;
    right: 0.9rem;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.input-icon .form-input { padding-right: 2.5rem; }

.password-toggle {
    position: absolute;
    top: 50%;
    left: 0.7rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem;
}

.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.forgot-link { font-size: 0.85rem; }

.auth-form { margin-top: 0.5rem; }
.auth-description { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1rem; line-height: 1.8; }

/* --- Page Header --- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* --- Search --- */
.search-box {
    position: relative;
}

.search-box input {
    padding: 0.55rem 0.9rem 0.55rem 2.5rem;
    padding-right: 2.5rem;
    font-family: var(--font-family);
    font-size: 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    backdrop-filter: blur(4px);
    color: var(--text);
    width: 280px;
    transition: var(--transition);
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
    width: 320px;
}

.search-box i {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* --- Filters --- */
.filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.4rem 0.85rem;
    font-family: var(--font-family);
    font-size: 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 2rem;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-btn:hover { border-color: var(--primary); color: var(--primary); }

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

/* --- Table --- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: right;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.02);
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}

table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
    vertical-align: middle;
}

table tbody tr { transition: var(--transition); }
table tbody tr:hover { background: var(--primary-bg); }
table tbody tr.completed { opacity: 0.6; }
table tbody tr.completed td:first-child { text-decoration: line-through; }

.table-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-info { background: var(--info-bg); color: #0369a1; }
.badge-gray { background: rgba(100,116,139,0.1); color: var(--text-secondary); }

/* --- Priority & Status --- */
.priority-critical { color: var(--danger) !important; font-weight: 700; }
.priority-high { color: #ea580c; }
.priority-medium { color: var(--warning); }
.priority-low { color: var(--text-muted); }

.status-todo { color: var(--text-muted); }
.status-progress { color: var(--primary); }
.status-done { color: var(--success); }
.status-cancelled { color: var(--danger); }

/* --- Priority Dots --- */
.priority-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 0.5rem;
}

.priority-dot.critical { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.2); }
.priority-dot.high { background: #ea580c; }
.priority-dot.medium { background: var(--warning); }
.priority-dot.low { background: var(--text-muted); }

/* --- Color Swatches --- */
.color-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    vertical-align: middle;
    margin-left: 0.4rem;
}

/* --- Tags --- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg);
    color: var(--text-secondary);
    margin: 0.15rem;
}

/* --- Profile Page --- */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.avatar-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border);
}

.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}

.avatar-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    background: var(--bg);
    border-radius: 2rem;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.avatar-upload-btn:hover { background: var(--primary-bg); color: var(--primary); }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: var(--text);
    background: var(--bg-card);
    transition: var(--transition);
}

.pagination a:hover { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.85rem; }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.modal-close:hover { color: var(--text); background: var(--bg); }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* --- Calendar --- */
.calendar-wrapper {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.calendar-header h3 { font-size: 1.1rem; }

.calendar-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
}

.calendar-nav-btn:hover { background: var(--primary-bg); color: var(--primary); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-weekday {
    padding: 0.6rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(0,0,0,0.02);
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    position: relative;
}

.calendar-day:hover { background: var(--primary-bg); }

.calendar-day.today {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 700;
}

.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
}

.calendar-day.other-month { color: var(--text-muted); }

/* --- Date Picker --- */
.datepicker-wrapper {
    position: relative;
}

.datepicker-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.datepicker-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

.datepicker-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 150;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    min-width: 300px;
    animation: dropDown 0.2s ease-out;
}

.datepicker-dropdown .calendar-nav-btn {
    width: 32px; height: 32px; font-size: 0.85rem;
}

.datepicker-dropdown .calendar-day { aspect-ratio: auto; padding: 0.4rem; }
.datepicker-dropdown .calendar-day:hover { border-radius: var(--radius-sm); }

.datepicker-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

/* --- Activity Chart --- */
.activity-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 150px;
    padding: 1rem 0;
}

.activity-bar {
    flex: 1;
    background: linear-gradient(to top, var(--primary), var(--primary-light));
    border-radius: 4px 4px 0 0;
    transition: var(--transition);
    min-width: 20px;
    position: relative;
    cursor: pointer;
}

.activity-bar:hover { opacity: 0.8; transform: scaleY(1.05); }

.activity-bar-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.activity-bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
}

/* --- Weekly Activity Grid --- */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.activity-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: rgba(0,0,0,0.04);
}

.activity-cell.active { background: var(--primary); }
.activity-cell.level-1 { background: rgba(37,99,235,0.2); }
.activity-cell.level-2 { background: rgba(37,99,235,0.4); }
.activity-cell.level-3 { background: rgba(37,99,235,0.6); }
.activity-cell.level-4 { background: rgba(37,99,235,0.85); }

/* --- Two Column Grid --- */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* --- Timeline --- */
.timeline {
    position: relative;
    padding-right: 1.5rem;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 1rem;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
    content: '';
    position: absolute;
    right: -1.8rem;
    top: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--bg);
}

.timeline-time { font-size: 0.75rem; color: var(--text-muted); }
.timeline-content { font-size: 0.85rem; margin-top: 0.15rem; }

/* --- Toggle Switch --- */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    right: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); right: auto; }

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.ml-auto { margin-right: auto; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .two-col-grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .search-box input {
        width: 100%;
    }

    .search-box input:focus {
        width: 100%;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .notification-dropdown {
        width: 300px;
        left: -50px;
    }

    .user-name {
        display: none;
    }

    .top-header {
        padding: 0 1rem;
    }

    .page-content {
        padding: 1rem;
    }

    .modal {
        width: 95%;
        margin: 1rem;
    }

    table thead {
        display: none;
    }

    table tbody tr {
        display: block;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-light);
    }

    table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0;
        border: none;
        font-size: 0.85rem;
    }

    table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        margin-left: 0.5rem;
    }

    .table-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .calendar-grid .calendar-day {
        font-size: 0.75rem;
    }

    .header-left .page-title {
        font-size: 1rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Print --- */
@media print {
    .sidebar, .top-header, .sidebar-overlay { display: none; }
    .main-content { margin-right: 0; }
    .page-content { padding: 0; }
}
