/* ── MARAP web client (account.html) ── */

/* The hidden attribute must win over display:flex/grid on .modal, .auth-view, etc. */
[hidden] { display: none !important; }

.account-body { background: var(--sand); min-height: 100vh; }

/* Header */
#acct-nav { position: sticky; top: 0; z-index: 40; background: #fff; box-shadow: 0 1px 0 var(--line); }
#acct-nav .brand-logo { filter: none; }
#acct-nav .nav-links a { color: var(--navy); }
.acct-user { display: inline-flex; align-items: center; gap: 14px; }
#acct-username { font-weight: 700; color: var(--navy); }
.btn-ghost-navy { background: transparent; border: 2px solid var(--navy); color: var(--navy); }
.btn-ghost-navy:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Auth view ── */
.auth-view { min-height: calc(100vh - 70px); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 38px 34px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(10,42,67,.12);
}
.auth-card h1 { font-size: 1.7rem; margin-bottom: .2em; }
.auth-sub { color: var(--muted); margin-bottom: 22px; }
.auth-form .btn { width: 100%; margin-top: 6px; border: none; cursor: pointer; font-family: inherit; font-size: 1rem; }
.auth-toggle { margin: 18px 0 0; text-align: center; font-size: .92rem; color: var(--muted); }
.auth-toggle a { color: var(--teal); font-weight: 700; }

