@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────── */
:root {
  --primary: #6366f1;
  --primary-rgb: 99, 102, 241;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --secondary-rgb: 236, 72, 153;
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --danger: #f43f5e;
  --danger-rgb: 244, 63, 94;
  --warning: #f59e0b;
  --warning-rgb: 245, 158, 11;
  --info: #06b6d4;
  --info-rgb: 6, 182, 212;
  
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f8fafc;
  --sidebar-active: #6366f1;
  --sidebar-active-bg: rgba(99, 102, 241, 0.1);
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(99, 102, 241, 0.05), 0 4px 6px -2px rgba(99, 102, 241, 0.02);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  --shadow-premium: 0 10px 30px -10px rgba(99, 102, 241, 0.2);
  
  --radius: 1rem;
  --radius-sm: 0.6rem;
  --radius-lg: 1.5rem;
  --font: 'Tajawal', 'Plus Jakarta Sans', sans-serif;
  --sidebar-width: 260px;
  --header-height: 70px;
  --transition: cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

[data-theme="dark"] {
  --bg: #090d16;
  --bg-card: #131b2e;
  --bg-sidebar: #090d16;
  --sidebar-text: #64748b;
  --sidebar-text-hover: #f8fafc;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #1e293b;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
  --shadow-premium: 0 10px 35px -10px rgba(0, 0, 0, 0.6);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sidebar-logo .logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.sidebar-logo .logo-text { color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.sidebar-logo .logo-sub { color: var(--sidebar-text); font-size: .75rem; font-weight: 500; opacity: 0.8; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1.5rem 0; }
.nav-section { padding: .25rem 1.5rem .75rem; }

.nav-section-label {
  font-size: .73rem; font-weight: 700; letter-spacing: .06em;
  color: rgba(255,255,255, 0.25); text-transform: uppercase;
  margin-bottom: .6rem; padding-right: 0.5rem;
}

.nav-item {
  display: flex; align-items: center; gap: .85rem;
  padding: .7rem 1.1rem;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  margin: .15rem 0;
  font-size: .9rem; font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item i { width: 22px; text-align: center; font-size: 1rem; opacity: .7; transition: var(--transition); }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--sidebar-text-hover); }
.nav-item:hover i { opacity: 1; transform: scale(1.08); }

.nav-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
  font-weight: 600;
}
.nav-item.active i { opacity: 1; }

.sidebar-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-user {
  display: flex; align-items: center; gap: .75rem;
}

.sidebar-user .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1rem;
  overflow: hidden; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .info { flex: 1; overflow: hidden; }
.sidebar-user .name { color: #fff; font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .email { color: var(--sidebar-text); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.7; }

/* Main Content */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* Header */
.app-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .app-header {
  background: rgba(19, 27, 46, 0.8);
}

.header-search {
  position: relative; flex: 1; max-width: 420px; min-width: 0;
}

.header-search input {
  width: 100%;
  padding: .65rem 1.25rem .65rem 2.75rem;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 2rem;
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  outline: none;
  transition: var(--transition);
}

.header-search input:focus {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
  background: var(--bg-card);
}

.header-search .search-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .95rem; pointer-events: none;
}

#search-results {
  position: absolute; top: calc(100% + .5rem); right: 0; left: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 380px; overflow-y: auto; z-index: 200;
  display: none;
  animation: slideDown 0.25s ease;
}

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

#search-results.show { display: block; }

.search-result-item {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition); cursor: pointer;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); }
.search-result-item .type-badge {
  padding: .25rem .6rem; border-radius: .4rem; font-size: .7rem; font-weight: 700; white-space: nowrap;
}

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

.header-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border); background: var(--bg-card);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition);
  position: relative;
}
.header-btn:hover {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
  transform: translateY(-1px);
}
.btn-sidebar-toggle { display: none; }

/* Page Content */
.page-content { flex: 1; padding: 2rem; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem; flex-wrap: wrap; gap: 1.25rem;
}
.page-title { font-size: 1.6rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.page-title span { color: var(--primary); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-body { padding: 1.5rem; }
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.01);
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex; align-items: center; gap: 1.25rem;
  transition: var(--transition);
  position: relative; overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--card-color, var(--primary));
  border-radius: 0 99px 99px 0;
}

.stat-card::after {
  content: '';
  position: absolute;
  width: 100px;
  height: 100px;
  background: var(--card-color, var(--primary));
  border-radius: 50%;
  bottom: -40px;
  left: -40px;
  opacity: 0.04;
  pointer-events: none;
  transition: var(--transition);
}

