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

:root {
  --green-dark:  #1a3c2e;
  --green-mid:   #2d7a4f;
  --green-light: #4caf7d;
  --green-pale:  #e8f5ee;
  --accent:      #ff8c00;
  --text-dark:   #1a1a1a;
  --text-mid:    #555;
  --text-light:  #888;
  --bg:          #f4f7f5;
  --white:       #ffffff;
  --red:         #e53935;
  --blue:        #1565c0;
  --shadow:      0 2px 12px rgba(0,0,0,.12);
  --radius:      12px;
  --topbar-h:    56px;
  --nav-h:       62px;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text-dark); overflow: hidden; }

/* ===== SCREENS ===== */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; z-index: 1; }
.screen.active { display: flex; }

/* ===== AUTH ===== */
.auth-container { margin: auto; width: 100%; max-width: 380px; padding: 2rem 1.5rem; }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-icon { font-size: 3rem; }
.auth-logo h1 { font-size: 2rem; color: var(--green-dark); }
.auth-logo p  { color: var(--text-mid); font-size: .9rem; }
.auth-tabs { display: flex; border-bottom: 2px solid #ddd; margin-bottom: 1.5rem; }
.auth-tab { flex: 1; background: none; border: none; padding: .75rem; font-size: 1rem; cursor: pointer; color: var(--text-mid); transition: color .2s; }
.auth-tab.active { color: var(--green-mid); border-bottom: 2px solid var(--green-mid); margin-bottom: -2px; font-weight: 600; }
.auth-form { display: none; flex-direction: column; gap: .9rem; }
.auth-form.active { display: flex; }
.auth-form input, .auth-form select { width: 100%; padding: .8rem 1rem; border: 1.5px solid #ddd; border-radius: var(--radius); font-size: 1rem; transition: border-color .2s; }
.auth-form input:focus, .auth-form select:focus { outline: none; border-color: var(--green-mid); }

/* ===== BUTTONS ===== */
.btn-primary { background: var(--green-mid); color: var(--white); border: none; border-radius: var(--radius); padding: .85rem 1.5rem; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--green-pale); color: var(--green-dark); border: 1.5px solid var(--green-mid); border-radius: var(--radius); padding: .6rem 1rem; font-size: .9rem; cursor: pointer; }
.btn-text { background: none; border: none; color: var(--red); cursor: pointer; font-size: .9rem; }
.btn-full { width: 100%; }
.icon-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: .3rem; }