/* Shared form fields */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; color: var(--navy); font-size: .9rem; margin-bottom: 6px; }
.field .opt { color: var(--muted); font-weight: 500; font-size: .82rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-family: inherit; font-size: .95rem; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(25,167,160,.15); }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-field { display: flex; align-items: flex-end; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.checkbox-field input { width: auto; accent-color: var(--teal); }
.form-status { margin: 10px 0 0; font-size: .9rem; font-weight: 600; min-height: 1.1em; }
.form-status.ok { color: var(--teal); }
.form-status.err { color: #e2434e; }

/* ── App view ── */
.app-view { padding: 40px 24px 80px; }
#add-log-btn { border: none; cursor: pointer; font-family: inherit; font-size: 1rem; }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#export-btn { cursor: pointer; font-family: inherit; font-size: 1rem; }
.logs-empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Profile header */
.profile-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.profile-id { display: flex; align-items: center; gap: 16px; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: none; overflow: hidden;
  background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.7rem;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-id-text h1 { margin: 0; font-size: 1.6rem; }
.profile-id-text .link-btn { margin-top: 4px; }

/* Edit profile modal */
.pf-photo-row { display: flex; align-items: center; gap: 14px; }
.pf-avatar { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex: none; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.6rem; }
.pf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pf-pw-section { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 14px; }
.pf-pw-note { color: var(--muted); font-size: .88rem; margin: 6px 0 10px; }
#pf-pw-fields { margin-top: 12px; }
#pf-pw-send, #pf-pw-fields .btn { cursor: pointer; font-family: inherit; }
#pf-pw-fields .btn { margin-top: 4px; border: none; }

/* Stat cards */
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 14px; text-align: center; }
.stat-num { font-size: 1.9rem; font-weight: 900; color: var(--navy); line-height: 1; }
.stat-label { font-size: .85rem; color: var(--muted); font-weight: 600; margin-top: 6px; }

/* Tabs */
.profile-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 26px; flex-wrap: wrap; }
.ptab {
  background: none; border: none; padding: 12px 16px; font-family: inherit; font-weight: 700;
  font-size: .95rem; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.ptab:hover { color: var(--navy); }
.ptab.active { color: var(--navy); border-bottom-color: var(--teal); }

/* Summary sections */
.summary-section { margin-bottom: 36px; }
.section-title { font-size: 1.15rem; color: var(--navy); margin: 0 0 16px; }
.muted-note { color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head .section-title { margin: 0; }
.link-btn { background: none; border: none; color: var(--teal); font-family: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* Photos + Activity side by side */
.summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 36px; align-items: start; }
.summary-col .photos-grid { grid-template-columns: repeat(3, 1fr); }

/* Photos */
.photos-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.photo-thumb { aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: #e4e8ec; cursor: zoom-in; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.photo-thumb:hover img { transform: scale(1.04); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(6,21,31,.88); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }

/* Species citation */
.sp-citation { color: var(--muted); font-size: .72rem; margin-top: 6px; line-height: 1.35; }
.sp-citation a { color: var(--muted); text-decoration: underline; }
.sp-citation a:hover { color: var(--teal); }

/* Activity */
.insight-box {
  background: rgba(43,140,255,.09); color: var(--navy); border-radius: 14px;
  padding: 14px 18px; font-weight: 600; font-size: .95rem; margin-bottom: 16px;
}
.chart-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.activity-chart { width: 100%; height: auto; display: block; }
.species-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.species-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.species-card .thumb { aspect-ratio: 4 / 3; background: linear-gradient(160deg, #0e3a5c, #19a7a0); position: relative; }
.species-card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-credit {
  position: absolute; bottom: 6px; right: 6px; z-index: 2;
  background: rgba(0,0,0,.55); color: #fff; font-size: .6rem; font-weight: 600;
  padding: 2px 6px; border-radius: 6px; text-decoration: none; max-width: 92%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-credit:hover { background: rgba(0,0,0,.78); text-decoration: underline; }
.species-card { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.species-card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(10,42,67,.12); }
.species-card .info { padding: 12px 14px; }
.species-card .sp-name { font-weight: 700; color: var(--navy); font-size: .95rem; }
.species-card .sp-count { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* ── Species profile detail (full-screen) ── */
/* Full-screen, scrollable (block flow so tall content scrolls) */
#species-modal { display: block; padding: 0; overflow-y: auto; }
#species-modal .species-panel { display: block; width: 100%; max-width: 100%; min-height: 100vh; margin: 0; border-radius: 0; padding: 0; overflow: visible; }
.species-panel .modal-close {
  position: fixed; top: 14px; right: 16px; z-index: 10;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.94);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(0,0,0,.3); font-size: 2rem;
}
.sp-download { position: fixed; top: 14px; right: 66px; z-index: 11; }
.sp-dl-btn { background: rgba(255,255,255,.94); border: none; border-radius: 999px; padding: 9px 16px; font-family: inherit; font-weight: 700; font-size: .9rem; color: var(--navy); cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.sp-dl-menu { position: absolute; top: 46px; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.2); overflow: hidden; min-width: 184px; }
.sp-dl-menu button { display: block; width: 100%; text-align: left; padding: 12px 16px; background: none; border: none; font-family: inherit; font-size: .95rem; color: var(--navy); cursor: pointer; }
.sp-dl-menu button:hover { background: var(--sand); }
/* Top: cover carousel (left) + your photos (right) */
.sp-header { max-width: 1100px; margin: 0 auto; padding: 64px 26px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
.sp-cover { position: relative; height: 340px; border-radius: 16px; overflow: hidden; }
.sp-cover-grad { position: absolute; left: 0; right: 0; bottom: 0; height: 46%; background: linear-gradient(transparent, rgba(0,0,0,.72)); pointer-events: none; z-index: 2; }
.sp-cover-name { position: absolute; left: 18px; bottom: 14px; z-index: 3; }
.sp-cover-name h2 { margin: 0; font-size: 1.5rem; color: #fff; text-shadow: 0 1px 5px rgba(0,0,0,.55); }
.sp-cover-name p { margin: 2px 0 0; font-style: italic; font-size: .9rem; color: rgba(255,255,255,.92); text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.sp-dots { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; gap: 6px; }
.sp-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); transition: background .15s ease; }
.sp-dot.active { background: #fff; }
.sp-carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; height: 100%; }
.sp-carousel::-webkit-scrollbar { display: none; }
.sp-slide { position: relative; flex: 0 0 100%; height: 340px; scroll-snap-align: center; background: #0e3a5c; }
.sp-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-slide .no-media { position: absolute; inset: 0; background: linear-gradient(160deg, #0e3a5c, #19a7a0); }
.sp-yourphotos { height: 340px; overflow: hidden; display: flex; flex-direction: column; }
.sp-yourphotos.expanded { height: auto; overflow: visible; }
.sp-yp-head { flex: none; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sp-yp-head .data-title { text-align: left; margin: 0; }
/* Collapsed: a clean 3×2 grid that fills the cover's height — no clipped photos. */
.yourphotos-grid { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); grid-auto-rows: 0; gap: 8px; overflow: hidden; }
.yourphotos-grid .photo-thumb { aspect-ratio: auto; border-radius: 10px; overflow: hidden; }
.sp-yourphotos.expanded .yourphotos-grid { grid-template-rows: none; grid-auto-rows: auto; overflow: visible; }
.sp-yourphotos.expanded .yourphotos-grid .photo-thumb { aspect-ratio: 1 / 1; }
.sp-detail-body { max-width: 1100px; margin: 0 auto; padding: 22px 26px 72px; }
.sp-detail-body .sp-status { margin: 0 0 4px; }
.sp-title { margin: 0; font-size: 1.5rem; color: var(--navy); }
.sp-latin { margin: 2px 0 0; font-style: italic; color: var(--muted); }
.sp-status {
  display: inline-block; margin-top: 10px; background: rgba(232,137,59,.16); color: #b8631d;
  font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; padding: 4px 10px; border-radius: 999px;
}
.sp-section { font-size: 1rem; color: var(--navy); margin: 24px 0 10px; }
.sp-desc { color: var(--ink); font-size: .95rem; line-height: 1.6; margin: 0; }
.facts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fact { background: var(--sand); border-radius: 12px; padding: 12px 14px; }
.fact-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.fact-val { color: var(--navy); font-weight: 600; margin-top: 3px; font-size: .92rem; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--sand); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .82rem; color: var(--navy); }
.sp-link { margin: 22px 0 0; }
.sp-link a { color: var(--teal); font-weight: 700; }

/* Your-data charts inside species detail */
.data-block { margin-top: 18px; }
.data-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.data-grid .data-block { margin-top: 0; }
.data-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 6px; }
.data-grid-3 .data-block { margin-top: 0; display: flex; flex-direction: column; }
/* Fixed-height head (title + insight) so every chart starts at the same height → charts align across a row */
.chart-head { min-height: 58px; margin-bottom: 6px; }
.chart-head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chart-dl { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1.15rem; line-height: 1; padding: 2px 5px; border-radius: 6px; }
.chart-dl:hover { color: var(--navy); background: var(--sand); }
.chart-insight { font-size: .82rem; color: var(--muted); margin: 4px 0 0; line-height: 1.35; }
.sp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sp-toolbar [data-spexport] { cursor: pointer; font-family: inherit; }
.data-title { font-size: .98rem; color: var(--navy); font-weight: 700; text-transform: none; letter-spacing: 0; text-align: left; margin: 0; }
.sp-detail-body .insight-box { margin-bottom: 12px; }
@media (max-width: 980px) { .sp-header { grid-template-columns: 1fr; } .data-grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .data-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .data-grid-3 { grid-template-columns: 1fr; } }

.type-choices-3 { grid-template-columns: repeat(3, 1fr) !important; }

/* Log cards reuse .sighting-card from styles.css; add edit/delete controls */
.sighting-card { position: relative; }
.log-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.log-actions button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px;
  font-family: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--navy);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.log-actions .edit:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.log-actions .delete { color: #e2434e; }
.log-actions .delete:hover { background: #e2434e; color: #fff; border-color: #e2434e; }
.sighting-card.t-report .sighting-chip { background: #e2434e; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(6,21,31,.55); backdrop-filter: blur(2px); }
.modal-panel {
  position: relative; background: #fff; border-radius: 18px; width: 100%; max-width: 560px;
  box-shadow: 0 30px 80px rgba(0,0,0,.4); margin: auto; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 8px; }
.modal-head h2 { margin: 0; font-size: 1.4rem; }
.modal-close { background: none; border: none; font-size: 1.9rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 12px 24px 8px; }
.modal-foot { padding: 12px 24px 22px; border-top: 1px solid var(--line); margin-top: 8px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
.modal-actions .btn { border: none; cursor: pointer; font-family: inherit; font-size: 1rem; }
.modal-actions .btn-ghost-navy { border: 2px solid var(--navy); }

/* Type chooser */
.type-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-choice {
  border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 6px;
  font-family: inherit; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--navy);
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.type-choice:hover { border-color: var(--teal); }
.type-choice.lt-sighting.active { background: #2b8cff; border-color: #2b8cff; color: #fff; }
.type-choice.lt-catch.active    { background: #e8893b; border-color: #e8893b; color: #fff; }
.type-choice.lt-alert.active    { background: #e2434e; border-color: #e2434e; color: #fff; }
.type-choice.lt-project.active  { background: #19a7a0; border-color: #19a7a0; color: #fff; }

/* Field visibility (JS toggles .show) */
.type-field, .report-field { display: none; }
.type-field.show, .report-field.show { display: block; }
.row2.type-field.show { display: grid; }

.species-search { margin-bottom: 8px; }
#lf-species { max-height: none; }

.lf-map { width: 100%; height: 240px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.lf-map-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.lf-map-row .btn { border: 2px solid var(--navy); cursor: pointer; font-family: inherit; }
.lf-coords { color: var(--muted); font-size: .85rem; }
.lf-photo-preview { margin-top: 10px; }
.lf-photo-preview img { max-height: 160px; border-radius: 10px; display: block; }

/* Media fallback for logs without a photo/video */
.sighting-media .no-media { position: absolute; inset: 0; background: linear-gradient(160deg, #0e3a5c, #19a7a0); }

@media (max-width: 900px) {
  .species-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-row { grid-template-columns: 1fr; gap: 32px; }
  .summary-col .photos-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
  .type-choices { grid-template-columns: repeat(2, 1fr); }
  .type-choices-3 { grid-template-columns: repeat(3, 1fr) !important; }
  .row2 { grid-template-columns: 1fr; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .species-grid { grid-template-columns: 1fr; }
  .photos-grid { grid-template-columns: repeat(3, 1fr); }
  .facts-grid { grid-template-columns: 1fr; }
}