.stat-card:hover::after {
  transform: scale(1.3);
  opacity: 0.08;
}

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

.stat-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  background: var(--card-color, var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 2;
}

.stat-info { position: relative; z-index: 2; }
.stat-info .value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; margin-bottom: .3rem; font-family: 'Plus Jakarta Sans', sans-serif; }
.stat-info .label { font-size: .83rem; color: var(--text-muted); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.35rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .9rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 6px 15px rgba(99, 102, 241, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
  box-shadow: 0 6px 15px rgba(16, 185, 129, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #e11d48 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}
.btn-danger:hover {
  box-shadow: 0 6px 15px rgba(244, 63, 94, 0.35);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-info {
  background: linear-gradient(135deg, var(--info) 0%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

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

.btn-sm { padding: .45rem 1rem; font-size: .82rem; }

.btn-icon {
  width: 38px; height: 38px; padding: 0;
  justify-content: center; border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-icon:hover {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .5rem; color: var(--text); }
.form-control {
  width: 100%;
  padding: .7rem 1rem;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  outline: none;
  transition: var(--transition);
}
.form-control:focus {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
  background: var(--bg-card);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }
textarea.form-control { resize: vertical; min-height: 120px; border-radius: var(--radius-sm); }
select.form-control { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }

/* Grid */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

.grid-stats {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.grid-charts {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 2fr 1fr;
}
.grid-sidebar-layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w, 300px);
  gap: 1.5rem;
  align-items: start;
}
.mindmap-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.grid-notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem;
}
.grid-goals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .65rem;
  border-radius: 99px;
  font-size: .75rem; font-weight: 700;
}
.badge-primary { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-danger  { background: rgba(244, 63, 94, 0.1);  color: var(--danger);  }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-info    { background: rgba(6, 182, 212, 0.1);  color: var(--info);    }
.badge-muted   { background: var(--bg);            color: var(--text-muted); }

/* Priority badges */
.priority-low    { background: rgba(16, 185, 129, 0.1); color: #047857; }
.priority-medium { background: rgba(245, 158, 11, 0.1); color: #b45309; }
.priority-high   { background: rgba(244, 63, 94, 0.1);  color: #be123c; }
.priority-urgent { background: rgba(153, 27, 27, 0.1);  color: #991b1b; }

[data-theme="dark"] .priority-low    { color: #34d399; }
[data-theme="dark"] .priority-medium { color: #fbbf24; }
[data-theme="dark"] .priority-high   { color: #fb7185; }
[data-theme="dark"] .priority-urgent { color: #f87171; }

/* Note Card */
.note-card {
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.note-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 100%; height: 4px;
  background: var(--note-color, var(--primary));
}
.note-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.note-card .note-body { padding: 1.25rem; flex: 1; }
.note-card .note-title { font-weight: 800; font-size: 1.05rem; margin-bottom: .5rem; color: var(--text); }
.note-card .note-content { font-size: .85rem; color: var(--text-muted); line-height: 1.6; }
.note-card .note-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.01);
}
.note-actions { display: flex; gap: .4rem; opacity: 0.45; transition: opacity 0.2s ease; }
.note-card:hover .note-actions { opacity: 1; }

/* Reminder Item */
.reminder-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1.25rem;
  transition: var(--transition);
  position: relative;
}
.reminder-item .rem-color {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.reminder-item.done { opacity: .55; }
.reminder-item.done .rem-title { text-decoration: line-through; }
.reminder-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Goal Progress */
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}
.goal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.progress-bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 0.75rem 0; }
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width .8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Table */
.table-wrapper {
  overflow-x: auto; border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg); padding: .95rem 1.25rem;
  font-size: .8rem; font-weight: 700; color: var(--text-muted);
  text-align: right; border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(99, 102, 241, 0.02); }
[data-theme="dark"] tbody tr:hover { background: rgba(99, 102, 241, 0.04); }

/* Pagination */
.pagination { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 .7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text); font-family: var(--font); font-size: .85rem;
  font-weight: 600;
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover, .page-btn.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(9, 13, 22, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(-15px);
  transition: var(--transition);
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 800; font-size: 1.15rem; color: var(--text); }
.modal-close {
  width: 34px; height: 34px;
  border: 1.5px solid var(--border); background: var(--bg); border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .75rem; justify-content: flex-end;
}

/* Toast */
#toast-container {
  position: fixed; bottom: 2rem; left: 2rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .75rem;
}
.toast {
  padding: .95rem 1.5rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .85rem;
  font-size: .9rem; font-weight: 600;
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
}
.toast.success { border-right: 4px solid var(--success); }
.toast.error   { border-right: 4px solid var(--danger);  }
.toast.warning { border-right: 4px solid var(--warning); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Auth Pages */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top right, #312e81 0%, #1e1b4b 60%, #090d16 100%);
  padding: 2rem;
}
.auth-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 3rem;
  width: 100%; max-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .auth-card { background: #131b2e; }

.auth-logo {
  text-align: center; margin-bottom: 2.25rem;
}
.auth-logo .icon {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2rem; color: #fff;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}
.auth-logo h1 { font-size: 1.45rem; font-weight: 800; color: var(--text); }
.auth-logo p { font-size: .85rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Utilities */
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary)    !important; }
.text-success { color: var(--success)    !important; }
.text-danger  { color: var(--danger)     !important; }
.text-warning { color: var(--warning)    !important; }
.text-info    { color: var(--info)       !important; }
.text-secondary { color: var(--secondary) !important; }
.text-center  { text-align: center; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.fw-700 { font-weight: 700; }
.fs-sm { font-size: .8rem; }

.empty-state {
  text-align: center; padding: 4rem 1.5rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3.5rem; opacity: .25; margin-bottom: 1.25rem; display: block; }
.empty-state h3 { font-size: 1.15rem; margin-bottom: .5rem; color: var(--text); }

/* Color picker row */
.color-options { display: flex; gap: .6rem; flex-wrap: wrap; }
.color-opt {
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: var(--transition);
}
.color-opt.selected, .color-opt:hover { border-color: var(--text); transform: scale(1.15); }

/* Chart container */
.chart-container { position: relative; height: 280px; }

/* Sidebar collapsed */
.sidebar-collapsed .sidebar { transform: translateX(100%); }
.sidebar-collapsed .main-content { margin-right: 0; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 992px) {
  .grid-charts {
    grid-template-columns: 1fr;
  }
  .grid-sidebar-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  
  /* Sidebar Mobile Fix (RTL Compatible) */
  .sidebar {
    right: -260px !important;
    left: auto !important;
    width: 260px !important;
    transform: none !important;
    transition: right 0.3s ease !important;
    z-index: 1050 !important;
  }
  .sidebar.mobile-open {
    right: 0 !important;
    transform: none !important;
    box-shadow: -6px 0 24px rgba(0,0,0,0.4) !important;
  }
  
  /* Main Content Layout */
  .main-content {
    margin-right: 0 !important;
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Header adjustments */
  .app-header {
    padding: 0 1rem !important;
    gap: 0.5rem !important;
  }
  .btn-sidebar-toggle {
    display: flex !important;
  }
  .header-search {
    max-width: none !important;
    flex: 1 !important;
  }
  .header-actions a {
    display: none !important;
  }
  
  /* Grids and Spacing */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  .grid-6 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .page-content {
    padding: 1.25rem 1rem !important;
  }
  .auth-card {
    padding: 2rem 1.5rem !important;
  }
  .mindmap-editor-grid {
    grid-template-columns: 1fr !important;
  }

  /* Form Filters Responsiveness */
  form[method="GET"] {
    flex-direction: column !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  form[method="GET"] input[type="date"],
  form[method="GET"] input[type="text"],
  form[method="GET"] select {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }
  form[method="GET"] > div {
    display: flex !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  form[method="GET"] .btn,
  form[method="GET"] a.btn {
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Tables Responsiveness */
  .table-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Overall prevention of horizontal scrolling */
  body, html, .app-wrapper {
    overflow-x: hidden !important;
  }
}

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

/* ── Mobile FAB (Floating Action Button) ────────────── */
.mobile-fab {
  display: none;
}

@media (max-width: 768px) {
  /* Hide page-header buttons that have a FAB equivalent */
  .page-header [data-mobile-fab] {
    display: none !important;
  }

  /* The FAB itself */
  .mobile-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 1.75rem;
    left: 1.25rem;
    z-index: 500;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45), 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease;
    text-decoration: none;
    animation: fabPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .mobile-fab:hover,
  .mobile-fab:active {
    transform: scale(1.12) translateY(-2px) !important;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55) !important;
    color: #fff;
  }

  /* Ripple on click */
  .mobile-fab::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
  }
  .mobile-fab:active::after {
    opacity: 1;
    transform: scale(1);
  }

  /* FAB tooltip label */
  .mobile-fab[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + .65rem);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-sidebar);
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
    padding: .35rem .75rem;
    border-radius: var(--radius-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  .mobile-fab:hover[data-label]::before {
    opacity: 1;
  }
}

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