/* ===== Two-column layout ===== */
.main-layout {
  flex: 1 1 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 0;
}
.main-col {
  flex: 1 1 0;
  min-width: 0;
  padding: 16px;
}
.timer-col {
  flex: 0 0 380px;
  position: sticky;
  top: 10px;
  align-self: stretch;
  border-inline-start: 1px solid var(--paper-line);
  padding: 16px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ===== شاشة التحميل الأولى: صفحة blank بلوجو في النص + نقاط تحميل (زي TickTick/Todoist) =====
   بتغطي الشاشة كلها (fixed فوق كل حاجة)، وبتتمسح من الـ DOM في main.js بعد أول render. */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink-soft);
}
.boot-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.boot-splash-logo {
  width: 96px;
  height: 96px;
  border-radius: 26px;
  box-shadow: var(--shadow);
  /* خلفية بيضا دايمة عشان اللوجو أسود — في الوضع الداكن كانت بتختفي */
  background: #ffffff;
  padding: 8px;
  box-sizing: border-box;
}
.boot-splash-dots {
  display: flex;
  gap: 8px;
}
.boot-splash-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pen);
  animation: boot-splash-bounce 1.2s ease-in-out infinite;
}
.boot-splash-dots span:nth-child(2) { animation-delay: 0.15s; }
.boot-splash-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes boot-splash-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.35; }
  50% { transform: translateY(-5px); opacity: 1; }
}

/* ===== Timer Panel ===== */
.timer-panel-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.timer-panel-title {
  font-family: "Almarai";
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.timer-panel-title .material-icons {
  font-size: 20px;
  color: var(--pen);
}
.timer-add-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 5px;
  transition: border-color 0.12s ease;
}
.timer-add-row:focus-within {
  border-color: var(--pen);
}
.timer-add-row input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  background: transparent;
  color: var(--ink);
  outline: none;
}
.timer-add-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--pen);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
}
.timer-add-btn:hover {
  background: var(--pen-soft);
}
.timer-add-btn .material-icons {
  font-size: 20px;
}
.timer-add-wrap {
  position: relative;
  flex: 0 0 auto;
}
.timer-type-popover {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 180px;
  background: var(--popup);
  border: 1px solid var(--popup-border);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 6px;
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 4px;
}
.timer-type-popover.open {
  display: flex;
}
.timer-type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: right;
}
.timer-type-option .material-icons {
  font-size: 20px;
  color: var(--pen);
}
.timer-type-option:hover {
  background: var(--paper);
}

.timer-empty {
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  padding: 20px 8px;
}

.timer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timer-item {
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: timerFadeIn 0.25s ease;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}
.timer-item.running {
  border-color: var(--done);
  box-shadow: 0 0 0 3px var(--done-soft);
}
@keyframes timerFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.timer-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.timer-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.timer-target-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--paper);
  border-radius: 999px;
  padding: 2px 8px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
  direction: ltr;
}
.timer-target-label .material-icons {
  font-size: 13px;
}
.timer-item.countdown-ended {
  border-color: var(--pen);
  box-shadow: 0 0 0 3px var(--pen-soft);
}
.timer-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
  flex: 0 0 auto;
}
.timer-item.running .timer-status-dot {
  background: var(--done);
  animation: timerPulse 1.4s ease-in-out infinite;
}
@keyframes timerPulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.35);
  }
  50% {
    opacity: 0.6;
    box-shadow: 0 0 0 5px rgba(46, 125, 50, 0);
  }
}
.timer-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.timer-clock {
  font-family: "Almarai", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.5px;
  direction: ltr;
}
.timer-controls {
  display: flex;
  gap: 6px;
}
.timer-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
}
.timer-btn:active {
  transform: scale(0.92);
}
.timer-btn .material-icons {
  font-size: 19px;
}
.timer-toggle-btn {
  background: var(--done-soft);
  color: var(--done);
}
.timer-toggle-btn:hover {
  background: var(--done);
  color: #fff;
}
.timer-toggle-btn.is-running {
  background: #fdecea;
  color: #c0392b;
}
.timer-toggle-btn.is-running:hover {
  background: #c0392b;
  color: #fff;
}
/* زر فتح وضع التركيز لكل مؤقت */
.timer-focus-btn {
  background: var(--pen-soft);
  color: var(--pen);
}
.timer-focus-btn:hover {
  background: var(--pen);
  color: #fff;
}
.timer-delete-btn {
  background: transparent;
  color: var(--ink-soft);
}
.timer-delete-btn:hover {
  background: #fdecea;
  color: #c0392b;
}

