/* =====================================================================
   MY-TRACKER 2.0 — DESIGN SYSTEM "MODERN ZEN"
   Mọi màu, font, góc bo nằm ở đây. Đổi 1 chỗ → cả app đổi theo.
   ===================================================================== */

/* ---------- 1. Design tokens (biến dùng chung) ---------- */
:root {
  /* Màu chủ đạo */
  --deep-sage: #2F4F4F;
  --sage: #47685D;
  --muted-green: #526F63;
  --soft-sage: #78917E;
  --dark-forest: #273E36;
  --gradient: linear-gradient(125deg, #2F4F4F, #526F63);

  /* Nền */
  --bg-page: #F4F2ED;
  --bg-card: #FFFEFA;
  --bg-soft: #F5F5F2;
  --bg-item: #F9F9F5;
  --bg-profile: #F5F6F1;
  --bg-icon: #EEF2EB;
  --border: #E4E3DC;

  /* Chữ */
  --text: #46534F;
  --text-muted: #6B756E;       /* đậm hơn #737D76 một chút để dễ đọc */
  --text-label: #40574D;
  --text-heading: #273E36;

  /* Trạng thái */
  --success: #47685D;  --success-bg: #EDF3EB;
  --warning: #7A5A2E;  --warning-bg: #F7EFE2;
  --error:   #A85B60;  --error-bg:   #FFF7F6;  --error-border: #F0DCDC;

  /* Font */
  --font-serif: 'Noto Serif', Georgia, serif;
  --font-sans: 'Be Vietnam Pro', system-ui, sans-serif;

  /* Bóng đổ & góc bo */
  --shadow-card: 0 10px 30px #68685D12;
  --shadow-btn: 0 10px 22px #2F4F4F28;
  --radius-frame: 30px 66px 28px 28px;   /* góc bất đối xứng — nét riêng của Modern Zen */
  --radius-hero: 25px 65px 25px 25px;
  --radius-card: 26px;
}

/* ---------- 2. Nền tảng ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
}
h1, h2, h3 { font-family: var(--font-serif); color: var(--text-heading); margin: 0; }
h1 { font-size: 27px; font-weight: 400; }
h2 { font-size: 21px; font-weight: 500; }
a { color: var(--sage); }
a:hover { color: var(--dark-forest); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ---------- 3. Bố cục ---------- */
.container { max-width: 1000px; margin: 30px auto; padding: 0 22px 60px; display: flex; flex-direction: column; gap: 20px; }

.top-frame {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-frame); padding: 27px 36px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 22px;
}
.top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 14px; background: var(--gradient);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-name { font-family: var(--font-serif); font-size: 30px; color: var(--text-heading); line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--text-muted); }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.profile-chip {
  display: flex; align-items: center; gap: 10px; background: var(--bg-profile);
  border: 1px solid #DFE5DC; border-radius: 20px; padding: 6px 14px 6px 6px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sage); color: #fff;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.profile-name { font-size: 14px; font-weight: 600; color: var(--text-heading); line-height: 1.3; }
.profile-role { font-size: 12px; color: var(--text-muted); line-height: 1.3; }

/* Thanh menu: các hàng cuộn ngang KHÔNG được co lại (bài học từ mockup) */
.main-nav { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.nav-link {
  min-height: 44px; display: inline-flex; align-items: center; padding: 10px 18px;
  border-radius: 25px; background: #EDF0E9; border: 1px solid #DCE3DA;
  color: var(--text-label); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}
.nav-link:hover { transform: translateY(-2px); color: var(--text-label); }
.nav-link.active { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: var(--shadow-btn); }

/* ---------- 4. Thẻ (card) & hero ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 30px 36px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 16px;
}
.card-head { display: flex; align-items: center; gap: 14px; }
.section-icon {
  width: 37px; height: 37px; border-radius: 13px; background: var(--bg-icon);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.hero {
  background: var(--gradient); border-radius: var(--radius-hero); padding: 32px 36px;
  box-shadow: 0 12px 26px #2F4F4F1F; color: #fff; display: flex; flex-direction: column; gap: 6px;
}
.hero h1 { color: #fff; }
.hero p { margin: 0; color: #EDF3ED; font-size: 14px; }
.placeholder {
  background: var(--bg-item); border: 1px dashed #CBD7CB; border-radius: 18px;
  padding: 18px 20px; color: var(--text-muted); font-size: 14px;
}

/* ---------- 5. Nút ---------- */
.btn {
  min-height: 46px; padding: 12px 20px; border-radius: 25px; border: 0;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .2s, box-shadow .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-btn); }
.btn-secondary { background: #EDF0E9; color: var(--text-label); border: 1px solid #DCE3DA; }
.btn-outline { background: var(--bg-card); color: var(--sage); border: 1px solid #CBD7CB; }
.btn-small { min-height: 44px; padding: 10px 16px; }
.btn-icon { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; position: relative; }
.badge {
  min-width: 20px; height: 20px; border-radius: 10px; background: var(--sage); color: #fff;
  font-size: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.btn-icon .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; font-size: 11px; }

/* ---------- 6. Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text-label); }
.field input, .field select, .field textarea {
  min-height: 48px; border-radius: 14px; border: 1px solid #DCDED7; background: var(--bg-card);
  color: var(--deep-sage); font-family: inherit; font-size: 15px; padding: 12px 13px; font-weight: 400;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #738E7D; box-shadow: 0 0 0 3px #526F6318;
}
.alert { display: flex; align-items: center; gap: 10px; border-radius: 14px; padding: 10px 14px; font-size: 13px; }
.alert-error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error); }
.alert-success { background: var(--success-bg); border: 1px solid #D5E3D2; color: var(--success); }

/* ---------- 7. Trang đăng nhập ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 22px; }
.login-wrap { width: 100%; max-width: 1000px; display: flex; flex-wrap: wrap; gap: 20px; }
.login-hero {
  flex: 1 1 380px; min-width: 0; background: var(--gradient); border-radius: var(--radius-hero);
  padding: 40px 36px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  box-shadow: 0 12px 26px #2F4F4F1F;
}
.login-hero h1 { color: #fff; font-size: 34px; line-height: 1.3; }
.login-hero p { color: #EDF3ED; max-width: 380px; }
.login-card {
  flex: 1 1 380px; min-width: 0; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-frame); padding: 40px 36px; box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; justify-content: center; gap: 22px;
}
.login-card form { display: flex; flex-direction: column; gap: 18px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 14px; border-radius: 20px; background: #FFFFFF1F; border: 1px solid #FFFFFF33; }

/* ---------- 8. Popup (dialog) ---------- */
dialog.popup {
  width: min(480px, calc(100vw - 24px)); border: 1px solid var(--border); padding: 28px 30px;
  background: var(--bg-card); border-radius: var(--radius-frame); box-shadow: 0 24px 60px #273E3633;
  color: var(--text); font-family: var(--font-sans);
}
dialog.popup::backdrop { background: #273E3659; }
.popup-body { display: flex; flex-direction: column; gap: 18px; }
.popup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.seg {
  min-height: 44px; padding: 8px 4px; border-radius: 22px; border: 1px solid #DCE3DA; background: var(--bg-card);
  color: var(--text-label); font-family: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.seg.active { border-color: var(--sage); background: var(--success-bg); color: var(--text-heading); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.timer-display {
  background: var(--bg-item); border: 1px solid var(--border); border-radius: 18px; padding: 18px; text-align: center;
  font-family: var(--font-serif); font-size: 55px; color: var(--text-heading); line-height: 1.1; letter-spacing: 2px;
}

/* ---------- 9. Thanh điều hướng điện thoại ---------- */
.bottom-nav { display: none; }

@media (max-width: 600px) {
  .container { margin: 12px auto; padding: 0 10px 96px; gap: 14px; }
  .top-frame { padding: 16px 18px; border-radius: 22px 44px 22px 22px; }
  .brand-name { font-size: 23px; }
  .brand-sub, .profile-chip .profile-text, .top-frame .main-nav, .btn-label, #logout-btn { display: none; }
  .top-row { flex-wrap: nowrap; }
  .top-actions { flex-wrap: nowrap; gap: 8px; }
  .top-actions .btn-small { width: 44px; padding: 0; border-radius: 50%; position: relative; }
  .top-actions .badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; font-size: 11px; }
  .profile-chip { padding: 0; border: 0; background: none; }
  .avatar { width: 44px; height: 44px; }
  .seg-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* màn hẹp: 2 nút mỗi hàng để chữ không bị cắt */
  /* Đồng hồ đang chạy: nút Focus nở ra để hiện số đếm ngược */
  .top-actions #open-focus.running { width: auto; padding: 0 12px; border-radius: 22px; }
  .top-actions #open-focus.running .btn-label { display: inline; }
  .top-actions #open-focus.running svg { display: none; }
  .brand { gap: 10px; min-width: 0; }
  .brand-logo { width: 36px; height: 36px; border-radius: 12px; }
  .brand-name { font-size: 21px; white-space: nowrap; }
  .card { padding: 22px 18px; }
  .hero { padding: 24px 20px; border-radius: 22px 48px 22px 22px; }
  .hero h1 { font-size: 21px; }
  h2 { font-size: 19px; }
  /* Trang đăng nhập trên điện thoại: khối giới thiệu gọn lại để form hiện ngay */
  .login-page { align-items: flex-start; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); }
  .login-wrap { gap: 14px; }
  .login-hero { padding: 20px 22px; gap: 14px; border-radius: 22px 48px 22px 22px; }
  .login-hero h1 { font-size: 19px; line-height: 1.4; }
  .login-hero p, .login-pills { display: none !important; }  /* !important: thắng style viết trực tiếp trong HTML */
  .login-card { padding: 28px 22px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg-card); border-top: 1px solid var(--border); padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
    z-index: 10;
  }
  .bottom-nav a {
    min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; font-size: 11px; font-weight: 500; color: var(--text-muted);
  }
  .bottom-nav a.active { color: var(--text-heading); font-weight: 600; }
}

/* Tôn trọng người dùng bật "giảm chuyển động" */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
