/* =============================================
   Waqti Pro - Main Stylesheet (Enhanced UI/UX)
   ============================================= */

/* ===== CSS VARIABLES (DARK + LIGHT) ===== */
:root {
  --bg: #080810;
  --s1: #0f0f1a;
  --s2: #161625;
  --s3: #1e1e30;
  --gold: #f0b429;
  --gold2: #ffd166;
  --rose: #ff4d6d;
  --teal: #06d6a0;
  --blue: #4895ef;
  --purple: #7c3aed;
  --txt: #eeeef5;
  --dim: #6666aa;
  --border: #252538;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --glass: rgba(15,15,26,0.75);
}

[data-theme="light"] {
  --bg: #f5f5fa;
  --s1: #ffffff;
  --s2: #f0f0f5;
  --s3: #e8e8f0;
  --txt: #1a1a2e;
  --dim: #8888aa;
  --border: #dddde5;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --glass: rgba(255,255,255,0.85);
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: 'Cairo', sans-serif;
  min-height: 100vh;
  transition: background 0.4s, color 0.4s;
}

/* ===== NOISE TEXTURE ===== */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: 0.4;
}
[data-theme="light"] body::before { opacity: 0.15; }

/* ===== AUTH SCREENS ===== */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  animation: fadeUp 0.4s ease;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 44px 36px;
  width: 92%; max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s ease;
}
.auth-card img { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; }
.auth-card h2 { font-size: 1.4rem; font-weight: 900; margin-bottom: 6px; }
.auth-card h2 em { color: var(--gold); font-style: normal; }
.auth-card .sub { color: var(--dim); font-size: 0.82rem; margin-bottom: 22px; }
.auth-card input { width: 100%; margin-bottom: 12px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-card .switch-link { color: var(--dim); font-size: 0.82rem; margin-top: 14px; cursor: pointer; transition: color 0.2s; }
.auth-card .switch-link:hover { color: var(--gold); }
.auth-card .switch-link b { color: var(--gold); }
.auth-card .err { color: var(--rose); font-size: 0.8rem; margin-top: 10px; min-height: 22px; }

/* ===== SIDEBAR NAV ===== */
.sidebar {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 74px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 4px;
  z-index: 100;
  transition: background 0.4s, border-color 0.4s;
}
.nav-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  margin-bottom: 18px;
  object-fit: cover;
}
.nav-btn {
  width: 50px; height: 50px;
  border-radius: 14px;
  border: none;
  background: none;
  color: var(--dim);
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(.34,1.56,.64,1);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.nav-btn span.lbl { font-size: 0.55rem; font-family: 'Cairo', sans-serif; font-weight: 600; }
.nav-btn:hover { background: var(--s2); color: var(--txt); transform: scale(1.08); }
.nav-btn.active { background: rgba(240,180,41,0.15); color: var(--gold); }
.nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 24px;
  background: var(--gold);
  border-radius: 0 4px 4px 0;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  margin-top: auto;
  margin-bottom: 8px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--dim);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold); transform: rotate(25deg); }

/* ===== MAIN ===== */
.main {
  margin-left: 0;
  margin-right: 74px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== PAGES ===== */
.page { display: none; padding: 28px 24px; animation: fadeUp 0.35s ease; }
.page.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.page-title { font-size: 1.6rem; font-weight: 900; }
.page-title em { color: var(--gold); font-style: normal; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--dim);
  transition: all 0.3s;
}
.badge b { color: var(--gold); }
.badge-points { cursor: pointer; }
.badge-points:hover { border-color: var(--gold); transform: scale(1.06); }

/* ===== CARDS ===== */
.card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: background 0.4s, border-color 0.4s, box-shadow 0.3s;
}
.card:hover { box-shadow: 0 2px 16px rgba(0,0,0,0.15); }
.card-glow {
  position: absolute;
  width: 120px; height: 120px;
  border-radius: 50%;
  filter: blur(40px);
  top: -30px; left: -30px;
  pointer-events: none;
  opacity: 0.15;
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }

