/* ===== DESIGN TOKENS ===== */
:root {
  /* Primary */
  --primary: #008A64;
  --primary-light: #F0FBF7;
  --primary-border: #B8E6D5;

  /* Backgrounds */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F7F8F8;
  --bg-tertiary: #F1F3F3;
  --bg-input: #F4F5F5;

  /* Text */
  --text-primary: #151818;
  --text-secondary: #626A69;
  --text-tertiary: #909796;

  /* Borders */
  --border-default: #E5E8E7;
  --border-light: #EEF0EF;

  /* Semantic */
  --success: #0B956D;
  --success-light: #E8F7F1;
  --warning: #F1A321;
  --warning-light: #FEF5E7;
  --error: #D94B4B;
  --error-light: #FDECEC;

  /* WhatsApp */
  --whatsapp: #25D366;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(16, 32, 28, 0.03);
  --shadow-md: 0 2px 8px rgba(16, 32, 28, 0.04);
  --shadow-lg: 0 4px 16px rgba(16, 32, 28, 0.06);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

/* ===== RESET ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== BASE ===== */
body {
  font-family: 'Estedad', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  font-size: 15px;
}

/* Material Symbols — hide text until font loads */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 22px;
  line-height: 1;
  vertical-align: middle;
  overflow: hidden;
  width: 1em;
  height: 1em;
  display: inline-block;
  color: transparent;
}

html.fonts-loaded .material-symbols-rounded {
  color: inherit;
  width: auto;
  height: auto;
  overflow: visible;
}

/* Hidden utility */
[hidden] { display: none !important; }

/* ===== VIEW SCREENS (mutually exclusive) ===== */
.view {
  min-height: 100vh;
  width: 100%;
}

/* ===== TYPOGRAPHY ===== */
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.body-text {
  font-size: 15px;
  color: var(--text-primary);
}

.secondary-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.tertiary-text {
  font-size: 12px;
  color: var(--text-tertiary);
}

.large-value {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

.small-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ===== LOGIN ===== */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--bg-secondary);
}

#login-view[hidden] {
  display: none;
}

#app-view {
  background: var(--bg-secondary);
}

#app-view[hidden] {
  display: none;
}

.login-card {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-6);
  width: 100%;
  max-width: 360px;
  text-align: center;
  border: 1px solid var(--border-light);
}

.login-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-5);
}

.login-icon .material-symbols-rounded {
  font-size: 32px;
  color: var(--primary);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 32;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.login-subtitle {
  color: var(--text-tertiary);
  font-size: 14px;
  margin-bottom: var(--space-6);
}

.input-group {
  position: relative;
  margin-bottom: var(--space-4);
}

.input-group .input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: var(--space-3);
  color: var(--text-tertiary);
  font-size: 20px;
  pointer-events: none;
}

.input-group input {
  padding-inline-start: 44px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 200ms ease;
  text-decoration: none;
  gap: var(--space-2);
  white-space: nowrap;
  height: 48px;
  line-height: 1;
}

.btn:active { transform: scale(0.97); opacity: 0.9; }

.btn .material-symbols-rounded { font-size: 20px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:active { background: #007A58; }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

.btn-danger {
  background: var(--error-light);
  color: var(--error);
}

.btn-whatsapp {
  background: var(--whatsapp);
  color: #fff;
  border-radius: var(--radius-full);
}
.btn-whatsapp:active { background: #20BD5A; }

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
  height: 36px;
  border-radius: var(--radius-sm);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Icon button (header) */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 150ms ease;
  color: var(--text-secondary);
  font-family: inherit;
}

.icon-btn:active { transform: scale(0.93); background: var(--bg-tertiary); }

.icon-btn .material-symbols-rounded { font-size: 20px; }

.lang-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ===== FORMS ===== */
.form-field {
  margin-bottom: var(--space-4);
}

.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="number"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text-primary);
  height: 48px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 138, 100, 0.1);
  background: var(--bg-primary);
}

input::placeholder {
  color: var(--text-tertiary);
}

.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: var(--space-2);
  text-align: center;
}

.success-text {
  color: var(--success);
  font-size: 13px;
  margin-top: var(--space-3);
  text-align: center;
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.form-actions .btn { flex: 1; }

/* ===== HEADER ===== */
.app-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + var(--safe-top));
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-actions {
  display: flex;
  gap: var(--space-2);
}

/* ===== MONTH NAVIGATION ===== */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) var(--space-4) 0;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  max-width: 280px;
  margin-inline: auto;
}

.month-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 150ms ease;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.month-nav-btn:active { background: var(--border-default); }

.month-nav-btn .material-symbols-rounded { font-size: 20px; }

.month-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 120px;
  text-align: center;
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  height: calc(56px + var(--safe-bottom));
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  padding: var(--space-2) 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 150ms ease;
  color: var(--text-tertiary);
  height: 56px;
  font-family: inherit;
}

