/* ============================================================
   app.css — Rotina App — Design System
   ============================================================ */

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

:root {
  --green:       #1D9E75;
  --green-light: #EAF7F1;
  --green-dark:  #0F6E52;
  --red:         #E24B4A;
  --red-light:   #FCEBEB;
  --yellow:      #EF9F27;
  --yellow-light:#FEF3E0;
  --blue:        #2D7DD2;
  --blue-light:  #E6F1FB;
  --purple:      #6C5CE7;
  --purple-light:#EEEDFE;

  --bg:          #F7F8FA;
  --surface:     #FFFFFF;
  --border:      #E8EAED;
  --border-dark: #D1D5DB;

  --text:        #111827;
  --text-2:      #6B7280;
  --text-3:      #9CA3AF;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --header-h: 60px;
  --nav-h:    64px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── Layout ──────────────────────────────────────────────── */
#auth-screen  { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; padding: 1.5rem; background: linear-gradient(145deg, var(--green) 0%, var(--green-dark) 100%); }
#app-screen   { display: none; flex-direction: column; min-height: 100dvh; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-sm);
}
.app-header h1 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.app-header h1 span { color: var(--green); }

.app-content {
  flex: 1;
  padding: 1rem 1rem calc(var(--nav-h) + 1rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: transparent; border: none; font-size: 10px;
  color: var(--text-3); padding: 8px 0; transition: color .15s;
}
.nav-item i { font-size: 22px; }
.nav-item.active { color: var(--green); }
.nav-item .badge {
  position: absolute; top: 8px;
  background: var(--red); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px;
  border-radius: 99px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Auth Card ───────────────────────────────────────────── */
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo i { font-size: 48px; color: var(--green); }
.auth-logo h2 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.auth-logo p  { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 1.25rem; background: var(--bg); border-radius: var(--radius-md); padding: 4px; }
.auth-tab { flex: 1; padding: 8px; border: none; background: transparent; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-2); transition: all .15s; }
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── Form Elements ───────────────────────────────────────── */
.field { margin-bottom: .875rem; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px; color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--green); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field { margin-bottom: 0; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  border: 1.5px solid transparent; transition: all .15s;
}
.btn-primary   { background: var(--green);   color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger    { background: var(--red);  color: #fff; }
.btn-google    { background: #fff; border-color: var(--border); color: var(--text); box-shadow: var(--shadow-sm); width: 100%; margin-top: .5rem; }
.btn-full      { width: 100%; }
.btn-sm        { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon      { padding: 8px; border-radius: var(--radius-md); background: transparent; border: none; color: var(--text-2); font-size: 20px; display: flex; align-items: center; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

.divider { display: flex; align-items: center; gap: 10px; margin: 1rem 0; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content:''; flex:1; height:1px; background: var(--border); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

/* ── Task Card ───────────────────────────────────────────── */
.task-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform .1s, box-shadow .1s;
  animation: fadeIn .2s ease;
}
.task-card:active { transform: scale(.99); }
.task-card.done   { opacity: .5; }
.task-card.overdue { border-left: 3px solid var(--red); border-radius: 0 var(--radius-lg) var(--radius-lg) 0; background: #FFFBFB; }

.task-check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border-dark);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all .15s;
  color: transparent;
}
.task-check.checked { background: var(--green); border-color: var(--green); color: #fff; }
.task-check i { font-size: 13px; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-card.done .task-title { text-decoration: line-through; }
.task-meta  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.task-time  { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 3px; }
.task-time i { font-size: 12px; }

.tag { display: inline-flex; align-items: center; font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 500; }
.tag-work     { background: var(--blue-light);   color: #0C447C; }
.tag-health   { background: var(--green-light);  color: var(--green-dark); }
.tag-personal { background: var(--purple-light); color: #3C3489; }
.tag-study    { background: var(--yellow-light); color: #633806; }

.task-actions { display: flex; align-items: center; gap: 2px; }

/* ── Day navigation ──────────────────────────────────────── */
.day-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 1rem; }
.day-nav .lbl { flex: 1; text-align: center; font-size: 15px; font-weight: 600; }
.day-nav button { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 7px 12px; font-size: 14px; color: var(--text); }

/* ── Week strip ──────────────────────────────────────────── */
.week-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 1rem; scrollbar-width: none; }
.week-strip::-webkit-scrollbar { display: none; }
.wday { flex-shrink: 0; width: 44px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border-radius: var(--radius-md); border: 1.5px solid transparent; cursor: pointer; transition: all .15s; }
.wday.today  { border-color: var(--green); }
.wday.sel    { background: var(--green); color: #fff; }
.wday .dn    { font-size: 10px; color: var(--text-2); }
.wday.sel .dn { color: rgba(255,255,255,.75); }
.wday .dd    { font-size: 16px; font-weight: 600; }
.wday-dots   { display: flex; gap: 3px; height: 5px; }
.dot { width: 5px; height: 5px; border-radius: 50%; }
.dot-g { background: var(--green); }
.dot-y { background: var(--yellow); }
.dot-r { background: var(--red); }

/* ── Stats ───────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 1rem; }
.stat-box  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 8px; text-align: center; }
.stat-box .num { font-size: 26px; font-weight: 700; }
.stat-box .lbl { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.num-green { color: var(--green); }
.num-red   { color: var(--red); }
.num-yellow{ color: var(--yellow); }

/* ── Overdue list ────────────────────────────────────────── */
.overdue-card { background: var(--red-light); border: 1px solid #F09595; border-radius: var(--radius-md); padding: 12px; display: flex; align-items: center; gap: 10px; }
.overdue-info { flex: 1; }
.overdue-title { font-size: 13px; font-weight: 600; color: #501313; }
.overdue-meta  { font-size: 11px; color: #791F1F; margin-top: 2px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); animation: bgIn .2s; }
.modal-bg.center { align-items: center; }
.modal-sheet { background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; width: 100%; max-width: 520px; padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; animation: slideUp .25s ease; }
.modal-bg.center .modal-sheet { border-radius: var(--radius-xl); max-height: 80dvh; }
.modal-handle { width: 36px; height: 4px; background: var(--border); border-radius: 99px; margin: 0 auto 1rem; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 1rem; }

/* ── Profile ─────────────────────────────────────────────── */
.avatar-wrap { position: relative; display: inline-block; }
.avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--green-light); display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--green); font-weight: 700; border: 3px solid var(--green-light); }
.avatar-btn { position: absolute; bottom: 0; right: 0; background: var(--green); border: 2px solid #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.avatar-btn i { font-size: 12px; color: #fff; }

/* ── Misc ────────────────────────────────────────────────── */
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin: 1rem 0 .5rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-3); }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; }
.empty p { font-size: 13px; }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.add-row   { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border: 1.5px dashed var(--border-dark); border-radius: var(--radius-lg); cursor: pointer; color: var(--text-2); font-size: 13px; transition: all .15s; margin-top: 8px; }
.add-row:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }
.add-row i { font-size: 18px; }

.toast { position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%); background: #1C2536; color: #fff; padding: 10px 18px; border-radius: var(--radius-lg); font-size: 13px; z-index: 200; white-space: nowrap; animation: toastIn .25s ease, toastOut .25s ease 2.5s forwards; pointer-events: none; box-shadow: var(--shadow-md); }
.install-bar { position: fixed; bottom: var(--nav-h); left: 0; right: 0; background: var(--green); color: #fff; padding: 12px 1rem; display: flex; align-items: center; gap: 10px; z-index: 30; font-size: 13px; }
.install-bar button { margin-left: auto; background: rgba(255,255,255,.25); border: none; color: #fff; padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: var(--red-light); color: var(--red); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.pill-yellow { background: var(--yellow-light); color: #7A4B00; }
.pill-green  { background: var(--green-light);  color: var(--green-dark); }

@keyframes fadeIn   { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform: none; } }
@keyframes slideUp  { from { transform: translateY(100%); } to { transform: none; } }
@keyframes bgIn     { from { opacity:0; } to { opacity:1; } }
@keyframes toastIn  { from { opacity:0; transform: translateX(-50%) translateY(10px); } to { opacity:1; transform: translateX(-50%); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 640px) {
  .app-content { max-width: 600px; margin: 0 auto; }
  .bottom-nav  { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-xl) var(--radius-xl) 0 0; border: 1px solid var(--border); }
  .modal-bg    { align-items: center; }
  .modal-sheet { border-radius: var(--radius-xl); }
}

/* ── Pull-to-refresh spinner ─────────────────────────────── */
.ptr { text-align: center; padding: 12px; color: var(--text-3); font-size: 13px; display: none; }
.ptr.visible { display: block; }