/* ===== STAT MINI ===== */
.stat-mini {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  transition: all 0.3s;
}
.stat-mini:hover { border-color: rgba(240,180,41,0.3); transform: translateY(-2px); }
.stat-mini .num { font-size: 1.8rem; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.stat-mini .lbl { font-size: 0.7rem; color: var(--dim); }

/* ===== SECTION LABEL ===== */
.sec-lbl {
  font-size: 0.65rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 22px 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.sec-lbl::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ===== INPUTS ===== */
input, select, textarea {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--txt);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s, background 0.3s, box-shadow 0.3s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,180,41,0.12);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
select option { background: var(--s2); }
input[type=time]::-webkit-calendar-picker-indicator { filter: invert(0.5); cursor: pointer; }

/* ===== BUTTONS ===== */
.btn {
  border: none; border-radius: 12px;
  font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 0.9rem;
  padding: 11px 20px; cursor: pointer;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), filter 0.2s, box-shadow 0.3s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); transform: scale(1.04); }
.btn:active { transform: scale(0.97); }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #000; box-shadow: 0 4px 14px rgba(240,180,41,0.25); }
.btn-rose { background: linear-gradient(135deg, var(--rose), #ff6b8a); color: #fff; box-shadow: 0 4px 14px rgba(255,77,109,0.25); }
.btn-teal { background: linear-gradient(135deg, var(--teal), #34e8c0); color: #000; box-shadow: 0 4px 14px rgba(6,214,160,0.25); }
.btn-ghost { background: var(--s2); color: var(--txt); border: 1px solid var(--border); }

/* ===== PROGRESS BAR ===== */
.prog-wrap { background: var(--s3); border-radius: 100px; height: 8px; overflow: hidden; }
.prog-fill {
  height: 100%; border-radius: 100px;
  transition: width 0.6s cubic-bezier(.34,1.56,.64,1);
}

/* ===== TASKS PAGE ===== */
.add-task-form { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; margin-bottom: 10px; }
.add-task-form2 { display: flex; gap: 10px; margin-bottom: 20px; }

.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, opacity 0.3s, box-shadow 0.3s;
  animation: slideIn 0.3s cubic-bezier(.34,1.56,.64,1);
  user-select: none;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.task-row:hover { border-color: rgba(240,180,41,0.35); transform: translateX(-3px); box-shadow: 0 3px 12px rgba(0,0,0,0.1); }
.task-row.done { opacity: 0.45; }
.task-row.done .task-name { text-decoration: line-through; color: var(--dim); }
.task-row.dragging { opacity: 0.5; border-color: var(--gold); box-shadow: 0 6px 24px rgba(240,180,41,0.3); }

.task-drag {
  cursor: grab; color: var(--dim); font-size: 1rem; padding: 2px;
  transition: color 0.2s;
  flex-shrink: 0;
}
.task-drag:hover { color: var(--gold); }
.task-drag:active { cursor: grabbing; }

.task-check {
  width: 24px; height: 24px; border-radius: 8px;
  border: 2px solid var(--border); background: none;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; transition: all 0.3s cubic-bezier(.34,1.56,.64,1);
}
.task-row.done .task-check { background: var(--teal); border-color: var(--teal); transform: scale(1.1); }

.task-time { font-size: 0.72rem; color: var(--dim); background: var(--s2); border-radius: 7px; padding: 3px 8px; flex-shrink: 0; }
.task-cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-name { flex: 1; font-weight: 600; font-size: 0.93rem; }
.task-prio {
  font-size: 0.62rem; font-weight: 700; border-radius: 6px; padding: 3px 8px; flex-shrink: 0;
}
.p-high { background: rgba(255,77,109,0.18); color: var(--rose); }
.p-med  { background: rgba(240,180,41,0.18); color: var(--gold); }
.p-low  { background: rgba(6,214,160,0.18);  color: var(--teal); }
.del-btn {
  background: none; border: none; color: var(--dim); font-size: 1rem;
  cursor: pointer; padding: 2px 7px; border-radius: 7px; transition: color 0.2s, background 0.2s;
}
.del-btn:hover { color: var(--rose); background: rgba(255,77,109,0.1); }

/* ===== POINTS TOAST ===== */
.points-toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #000; font-weight: 900; font-size: 1rem;
  border-radius: 100px; padding: 10px 24px;
  z-index: 9999; pointer-events: none;
  transition: transform 0.5s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 6px 24px rgba(240,180,41,0.4);
}
.points-toast.show { transform: translateX(-50%) translateY(0); }

/* ===== FOCUS LOCK MODE ===== */
.focus-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8,8,16,0.97);
  z-index: 1000;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 24px;
  animation: fadeUp 0.4s ease;
}
.focus-overlay.open { display: flex; }
.focus-task-name {
  font-size: 1.6rem; font-weight: 900; color: var(--gold);
  max-width: 400px; text-align: center; line-height: 1.3;
}
.focus-sub { color: var(--dim); font-size: 0.85rem; }
.focus-ring {
  width: 190px; height: 190px; border-radius: 50%;
  border: 3px solid var(--s3);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.focus-ring svg { position: absolute; top: -3px; right: -3px; width: 196px; height: 196px; transform: rotate(-90deg); }
.focus-ring circle { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 565; stroke-dashoffset: 565; transition: stroke-dashoffset 1s linear; }
.focus-time { font-size: 3.2rem; font-weight: 900; letter-spacing: -3px; }
.focus-phone-tip {
  background: var(--s2); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 22px; text-align: center; max-width: 340px;
}
.focus-phone-tip .icon { font-size: 1.6rem; margin-bottom: 6px; }
.focus-phone-tip p { font-size: 0.8rem; color: var(--dim); line-height: 1.6; }
.focus-phone-tip strong { color: var(--rose); }

/* ===== SCHEDULE PAGE ===== */
.schedule-grid {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 0;
  position: relative;
}
.hour-label {
  font-size: 0.72rem; color: var(--dim); text-align: left;
  padding: 0 8px 0 0; line-height: 48px; height: 48px;
  border-top: 1px solid var(--border);
}
.hour-slot {
  height: 48px; border-top: 1px solid var(--border);
  position: relative;
}
.sched-block {
  position: absolute; right: 4px; left: 4px;
  border-radius: 8px; padding: 3px 8px;
  font-size: 0.72rem; font-weight: 700;
  overflow: hidden;
  cursor: pointer;
  z-index: 2;
  transition: filter 0.2s, transform 0.2s;
}
.sched-block:hover { filter: brightness(1.15); transform: scale(1.02); }
.now-line {
  position: absolute; right: 0; left: 0;
  height: 2px; background: var(--rose);
  z-index: 3;
}
.now-line::before {
  content: '';
  position: absolute; right: -4px; top: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--rose);
}

/* ===== SLEEP PAGE ===== */
.sleep-arc-wrap { display: flex; flex-direction: column; align-items: center; padding: 20px 0; }
.sleep-arc-svg { width: 220px; height: 130px; }
.sleep-score { font-size: 3.5rem; font-weight: 900; text-align: center; line-height: 1; }
.sleep-score .sub { font-size: 0.8rem; color: var(--dim); font-weight: 400; }
.sleep-tips { display: flex; flex-direction: column; gap: 8px; }
.sleep-tip {
  background: var(--s2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; font-size: 0.85rem;
  transition: transform 0.2s, border-color 0.2s;
}
.sleep-tip:hover { border-color: rgba(72,149,239,0.3); transform: translateX(-3px); }
.sleep-tip .icon { font-size: 1.2rem; flex-shrink: 0; }
.alarm-list { display: flex; flex-direction: column; gap: 8px; }
.alarm-row {
  background: var(--s1); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  transition: border-color 0.2s;
}
.alarm-row:hover { border-color: rgba(240,180,41,0.3); }
.alarm-time-big { font-size: 1.8rem; font-weight: 900; color: var(--gold); letter-spacing: -1px; }
.alarm-lbl { font-size: 0.75rem; color: var(--dim); }
.toggle-switch {
  width: 44px; height: 24px; border-radius: 100px; background: var(--s3);
  border: 1px solid var(--border); cursor: pointer; position: relative;
  transition: background 0.2s;
}
.toggle-switch.on { background: var(--teal); border-color: var(--teal); }
.toggle-switch::after {
  content: ''; position: absolute;
  top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform 0.25s;
}
.toggle-switch.on::after { transform: translateX(-20px); }

/* ===== REPORT PAGE ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 8px 0; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar-fill {
  width: 100%; border-radius: 6px 6px 0 0;
  min-height: 4px; transition: height 0.8s cubic-bezier(.34,1.56,.64,1);
  position: relative;
}
.bar-day { font-size: 0.65rem; color: var(--dim); }
.bar-val { font-size: 0.65rem; color: var(--dim); }

.ring-chart { width: 110px; height: 110px; margin: 0 auto 12px; }
.ring-chart circle { fill: none; stroke-width: 10; stroke-linecap: round; }

.insight-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--s2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  transition: border-color 0.2s, transform 0.2s;
}
.insight-row:hover { border-color: rgba(240,180,41,0.3); transform: translateX(-3px); }
.insight-row .icon { font-size: 1.3rem; flex-shrink: 0; }
.insight-row .txt { flex: 1; }
.insight-row .txt strong { display: block; font-size: 0.88rem; }
.insight-row .txt span { font-size: 0.75rem; color: var(--dim); }

/* ===== NOTIFICATION ===== */
.notif {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #000;
  font-weight: 700; border-radius: 14px; padding: 12px 24px;
  font-size: 0.88rem; z-index: 9999; pointer-events: none;
  transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 6px 20px rgba(240,180,41,0.35);
}
.notif.show { transform: translateX(-50%) translateY(0); }

/* ===== ANNOUNCEMENT BANNER ===== */
.announce-banner {
  background: linear-gradient(135deg, rgba(240,180,41,0.1), rgba(255,209,102,0.06));
  border: 1px solid rgba(240,180,41,0.2);
  border-radius: 14px;
  padding: 12px 18px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
  animation: fadeUp 0.5s ease;
}
.announce-banner .icon { font-size: 1.3rem; }
.announce-banner .txt { flex: 1; }
.announce-banner .txt strong { display: block; font-size: 0.88rem; color: var(--gold); }
.announce-banner .txt span { font-size: 0.78rem; color: var(--dim); }

/* ===== PWA INSTALL BANNER ===== */
.install-banner {
  background: linear-gradient(135deg, var(--s1), var(--s2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
  animation: fadeUp 0.5s ease;
}
.install-banner .icon { font-size: 1.5rem; }
.install-banner .txt { flex: 1; }
.install-banner .txt strong { display: block; font-size: 0.88rem; }
.install-banner .txt span { font-size: 0.75rem; color: var(--dim); }
.install-banner .btn { font-size: 0.8rem; padding: 8px 16px; }

/* ===== EMPTY STATE ===== */
.empty { text-align: center; padding: 48px 24px; color: var(--dim); }
.empty .icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.35; }
.empty p { font-size: 0.85rem; }

/* ===== LOADING SPINNER ===== */
.loading { text-align: center; padding: 40px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--s3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MOBILE ===== */
@media(max-width: 640px) {
  .sidebar {
    bottom: 0; top: auto; right: 0; left: 0;
    width: auto; height: 64px;
    flex-direction: row;
    border-top: 1px solid var(--border);
    border-left: none;
    padding: 0;
    justify-content: space-around;
  }
  .main { margin-right: 0; padding-bottom: 76px; }
  .nav-logo { display: none; }
  .theme-toggle { margin-top: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .add-task-form { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 32px 24px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}
