/* ===============================
   THEME SYSTEM (WCAG-friendly)
   - Dark default
   - [data-theme="light"] enables light mode
=================================*/

/* Default (Dark) */
:root {
  --bg: #0b0d10;
  --text: #f3f6f9;
  --text-muted: #c5ced8;
  --card-1: #111722;
  --card-2: #0f1520;
  --input: #0e131b;
  --border: rgba(255,255,255,0.16);
  --border-soft: rgba(255,255,255,0.10);

  --accent: #28c3da;       /* accent used as background */
  --accent-2: #15aabf;
  --accent-text: #07262b;  /* dark text on accent */

  --focus: #ffd24a;
  --danger: #ff6b6b;
  --success: #2ee6a6;

  --r: 12px;
  --r-lg: 16px;

  --base-font-size: 16px;
  --line-height: 1.55;
}

/* Respect OS preference unless overridden */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --text: #121317;
    --text-muted: #404854;
    --card-1: #ffffff;
    --card-2: #f6f8fb;
    --input: #f1f4f8;
    --border: rgba(0,0,0,0.20);
    --border-soft: rgba(0,0,0,0.12);

    --accent: #0aa2c0;
    --accent-2: #0bb3d5;
    --accent-text: #071b21;

    --focus: #b56e00;
  }
}

/* Explicit Light or Dark override */
:root[data-theme="light"] {
  --bg: #ffffff;
  --text: #121317;
  --text-muted: #404854;
  --card-1: #ffffff;
  --card-2: #f6f8fb;
  --input: #f1f4f8;
  --border: rgba(0,0,0,0.20);
  --border-soft: rgba(0,0,0,0.12);

  --accent: #0aa2c0;
  --accent-2: #0bb3d5;
  --accent-text: #071b21;

  --focus: #b56e00;
}
:root[data-theme="dark"] {
  --bg: #0b0d10;
  --text: #f3f6f9;
  --text-muted: #c5ced8;
  --card-1: #111722;
  --card-2: #0f1520;
  --input: #0e131b;
  --border: rgba(255,255,255,0.16);
  --border-soft: rgba(255,255,255,0.10);

  --accent: #28c3da;
  --accent-2: #15aabf;
  --accent-text: #07262b;

  --focus: #ffd24a;
}

/* ===============================
   BASE / LAYOUT / TYPE
=================================*/
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: var(--base-font-size); }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: var(--line-height);
}

