/* ============================================
   PetEarn - Main Stylesheet
   ============================================ */

:root {
  --primary: #6C5CE7;
  --primary-dark: #5A4BD1;
  --primary-light: #A29BFE;
  --secondary: #00CEC9;
  --accent: #FD79A8;
  --success: #00B894;
  --warning: #FDCB6E;
  --danger: #E17055;
  --dark: #2D3436;
  --gray: #636E72;
  --light-gray: #B2BEC3;
  --bg: #F8F9FA;
  --white: #FFFFFF;
  --card-shadow: 0 2px 12px rgba(108,92,231,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  padding-bottom: 80px; /* bottom nav */
  line-height: 1.5;
}

/* ---- TYPOGRAPHY ---- */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { color: var(--gray); font-size: 0.95rem; }

/* ---- LAYOUT ---- */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.page-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 20px 16px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-header h1 { font-size: 1.3rem; color: white; }
.page-header p { color: rgba(255,255,255,0.8); font-size: 0.85rem; }
.content { padding: 16px; margin-top: -16px; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid rgba(108,92,231,0.06);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--dark); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--dark); border: 1.5px solid #E0E0E0; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; border-radius: 8px; }
.btn-lg { padding: 16px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--gray); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-control {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid #E8E8E8;
  border-radius: 12px;
  font-size: 0.95rem;
  background: var(--white);
  color: var(--dark);
  transition: var(--transition);
  -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,0.12); }