/* ===== Header row: icon pill (right) â€” logo (center) â€” more button (left) =====
   In RTL, first DOM child sits at the row's start (right) and the last at its end (left). */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.header-top-bar {
  display: flex;
  align-items: center;
  width: fit-content;
  gap: 2px;
  background: var(--paper);
  border-radius: 14px;
  padding: 4px;
  flex-shrink: 0;
}
.header-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--pen);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    transform 0.1s ease,
    color 0.15s ease;
}
.header-icon-btn:hover {
  background: var(--done-soft);
  color: var(--done);
}
.header-icon-btn:active {
  transform: scale(0.92);
}
/* توحيد الحجم البصري: الدائرة المليانة بتبان أكبر من النقط — نصغرها سنة */
#accountBtn .material-icons {
  font-size: 22px;
}
.header-icon-btn.is-linked {
  color: var(--done);
}
.side-nav-lang-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: 'Almarai', sans-serif;
}
.header-btn-label {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* "More" (â€¢â€¢â€¢) button â€” its own small pill, mirrors the icon pill on the other side */
.header-actions-wrap {
  position: relative;
  flex-shrink: 0;
}
.header-more-btn {
  background: transparent;
  border-radius: 8px;
  color: var(--ink-soft);
}
.header-more-btn.is-open {
  background: transparent;
  color: var(--pen);
}
.header-more-btn.is-open:hover {
  background: var(--paper);
  color: var(--pen);
}

/* ===== App shell: الشريط الجانبي (Sidebar) + المحتوى ===== */
.app-shell {
  flex: 1 1 0;
  display: flex;
  align-items: stretch;
  gap: 0;
}
.side-nav {
  flex: 0 0 64px;
  position: sticky;
  top: 10px;
  align-self: stretch;
  z-index: 50;
  background: transparent;
  border-inline-end: 1px solid var(--paper-line);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  /* أنيميشن الطي والتوسيع */
  transition: flex-basis 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-nav-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}
.side-nav-btn:hover {
  background: var(--paper);
  color: var(--ink);
}
.side-nav-btn:active {
  transform: scale(0.92);
}
/* النشط ستايل TickTick: الأيقونة ملونة فقط من غير خلفية */
.side-nav-btn.active {
  background: transparent;
  color: var(--pen);
  box-shadow: none;
}
.side-nav-btn.active:hover {
  background: var(--paper);
  color: var(--pen);
}
.side-nav-btn .material-icons {
  font-size: 22px;
}
/* أسماء الأقسام جنب الأيقونات — تظهر على الشاشات الكبيرة فقط، والزر الأول بيطويها */
.side-nav-label {
  display: none;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1;
}
/* زر الطي بيجنب زر الحساب في نفس السطر — مبياخدش سطر لوحده */
.side-nav-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.side-nav-collapse-btn { display: none; }
@media (min-width: 1350px) {
  .side-nav:not(.collapsed) .side-nav-head { flex-direction: row-reverse; }
  .side-nav-collapse-btn {
    display: flex;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }
  .side-nav-collapse-btn .material-icons {
    font-size: 19px;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .side-nav.collapsed .side-nav-collapse-btn .material-icons {
    transform: rotate(180deg);
  }
  /* في الإنجليزي الشريط على الشمال — اتجاه السهم بيتعكس */
  html[dir="ltr"] .side-nav-collapse-btn .material-icons {
    transform: rotate(180deg);
  }
  html[dir="ltr"] .side-nav.collapsed .side-nav-collapse-btn .material-icons {
    transform: rotate(0deg);
  }
}
@media (min-width: 1350px) {
  .side-nav:not(.collapsed) {
    flex-basis: 212px;
    align-items: stretch;
    padding: 12px 10px;
  }
  .side-nav:not(.collapsed) .side-nav-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    padding-inline: 13px;
  }
  .side-nav:not(.collapsed) .side-nav-head .side-nav-btn:last-child { flex: 1; }
  /* الأسماء بتظهر بأنيميشن مع التوسيع */
  .side-nav-btn .side-nav-label {
    display: inline;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    vertical-align: middle;
    transition:
      max-width 0.28s ease,
      opacity 0.22s ease;
  }
  .side-nav:not(.collapsed) .side-nav-btn .side-nav-label {
    max-width: 150px;
    opacity: 1;
  }
  .side-nav:not(.collapsed) .side-nav-divider { width: 100%; }
}
.side-nav-divider {
  width: 30px;
  height: 1px;
  background: var(--ink-soft);
  opacity: 0.2;
  margin: 6px 0;
  flex: 0 0 auto;
  transition: width 0.28s ease;
}
.app-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* الهيدر اتشال من التصميم — الشريط السفلي هو التنقل الوحيد على الموبايل
   والشريط الجانبي على الشاشات الكبيرة. الأزرار بتفضل في الـ DOM كـ hubs
   (الشريطان بيشغّلوها) لكن مخفية دائمًا. */
.header-card {
  display: none;
}

/* Dropdown menu panel */
.header-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 210px;
  background: var(--popup);
  border: 1px solid var(--popup-border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 160;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}
.header-actions-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.header-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  border-radius: 9px;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: right;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.header-menu-item .material-icons {
  font-size: 20px;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.header-menu-item:hover {
  background: var(--paper);
}
.header-menu-item:hover .material-icons {
  color: var(--pen);
}
.header-menu-item:active {
  transform: scale(0.98);
}
.header-menu-divider {
  height: 1px;
  background: var(--ink-soft);
  opacity: 0.2;
  margin: 5px 4px;
}
.header-menu-group {
  width: 100%;
}
.header-menu-group summary.header-menu-summary {
  list-style: none;
  cursor: pointer;
}
.header-menu-group summary.header-menu-summary::-webkit-details-marker {
  display: none;
}
.header-menu-summary .header-menu-chevron {
  margin-inline-start: auto;
  font-size: 18px;
  transition: transform 0.15s ease;
}
.header-menu-group[open] .header-menu-summary .header-menu-chevron {
  transform: rotate(180deg);
}
.header-menu-subitems {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-inline-start: 14px;
  margin-top: 2px;
}

/* ===== الشريط السفلي للموبايل (Bottom Tab Bar) — معيار Todoist/TickTick =====
   مخفي على الشاشات الكبيرة (الشريط الجانبي هو التنقل)، وظاهر على الموبايل
   بدل تكديس أيقونات الهيدر العلوي. */
.bottom-tabbar {
  display: none;
}
@media (max-width: 640px) {
  .wrap {
    /* حجز مكان التاببار العائم (قمته ~74px + الـ safe-area) — من غير الـ safe-area
       المحتوى كان بيزحف تحت التاببار على الموبايلات اللي فيها نوتش */
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .bottom-tabbar {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    position: fixed;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    z-index: 120;
    background: var(--paper);
    border: 1px solid var(--paper-line);
    border-radius: 20px;
    box-shadow: var(--shadow-hover);
    padding: 6px 4px;
  }
  .bottom-tabbar-btn {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit;
    cursor: pointer;
    border-radius: 10px;
  }
  .bottom-tabbar-btn .material-icons {
    font-size: 22px;
  }
  .bottom-tabbar-btn.active {
    color: var(--pen);
  }
  /* زرار المزيد ساكن في الشريط — بنفس مقاس باقي الأزرار */
  .bottom-tabbar .header-actions-wrap {
    position: relative;
    flex: 1 1 0;
    display: flex;
  }
  .bottom-tabbar .header-more-btn {
    flex: 1 1 0;
    min-height: 48px;
  }
  /* لوحة المزيد بتفتح لفوق كورقة عائمة فوق الشريط */
  .bottom-tabbar .header-actions-panel {
    position: fixed;
    top: auto;
    bottom: 92px;
    left: 12px;
    right: 12px;
    min-width: 0;
    max-height: 60vh;
    overflow-y: auto;
  }
  html[dir="ltr"] .bottom-tabbar .header-actions-panel {
    left: 12px;
    right: 12px;
  }
}

/* ===== Performance: content-visibility للقوائم الطويلة ===== */
/* بيقلل_work الـ layout والـ paint للعناصر اللي بعيدة عن الشاشة (زي virtual DOM بدون إعادة كتابة الـ markup).
   مهم: مينفعش يتحط على الحاويات اللي فيها بوب/هي dropdowns متفتحة (زي task-row/keyword-row) لأن
   الـ paint containment اللي بيجمبه بيقصّ أي عنصر absolute زايد عن حدود الحاوية — بيخلي قائمة
   "المزيد" تظهر متقطعة. -->
.week-day-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
}
.timeblock-layout .tbw-grid {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}

/* ===== عرض السطر: السكرول الداخلي (ديسكتوب عريض بس) =====
   لما dayViewMode === 'list' السكرول بيتقيد جوه .task-list بدل مستوى الصفحة.
   مقصود على الشاشات العريضة بس (min-width:1237px) — نفس breakpoint اللي عنده
   لوحة المؤقتات جنب المهام. الشاشات الأضيق بتستخدم سكرول الصفحة الطبيعي
   (اللوحة بتنزل تحت، وتجميد الارتفاع هناك كان بيخنق المحتوى).
   ملحوظة: نفس الـ breakpoint مستخدم في isWideListScroll() في events.js. */
@media (min-width: 1237px) {
  body.list-scroll .wrap {
    height: calc(100vh - 20px);
    overflow: hidden;
  }
  body.list-scroll .app-main {
    min-height: 0;
  }
  body.list-scroll .main-layout {
    min-height: 0;
  }
  body.list-scroll .main-col {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body.list-scroll #content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.list-scroll .day-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.list-scroll .task-list.view-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  /* القايمة المفتوحة: fixed بإحداثيات من الـ JS عشان تهرب من قصّ حاوية
     السكرول — الإحداثيات بتيجي inline من ui.openTaskMorePos */
  body.list-scroll .task-more-menu-wrap .task-more-dropdown.open {
    position: fixed;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    margin: 0;
    z-index: 200;
  }
  /* السكرول مخفي افتراضيًا وبيظهر بس على hover */
  @media (hover: hover) {
    body.list-scroll .task-list.view-list {
      scrollbar-color: transparent transparent;
    }
    body.list-scroll .task-list.view-list:hover {
      scrollbar-color: color-mix(in srgb, var(--ink-soft) 45%, transparent) transparent;
    }
    body.list-scroll .task-list.view-list::-webkit-scrollbar {
      width: 6px;
    }
    body.list-scroll .task-list.view-list::-webkit-scrollbar-thumb {
      background: transparent;
    }
    body.list-scroll .task-list.view-list:hover::-webkit-scrollbar-thumb {
      background: color-mix(in srgb, var(--ink-soft) 45%, transparent);
    }
    body.list-scroll .task-list.view-list:hover::-webkit-scrollbar-thumb:hover {
      background: color-mix(in srgb, var(--ink-soft) 75%, transparent);
    }
  }
}