.nav-item .nav-icon {
  font-size: 24px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  transition: font-variation-settings 200ms ease;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active .nav-icon {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* ===== TAB CONTENT ===== */
.tab-content {
  padding: var(--space-4);
  padding-bottom: calc(72px + var(--safe-bottom));
  max-width: 600px;
  margin: 0 auto;
}

/* ===== CHECKLIST ===== */
.checklist-item {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: box-shadow 200ms ease;
}

.checklist-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.checklist-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checklist-icon .material-symbols-rounded {
  font-size: 20px;
  color: var(--primary);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.checklist-info {
  flex: 1;
  min-width: 0;
}

.checklist-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.3;
}

.checklist-name-bn {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.checklist-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.badge-done { background: var(--success-light); color: var(--success); }
.badge-partial { background: var(--warning-light); color: var(--warning); }
.badge-none { background: var(--bg-tertiary); color: var(--text-tertiary); }

/* Progress bar */
.progress-track {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 300ms ease;
}

.progress-fill.done { background: var(--success); }
.progress-fill.partial { background: var(--warning); }

/* Occurrence buttons */
.occurrence-buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.occ-btn {
  min-width: 40px;
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-default);
  background: var(--bg-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.occ-btn.completed {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.occ-btn:active { transform: scale(0.92); }

/* WhatsApp button in checklist */
.whatsapp-btn {
  margin-top: var(--space-3);
  display: none;
  background: var(--whatsapp);
  color: #fff;
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  height: 40px;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all 200ms ease;
}

.whatsapp-btn:active { transform: scale(0.97); opacity: 0.9; }

.whatsapp-btn.show { display: flex; }

.whatsapp-btn .material-symbols-rounded { font-size: 18px; }

/* ===== TASK MANAGEMENT ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.tasks-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  overflow: hidden;
}

.task-item {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-light);
  transition: background 150ms ease;
}

.task-item:last-child { border-bottom: none; }

.task-item:active { background: var(--bg-secondary); }

.task-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-icon .material-symbols-rounded {
  font-size: 18px;
  color: var(--primary);
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-info h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.task-info p {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.task-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.task-actions .btn {
  padding: var(--space-1) var(--space-2);
  font-size: 12px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.task-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.task-chevron .material-symbols-rounded { font-size: 20px; }

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-tertiary);
  padding: var(--space-10) var(--space-4);
}

.empty-state .material-symbols-rounded {
  font-size: 48px;
  margin-bottom: var(--space-3);
  color: var(--border-default);
}

.empty-state p {
  font-size: 14px;
}

/* ===== OVERLAY / BOTTOM SHEET ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 24, 24, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.bottom-sheet {
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-2) var(--space-5) var(--space-6);
  padding-bottom: calc(var(--space-6) + var(--safe-bottom));
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 250ms ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-default);
  border-radius: 2px;
  margin: var(--space-2) auto var(--space-4);
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ===== SUMMARY ===== */
.summary-hero {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  margin-bottom: var(--space-4);
}

.summary-percent {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.summary-label {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: var(--space-2);
}

.summary-tasks-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.summary-task-row {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

.summary-task-row:last-child { border-bottom: none; }

.summary-status-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-inline-end: var(--space-3);
  flex-shrink: 0;
}

.summary-status-icon.status-done {
  background: var(--success-light);
  color: var(--success);
}

.summary-status-icon.status-partial {
  background: var(--warning-light);
  color: var(--warning);
}

.summary-status-icon.status-none {
  background: var(--error-light);
  color: var(--error);
}

.summary-status-icon .material-symbols-rounded {
  font-size: 16px;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 16;
}

.summary-task-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  min-width: 0;
}

.summary-task-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ===== SETTINGS ===== */
.settings-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  padding: var(--space-5);
}

#settings-tab .section-title {
  margin-bottom: var(--space-4);
}

/* ===== WHATSAPP PREVIEW ===== */
.whatsapp-preview-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

#whatsapp-message-preview {
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  font-family: inherit;
  color: var(--text-primary);
  margin: 0;
}

/* ===== RTL SUPPORT ===== */
html[dir="ltr"] .month-nav-btn:first-of-type .material-symbols-rounded {
  /* flip arrow in LTR */
}

/* Logical property overrides for RTL/LTR */
html[dir="ltr"] .checklist-name { text-align: left; }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .tab-content {
    padding: var(--space-6);
    padding-bottom: calc(80px + var(--safe-bottom));
  }

  .login-card {
    padding: var(--space-10) var(--space-8);
  }

  .bottom-sheet {
    max-width: 480px;
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-5);
  }

  .overlay {
    align-items: center;
  }
}

/* ===== ANIMATIONS ===== */
@media (prefers-reduced-motion: no-preference) {
  .checklist-item {
    animation: fadeIn 200ms ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