.container { max-width: 760px; margin: 32px auto; padding: 0 16px; }
.card {
  background: linear-gradient(180deg, var(--card-1), var(--card-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
}

h1, h2, h3 { letter-spacing: 0.2px; }
h1 { font-size: 1.6rem; margin: 0 0 6px; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
.small { font-size: 0.875rem; color: var(--text-muted); }

/* ===============================
   FORM + CONTROLS
=================================*/
label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

/* new – inputs are full-width, buttons are not */
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
}

button {
  width: auto;                 /* <-- no stretching */
  padding: 12px 14px;
  border-radius: var(--r);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  font-weight: 800;
  cursor: pointer;
}

::placeholder { color: #8a96a6; opacity: 1; }
textarea { resize: vertical; min-height: 84px; }

button {
  cursor: pointer;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  border: none;
}

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 8px;
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
@media (max-width: 640px) { .row { flex-direction: column; } }

/* ===============================
   GRID / RESULTS
=================================*/
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.item {
  background: color-mix(in oklab, var(--card-2), var(--bg) 20%);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 12px;
}
.item img, #searchResults img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--border);
}

/* ===============================
   PAGE HEADER & SUBTITLE
=================================*/
.page-header { text-align: center; margin: 28px 0 8px; }
.subtitle { color: var(--text-muted); margin-top: 6px; }

/* Search section container */
.search-section {
  width: 100%;
  max-width: 760px;
  margin: 16px auto;
  padding: 0 16px;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  background: #0c111b;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  color: #e7ecf3;
  font-size: 16px;
  line-height: 1.4;
  padding: 8px;
  outline: none;
  min-height: 44px;
}

/* Compact two-button row under the search bar */
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;   /* always two columns on mobile */
  gap: 8px;                         /* tighter gap */
  margin-top: 8px;                  /* less vertical space */
}

/* Smaller, pill-style buttons */
.btn {
  border: none;
  border-radius: 999px;             /* pill */
  padding: 8px 10px;                /* compact padding */
  font-weight: 600;
  font-size: 14px;                  /* slightly smaller text */
  line-height: 1;
  min-height: 36px;                 /* smaller tap target but still usable */
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

/* Visual styles */
.btn.add {
  background: linear-gradient(135deg, #22b8cf, #15aabf);
  color: #001219;
  border: 1px solid rgba(255,255,255,0.08);
}
.btn.edit {
  background: #151a27;
  color: #e7ecf3;
  border: 1px solid rgba(255,255,255,0.12);
}

/* On wider screens, keep them compact and align to the right of the search block */
@media (min-width: 860px) {
  .search-section {
    display: grid;
    grid-template-columns: 1fr auto;  /* search | buttons */
    column-gap: 12px;
    align-items: center;
  }
  .button-row {
    grid-template-columns: auto auto; /* size to content */
    gap: 8px;
    margin-top: 0;
    justify-content: end;
  }
  .btn { padding: 8px 12px; min-height: 36px; }
}

/* ===============================
   TOGGLE SWITCHES
=================================*/
.toggle-group { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.toggle {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 14px 18px;
  cursor: pointer;
  transition: background .25s, border-color .25s;
}
.toggle input { display: none; }
.toggle .label-text { font-size: 1rem; padding-right: 12px; line-height: 1.35; }
.pill {
  width: 46px; height: 24px; background: #7f8ea1; border-radius: 50px; position: relative; flex-shrink: 0;
  transition: background .25s;
}
.pill::after {
  content: ""; width: 20px; height: 20px; background: #ffffff; border-radius: 50%;
  position: absolute; top: 2px; left: 2px; transition: transform .25s;
}
.toggle input:checked + .pill { background: var(--accent); }
.toggle input:checked + .pill::after { transform: translateX(22px); }
.toggle.active { border-color: var(--accent); background: color-mix(in oklab, var(--accent), var(--bg) 80%); }

/* ===============================
   MODALS
=================================*/
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; }
/* Base modal shell */
.modal {
  position: fixed;
  left: 50%;
  top: 10%;                        /* start near top */
  transform: translateX(-50%);     /* only center horizontally */
  width: min(720px, 92%);
  background: linear-gradient(180deg,#121826,#0f1420);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 18px;
  z-index: 60;
  max-height: 80vh;                /* taller viewport slice */
  overflow: auto;
}

/* Registration modal specifically: make it feel bigger/taller */
#regModal {
  min-height: 100vh;                /* visibly tall on desktop */
}

@media (max-width: 640px) {
  #regModal {
    top: 0;
    left: 0;
    transform: none;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;              /* edge-to-edge on mobile */
  }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.close-x {
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

/* ===============================
   THEME TOGGLE BUTTON
=================================*/
.theme-toggle {
  position: absolute; top: 16px; right: 16px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.theme-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ===============================
   REDUCED MOTION
=================================*/
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Align title + switch */
.row-head { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.title-wrap { flex:1; }

/* compact theme toggle */
.theme-toggle-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 26px;
  cursor: pointer;
}

/* hide the native checkbox everywhere (iOS needs this combo) */
.theme-toggle-wrap input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.theme-pill {
  width: 46px; height: 26px;
  background: #7f8ea1;
  border: 1px solid var(--border);
  border-radius: 50px;
  position: relative;
  transition: background .25s;
}

.theme-pill::after {
  content: "";
  width: 20px; height: 20px; background: #fff;
  border-radius: 50%;
  position: absolute; top: 3px; left: 3px;
  transition: transform .25s;
}

.theme-toggle-wrap input:checked + .theme-pill { background: var(--accent); }
.theme-toggle-wrap input:checked + .theme-pill::after { transform: translateX(20px); }

/* Make thumbnails taller and consistent across screens */
img.thumb {
  width: 100%;
  height: 260px;                  /* increased from ~140–220px */
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: transform 0.2s ease;
}

img.thumb:hover {
  transform: scale(1.02);
}

/* Full-screen image modal */
.image-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.9);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.image-modal img {
  max-width: 95%;
  max-height: 95%;
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(0,0,0,0.6);
}

.linklike { background:none;border:none;padding:6px 10px;cursor:pointer;text-decoration:underline }
.modal { position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:1000 }
.modal-card { background:var(--card-bg,#fff); color:var(--text,#111); padding:16px;border-radius:12px; width:min(420px,92vw); box-shadow:0 10px 30px rgba(0,0,0,.3) }
[data-theme="dark"] .modal-card { --card-bg:#111827; --text:#f9fafb }