/* ===== TOPBAR ===== */
.topbar { height: var(--topbar-h); background: var(--green-dark); color: var(--white); display: flex; align-items: center; padding: 0 1rem; gap: .5rem; position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
.topbar-title { font-size: 1.1rem; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.badge-offline { background: var(--red); color: white; font-size: .7rem; font-weight: 700; padding: .2rem .5rem; border-radius: 6px; animation: pulse 1.5s infinite; }
.points-chip { background: var(--accent); color: white; font-size: .8rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ===== MAIN ===== */
.main-content { position: fixed; top: var(--topbar-h); bottom: var(--nav-h); left: 0; right: 0; overflow: hidden; }
.page { position: absolute; inset: 0; overflow-y: auto; display: none; padding: 1rem; }
.page.active { display: block; }
#page-map { padding: 0; }

/* ===== MAP ===== */
#map { height: 100%; width: 100%; }
.map-controls { position: absolute; bottom: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: .5rem; }
.map-fab { width: 48px; height: 48px; background: var(--white); border: none; border-radius: 50%; box-shadow: var(--shadow); font-size: 1.4rem; cursor: pointer; }
.map-legend { position: absolute; bottom: 1rem; left: 1rem; z-index: 1000; background: rgba(255,255,255,.9); border-radius: 8px; padding: .4rem .6rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.legend-item { font-size: .7rem; padding: .2rem .5rem; border-radius: 6px; font-weight: 600; }
.legend-item.birds    { background: #fff9c4; color: #827717; }
.legend-item.reptiles { background: #fce4ec; color: #880e4f; }
.legend-item.plants   { background: #e8f5e9; color: #1b5e20; }
.legend-item.aquatic  { background: #e3f2fd; color: #0d47a1; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-header h2 { font-size: 1.3rem; color: var(--green-dark); }
.sync-chip { font-size: .75rem; padding: .2rem .6rem; border-radius: 999px; background: var(--green-pale); color: var(--green-mid); }
.sync-chip.offline { background: #ffebee; color: var(--red); }

/* ===== REPORT FORM ===== */
.report-form { max-width: 500px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 2rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text-mid); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: .75rem 1rem; border: 1.5px solid #ddd; border-radius: var(--radius); font-size: 1rem;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--green-mid); }
.location-row { display: flex; gap: .5rem; }
.location-row input { flex: 1; }
.photo-area { border: 2px dashed #ccc; border-radius: var(--radius); padding: 1rem; text-align: center; cursor: pointer; position: relative; min-height: 120px; display: flex; align-items: center; justify-content: center; }
.photo-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.photo-placeholder { color: var(--text-light); font-size: .95rem; pointer-events: none; }
.photo-preview { max-width: 100%; max-height: 200px; border-radius: 8px; }
.offline-note { font-size: .8rem; color: var(--text-mid); text-align: center; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: var(--shadow); }
.stat-card.sdg14 { border-top: 3px solid var(--blue); }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--green-mid); }
.stat-label { font-size: .75rem; color: var(--text-mid); margin-top: .2rem; }
.chart-section { background: var(--white); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.chart-section h3 { font-size: 1rem; color: var(--green-dark); margin-bottom: .75rem; }
.bar-chart { display: flex; flex-direction: column; gap: .5rem; }
.bar-row { display: flex; align-items: center; gap: .5rem; }
.bar-label { width: 80px; font-size: .8rem; color: var(--text-mid); text-align: right; }
.bar-fill { height: 22px; border-radius: 4px; background: var(--green-mid); transition: width .5s; min-width: 4px; }
.bar-count { font-size: .8rem; color: var(--text-mid); }
.triple-helix-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.helix-card { background: var(--green-pale); border-radius: 8px; padding: .75rem; }
.helix-card h4 { font-size: .75rem; color: var(--green-dark); margin-bottom: .4rem; }
.helix-card p  { font-size: .8rem; color: var(--text-mid); margin: .15rem 0; }

/* ===== LEADERBOARD ===== */
.leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; padding-bottom: 2rem; }
.leaderboard-list li { background: var(--white); border-radius: var(--radius); padding: .8rem 1rem; display: flex; align-items: center; gap: .75rem; box-shadow: var(--shadow); }
.lb-rank { font-size: 1.3rem; width: 2rem; text-align: center; }
.lb-name { flex: 1; font-weight: 600; }
.lb-type { font-size: .75rem; color: var(--text-mid); }
.lb-pts  { font-weight: 700; color: var(--accent); }
.lb-reports { font-size: .8rem; color: var(--text-mid); }

/* ===== PROFILE ===== */
.profile-card { background: var(--white); border-radius: var(--radius); padding: 1.5rem; text-align: center; box-shadow: var(--shadow); margin-bottom: 1rem; }
.profile-avatar { font-size: 3rem; }
.profile-card h3 { font-size: 1.3rem; margin: .5rem 0 .3rem; }
.type-badge { background: var(--green-pale); color: var(--green-dark); font-size: .75rem; padding: .2rem .6rem; border-radius: 999px; text-transform: capitalize; }
.profile-stats { display: flex; justify-content: center; gap: 2rem; margin-top: 1rem; }
.profile-stats div { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.profile-stats strong { font-size: 1.5rem; color: var(--green-mid); }
.profile-stats small { font-size: .75rem; color: var(--text-mid); }
.badges-section, .pending-section { background: var(--white); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.install-section { margin-bottom: 1rem; }
.ios-install-hint { margin-top: .75rem; font-size: .82rem; line-height: 1.5; color: var(--green-dark); background: var(--green-pale); border-radius: var(--radius); padding: .6rem .75rem; text-align: center; }
.badges-section h3, .pending-section h3 { font-size: 1rem; color: var(--green-dark); margin-bottom: .75rem; }
.badges-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge-item { background: var(--green-pale); border-radius: 8px; padding: .5rem .75rem; font-size: .8rem; display: flex; align-items: center; gap: .4rem; }
.count-chip { background: var(--green-mid); color: white; font-size: .7rem; padding: .1rem .4rem; border-radius: 999px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav { height: var(--nav-h); background: var(--white); border-top: 1px solid #eee; display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; box-shadow: 0 -2px 8px rgba(0,0,0,.06); }
.nav-btn { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; cursor: pointer; color: var(--text-light); font-size: 1.3rem; transition: color .2s; padding: .4rem; }
.nav-btn span { font-size: .65rem; }
.nav-btn.active { color: var(--green-mid); }

/* ===== CHAT ===== */
.chat-fab { position: fixed; bottom: calc(var(--nav-h) + 1rem); right: 1rem; width: 52px; height: 52px; background: var(--green-mid); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; cursor: pointer; box-shadow: var(--shadow); z-index: 200; }
.chat-panel { position: fixed; bottom: calc(var(--nav-h) + 4.5rem); right: 1rem; width: min(340px, calc(100vw - 2rem)); height: 420px; background: var(--white); border-radius: var(--radius); box-shadow: 0 4px 24px rgba(0,0,0,.18); z-index: 201; display: flex; flex-direction: column; overflow: hidden; }
.chat-panel.hidden { display: none; }
.chat-header { background: var(--green-dark); color: white; padding: .75rem 1rem; display: flex; align-items: center; justify-content: space-between; }
.chat-header button { background: none; border: none; color: white; font-size: 1rem; cursor: pointer; }
.chat-messages { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.chat-msg { max-width: 80%; }
.chat-msg.own { align-self: flex-end; }
.chat-msg .bubble { background: var(--green-pale); border-radius: 12px 12px 4px 12px; padding: .5rem .75rem; font-size: .9rem; }
.chat-msg.own .bubble { background: var(--green-mid); color: white; border-radius: 12px 12px 12px 4px; }
.chat-msg .meta { font-size: .7rem; color: var(--text-light); margin-top: .2rem; }
.chat-msg.own .meta { text-align: right; }
.chat-input-row { display: flex; border-top: 1px solid #eee; }
.chat-input-row input { flex: 1; border: none; padding: .75rem; font-size: .95rem; outline: none; }
.chat-input-row button { background: var(--green-mid); color: white; border: none; padding: .75rem 1rem; cursor: pointer; font-weight: 600; }

/* ===== UTILS ===== */
.hidden { display: none !important; }
.error-msg   { color: var(--red); font-size: .85rem; min-height: 1.2em; }
.success-msg { color: var(--green-mid); font-size: .85rem; }

/* Leaflet marker colours */
.marker-birds    { background: #f9a825; }
.marker-reptiles { background: #e91e63; }
.marker-plants   { background: #43a047; }
.marker-aquatic  { background: #1e88e5; }

/* ===== ADMIN PANEL (separate page) ===== */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: .6rem .8rem; border-bottom: 1px solid #eee; text-align: left; }
.admin-table th { background: var(--green-pale); color: var(--green-dark); }
.status-pending  { color: #f57c00; font-weight: 600; }
.status-verified { color: var(--green-mid); font-weight: 600; }
.status-rejected { color: var(--red); font-weight: 600; }

/* ===== MY RECORDS ===== */
.my-records-section { margin-top: 1.5rem; }
.my-records-section h3 { font-size: 1rem; color: var(--green-dark); margin-bottom: .75rem; }
.record-filter-row { display: flex; gap: .4rem; margin-bottom: .75rem; flex-wrap: wrap; }
.filter-chip { background: var(--green-pale); border: 1.5px solid #c8e6d4; color: var(--green-dark); border-radius: 20px; padding: .3rem .8rem; font-size: .8rem; cursor: pointer; transition: all .2s; }
.filter-chip.active { background: var(--green-mid); color: white; border-color: var(--green-mid); }
.report-item { border: 1px solid #eee; border-radius: 10px; padding: .75rem; margin-bottom: .5rem; background: white; }
.report-item-inner { display: flex; align-items: center; gap: .75rem; }
.report-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.report-item-info { flex: 1; }
.report-item-info strong { display: block; font-size: .9rem; }
.report-item-info small { display: block; color: var(--text-light); font-size: .75rem; margin-top: .15rem; }

@media (min-width: 768px) {
  .main-content { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .bottom-nav   { max-width: 480px; left: 50%; transform: translateX(-50%); }
  .topbar       { max-width: 480px; left: 50%; transform: translateX(-50%); }
}