.form-control::placeholder { color: var(--light-gray); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636E72' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ---- ALERTS ---- */
.alert { padding: 14px 16px; border-radius: 12px; font-size: 0.9rem; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #E8F5E9; color: #2E7D32; border-left: 4px solid var(--success); }
.alert-danger { background: #FBE9E7; color: #C62828; border-left: 4px solid var(--danger); }
.alert-warning { background: #FFF8E1; color: #E65100; border-left: 4px solid var(--warning); }
.alert-info { background: #E8EAF6; color: #283593; border-left: 4px solid var(--primary); }

/* ---- BOTTOM NAVIGATION ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid #F0F0F0;
  display: flex;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  text-decoration: none;
  color: var(--light-gray);
  font-size: 0.65rem;
  font-weight: 600;
  transition: var(--transition);
  gap: 3px;
  position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 1.3rem; }
.nav-item .nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 14px);
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 20px;
  min-width: 16px;
  text-align: center;
}

/* ---- TOP BAR ---- */
.top-bar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-bar-logo { font-size: 1.3rem; font-weight: 800; color: white; letter-spacing: -0.5px; }
.top-bar-logo span { color: var(--primary-light); }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.balance-chip {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
}
.notif-btn { position: relative; background: none; border: none; cursor: pointer; color: white; font-size: 1.2rem; padding: 4px; }
.notif-dot { position: absolute; top: 0; right: 0; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; border: 2px solid var(--primary-dark); }

/* ---- PET DISPLAY ---- */
.pet-card {
  background: linear-gradient(135deg, #EEF2FF, #F5F3FF);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid rgba(108,92,231,0.1);
}
.pet-emoji { font-size: 5rem; display: block; margin-bottom: 8px; animation: petFloat 3s ease-in-out infinite; }
@keyframes petFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.pet-name { font-size: 1.3rem; font-weight: 700; color: var(--dark); }
.pet-earn { font-size: 0.9rem; color: var(--primary); font-weight: 600; margin-top: 4px; }

/* ---- HAPPINESS BAR ---- */
.happiness-bar { margin-top: 16px; }
.happiness-label { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; color: var(--gray); margin-bottom: 6px; }
.progress { height: 10px; background: #E8E8E8; border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width 0.5s ease; }
.progress-bar.high { background: linear-gradient(90deg, var(--success), #81C784); }
.progress-bar.mid { background: linear-gradient(90deg, var(--warning), #FFD54F); }
.progress-bar.low { background: linear-gradient(90deg, var(--danger), #FF7043); }

/* ---- FEEDING WINDOWS ---- */
.windows-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.window-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  border: 2px solid #F0F0F0;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}
.window-card.active { border-color: var(--primary); background: #F5F3FF; }
.window-card.done { border-color: var(--success); background: #E8F5E9; }
.window-card.missed { border-color: var(--danger); background: #FBE9E7; opacity: 0.7; }
.window-card.locked { border-color: #E8E8E8; opacity: 0.5; cursor: default; }
.window-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.window-name { font-size: 0.8rem; font-weight: 700; color: var(--dark); }
.window-time { font-size: 0.7rem; color: var(--gray); }
.window-status { font-size: 0.7rem; font-weight: 700; margin-top: 4px; }
.window-status.done { color: var(--success); }
.window-status.active { color: var(--primary); }
.window-status.missed { color: var(--danger); }

/* ---- STATS GRID ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid rgba(108,92,231,0.06);
  box-shadow: var(--card-shadow);
}
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--dark); margin-top: 4px; }
.stat-sub { font-size: 0.75rem; color: var(--light-gray); margin-top: 2px; }
.stat-icon { font-size: 1.5rem; margin-bottom: 8px; }

/* ---- SHOP / PET LIST ---- */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shop-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  border: 2px solid #F0F0F0;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.shop-item.owned { border-color: var(--success); }
.shop-item.featured { border-color: var(--primary); }
.shop-item-emoji { font-size: 3rem; display: block; margin-bottom: 10px; }
.shop-item-name { font-size: 1rem; font-weight: 700; color: var(--dark); }
.shop-item-earn { font-size: 0.8rem; color: var(--success); font-weight: 600; margin: 4px 0; }
.shop-item-price { font-size: 1rem; font-weight: 800; color: var(--primary); margin-top: 8px; }
.shop-badge { position: absolute; top: 10px; right: 10px; font-size: 0.65rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge-free { background: #E8F5E9; color: #2E7D32; }
.badge-owned { background: #E8F5E9; color: #2E7D32; }

/* ---- TASKS ---- */
.task-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px solid #F0F0F0;
  transition: var(--transition);
}
.task-item.completed { opacity: 0.6; background: #F9F9F9; }
.task-icon-wrap { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.task-icon-youtube { background: #FBE9E7; }
.task-icon-instagram { background: #FCE4EC; }
.task-icon-tiktok { background: #F3E5F5; }
.task-icon-facebook { background: #E8EAF6; }
.task-icon-twitter { background: #E3F2FD; }
.task-icon-website { background: #E8F5E9; }
.task-icon-other { background: #FFF8E1; }
.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 0.9rem; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-reward { font-size: 0.85rem; color: var(--success); font-weight: 700; margin-top: 2px; }
.task-action { flex-shrink: 0; }

/* ---- TRANSACTION LIST ---- */
.tx-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #F5F5F5; }
.tx-item:last-child { border-bottom: none; }
.tx-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.tx-icon.credit { background: #E8F5E9; }
.tx-icon.debit { background: #FBE9E7; }
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: 0.85rem; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 0.75rem; color: var(--light-gray); margin-top: 2px; }
.tx-amount { font-size: 1rem; font-weight: 700; flex-shrink: 0; }
.tx-amount.credit { color: var(--success); }
.tx-amount.debit { color: var(--danger); }

/* ---- PAYMENT TABS ---- */
.pay-tabs { display: flex; background: #F0F0F0; border-radius: 12px; padding: 4px; margin-bottom: 20px; }
.pay-tab { flex: 1; padding: 10px; text-align: center; border-radius: 10px; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: var(--transition); color: var(--gray); border: none; background: none; }
.pay-tab.active { background: var(--white); color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* ---- REFERRAL ---- */
.referral-code-box {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: white;
  margin-bottom: 16px;
}
.referral-code { font-size: 2rem; font-weight: 900; letter-spacing: 4px; margin: 12px 0; }
.referral-code-box p { color: rgba(255,255,255,0.8); }

/* ---- STREAK ---- */
.streak-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: white;
  margin-bottom: 16px;
}
.streak-icon { font-size: 2.5rem; }
.streak-count { font-size: 2rem; font-weight: 900; }
.streak-label { font-size: 0.85rem; opacity: 0.9; }

/* ---- AD MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 2000;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 36px;
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-size: 1.2rem; font-weight: 700; text-align: center; margin-bottom: 8px; }
.modal-sub { text-align: center; margin-bottom: 20px; }
.ad-placeholder {
  background: linear-gradient(135deg, #F0F0F0, #E8E8E8);
  border-radius: var(--radius);
  height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--gray);
  gap: 8px;
}
.ad-timer { font-size: 2rem; font-weight: 900; color: var(--primary); }
.ad-countdown { font-size: 0.8rem; color: var(--gray); }

/* ---- NOTIFICATION ITEM ---- */
.notif-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid #F5F5F5; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #F8F6FF; margin: 0 -20px; padding: 14px 20px; }
.notif-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.notif-icon.success { background: #E8F5E9; }
.notif-icon.info { background: #E8EAF6; }
.notif-icon.warning { background: #FFF8E1; }
.notif-icon.danger { background: #FBE9E7; }
.notif-title { font-size: 0.9rem; font-weight: 600; color: var(--dark); }
.notif-msg { font-size: 0.8rem; color: var(--gray); margin-top: 2px; }
.notif-time { font-size: 0.72rem; color: var(--light-gray); margin-top: 4px; }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 4rem; display: block; margin-bottom: 16px; }
.empty-title { font-size: 1.1rem; font-weight: 700; color: var(--dark); margin-bottom: 8px; }
.empty-text { font-size: 0.9rem; color: var(--gray); margin-bottom: 20px; }

/* ---- UTILITIES ---- */
.text-center { text-align: center; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-gray { color: var(--gray) !important; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.fw-700 { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.pill-primary { background: #EEF2FF; color: var(--primary); }
.pill-success { background: #E8F5E9; color: #2E7D32; }
.pill-danger { background: #FBE9E7; color: #C62828; }
.pill-warning { background: #FFF8E1; color: #E65100; }
.divider { border: none; border-top: 1px solid #F0F0F0; margin: 16px 0; }

/* ---- AUTH PAGES ---- */
.auth-wrap { min-height: 100vh; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: flex; flex-direction: column; padding-bottom: 0; }
.auth-top { padding: 60px 24px 40px; text-align: center; color: white; }
.auth-logo { font-size: 3rem; margin-bottom: 12px; }
.auth-title { font-size: 1.8rem; font-weight: 900; color: white; margin-bottom: 8px; }
.auth-sub { color: rgba(255,255,255,0.8); font-size: 0.95rem; }
.auth-card { background: var(--white); border-radius: 28px 28px 0 0; padding: 28px 24px 48px; flex: 1; margin-top: auto; }
.auth-link { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--gray); }
.auth-link a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ---- SPINNER ---- */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOAST ---- */
#toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; min-width: 280px; max-width: 340px; pointer-events: none; }
.toast { background: var(--dark); color: white; padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; font-weight: 500; box-shadow: 0 4px 20px rgba(0,0,0,0.2); animation: toastIn 0.3s ease; pointer-events: all; display: flex; align-items: center; gap: 8px; }
.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }
.toast.warning { background: #E65100; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- LANDING PAGE ---- */
.hero { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 0; }
.hero-nav { display: flex; justify-content: space-between; align-items: center; padding: 20px 20px; }
.hero-nav-logo { font-size: 1.4rem; font-weight: 900; color: white; }
.hero-nav-links { display: flex; gap: 8px; }
.hero-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px; color: white; }
.hero-pets { font-size: 4rem; margin-bottom: 24px; letter-spacing: 8px; }
.hero-title { font-size: 2.2rem; font-weight: 900; line-height: 1.2; margin-bottom: 16px; }
.hero-sub { font-size: 1rem; opacity: 0.85; margin-bottom: 32px; max-width: 320px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hero-bottom { background: var(--white); border-radius: 28px 28px 0 0; padding: 32px 24px; }
.how-it-works { display: flex; flex-direction: column; gap: 20px; }
.how-item { display: flex; align-items: flex-start; gap: 16px; }
.how-num { width: 36px; height: 36px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; flex-shrink: 0; }
.how-text h3 { font-size: 0.95rem; font-weight: 700; color: var(--dark); }
.how-text p { font-size: 0.85rem; color: var(--gray); margin-top: 2px; }
