/* ==========================================================
   Goaltica demo v1.0.0-alpha.1 — Main Stylesheet
   Author: Zafer Yilmaz
   Description:
     - Mobile-first, offline-friendly PWA layout
     - Plain, compact but functional design
     - Light & dark themes
     - Focus on clarity, spacing, and accessibility
   ========================================================== */

/* ----------------------------------------------------------
   1. ROOT VARIABLES — LIGHT THEME DEFAULT
   ---------------------------------------------------------- */
:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #1976d2;
  --danger: #e53935;
  --success: #28a745; /* vivid, clear green for success */
  --border: #e5e7eb;
  --hover-bg: #f8f9fa;
  --max-width: 720px;
  --radius: 0.75rem;
  --shadow: rgba(0, 0, 0, 0.08);
}
/* ----------------------------------------------------------
   2. DARK THEME OVERRIDES
   ---------------------------------------------------------- */
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --danger: #ef5350;
  --success: #4ade80; /* lighter green for dark background */
  --border: #30363d;
  --hover-bg: #2a2a2a;
  --shadow: rgba(255, 255, 255, 0.06);
}
/* ----------------------------------------------------------
   3. UNIVERSAL RESET
   ---------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: var(--accent);
}
a:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------------
   4. GLOBAL LAYOUT
   ---------------------------------------------------------- */
body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ----------------------------------------------------------
   5. HEADER
   ---------------------------------------------------------- */
header {
  max-width: var(--max-width);
  width: 100%;
  margin: 1.5rem auto 1rem;
  text-align: center;
}

header h1 {
  font-family: "Lucida Grande", "Lucida Sans Unicode", "Segoe UI",
    "Helvetica Neue", -apple-system, sans-serif;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

header .tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ----------------------------------------------------------
   6. FOOTER
   ---------------------------------------------------------- */
footer {
  margin-top: 2rem;
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

footer h3 {
  font-family: "Lucida Grande", "Lucida Sans Unicode", "Segoe UI",
    "Helvetica Neue", -apple-system, sans-serif;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.3rem;
  font-size: 1.2rem;
}

footer p {
  margin: 0.4rem 0;
  line-height: 1.4;
}

footer a {
  color: var(--accent);
  font-weight: 500;
}

footer a:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------------
   7. APP CONTAINER
   ---------------------------------------------------------- */
/* Center main content and limit width */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ----------------------------------------------------------
   8. APP - Summary Section
   ---------------------------------------------------------- */
.summary {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow);
  padding: 1rem;
  text-align: center;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.summary-card {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.summary-card div {
  font-size: 0.95rem;
  color: var(--text);
}
.summary-card strong {
  color: var(--accent);
}

/* ----------------------------------------------------------
   9. APP - Form Section
   ---------------------------------------------------------- */
#form-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center; /* centers horizontally */
  max-width: 100%;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Toggle button (+) */
#toggle-form-btn {
  font-size: 1.5rem;
  align-self: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px var(--shadow);
  transition: transform 0.2s ease, background 0.3s ease;
}
#toggle-form-btn:hover {
  opacity: 0.95;
}

/* The form itself */
#goal-form {
  display: none; /* hidden by default — toggled via JS */
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}
#form-section.visible #goal-form {
  display: flex;
}

/* Input & Textarea */
input[type="text"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, background 0.3s, box-shadow 0.3s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
  outline: none;
}

/* Textarea — auto height feel and spacing */
textarea {
  resize: vertical;
  min-height: 80px;
  max-height: 240px;
  line-height: 1.4;
}

select {
  cursor: pointer;
}

.char-counter {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  /* margin-bottom: 0.3rem; */
  user-select: none;
  transition: color 0.2s ease;
}

.char-counter.limit {
  color: var(--danger);
  font-weight: 500;
}

/* Priority select */
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%),
    linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% - 3px),
    calc(100% - 10px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Buttons inside form */
.form-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-start;
  margin-top: 0.5rem;
}

.form-actions .btn {
  flex: 1;
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
}

#cancel-edit {
  display: none;
}

/* Temporary attention highlight when editing an item */
#goal-form.highlight {
  box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.08);
  border-radius: var(--radius);
  transition: box-shadow 0.25s ease;
}

/* ----------------------------------------------------------
   10. APP - Buttons
   ---------------------------------------------------------- */
.btn {
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, opacity 0.2s, border 0.2s;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  opacity: 0.9;
}
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
[data-theme="dark"] .btn.secondary {
  background: #1c1c1c;
  border-color: #444;
  color: #eee;
}
.btn.secondary:hover {
  background: var(--surface);
}
.btn.danger {
  background: #e53935;
  color: #fff;
}
.btn.danger:hover {
  opacity: 0.85;
}

.btn.success {
  background-color: var(--success);
  color: #fff;
}

.btn.success:hover {
  opacity: 0.85;
}

/* ----------------------------------------------------------
   11. APP - Search Section
   ---------------------------------------------------------- */
#search-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow);
  padding: 0.75rem 1rem;
  max-width: var(--max-width);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Input field */
#search-section .search-bar {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  box-shadow: 0 1px 2px var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
}

#search-section .search-bar::placeholder {
  color: var(--text-muted);
}

/* Focus + hover */
#search-section .search-bar:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
  outline: none;
}

@media (hover: hover) {
  #search-section .search-bar:hover {
    background-color: var(--hover-bg);
  }
}

/* Optional: slight contrast in dark theme */
[data-theme="dark"] #search-section .search-bar {
  background-color: var(--surface);
  box-shadow: 0 1px 3px var(--shadow);
}

/* ----------------------------------------------------------
   12. APP - Goal List Section
   ---------------------------------------------------------- */
#goal-list-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow);
  padding: 1rem;
}

#goal-list-section h2 {
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

#goal-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Individual goal item */
.goal-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  transition: all 0.3s ease;
  position: relative;
}

.goal-item:hover {
  background: var(--hover-bg);
  transform: translateY(-1px);
}

/* Completed goal — soft gray background and dimmed text */
.goal-item.completed {
  background: #f3f4f6; /* light gray surface */
  color: #6b7280; /* muted text */
  border: 1px solid #d1d5db; /* soft gray border */
  opacity: 0.9;
}

/* Dark theme override */
[data-theme="dark"] .goal-item.completed {
  background: #1f2229; /* dark gray surface */
  color: #9ca3af; /* muted text */
  border: 1px solid #30363d; /* soft dark border */
  opacity: 0.85;
}

/* Completed badge */
.goal-item.completed::after {
  content: "✓";
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--success);
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  box-shadow: 0 1px 3px var(--shadow);
  opacity: 0.95;
}

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

.goal-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Goal description truncation */
.goal-desc {
  display: -webkit-box; /* Required for -webkit-line-clamp */
  -webkit-box-orient: vertical; /* Required for -webkit-line-clamp */
  -webkit-line-clamp: 3; /* Chrome, Safari, Edge */ /* show 3 lines */
  line-clamp: 3; /* Standard property (future-proof) */
  position: relative;
  overflow: hidden;
  line-height: 1.7;
  max-height: calc(1.7em * 3);
  transition: max-height 0.3s ease;
  color: var(--text);
  font-size: 0.9rem;
}

/* When expanded via JS toggle (e.g., read-more active) */
.goal-desc.expanded {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: none;
}

/* Read More button */
.read-more-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  margin-top: 0.5rem;
  align-self: flex-start;
  transition: opacity 0.2s ease;
}
.read-more-btn:hover {
  color: var(--accent);
  opacity: 0.8;
}

.goal-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Base style: soft pill buttons */
.goal-controls button {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s ease;
  box-shadow: none;
}

/* Hover / focus state */
.goal-controls button:hover,
.goal-controls button:focus {
  background: var(--hover-bg);
  color: var(--text);
  outline: none;
}

/* Subtle accent for edit */
.goal-controls .edit-btn {
  color: var(--accent);
}

/* Delete = danger tone */
.goal-controls .delete-btn {
  color: var(--danger);
}

.goal-controls .delete-btn:hover {
  background: rgba(229, 57, 53, 0.1);
}

/* Toggle completed */
.goal-controls .complete-btn.completed {
  background: rgba(25, 118, 210, 0.1);
  color: var(--accent);
  font-weight: 500;
}

/* ----------------------------------------------------------
   13. APP - Settings Section
   ---------------------------------------------------------- */
#settings-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: center;
  margin-top: 1rem;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

#settings-section h3 {
  font-size: 1.1rem;
  color: var(--text);
}

#settings-section p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

#settings-section .btn {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
}

/* ----------------------------------------------------------
   14. APP - FLOATING ACTION BUTTON (Mobile Quick Add)
   ---------------------------------------------------------- */
.fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px var(--shadow);
  border: none;
  cursor: pointer;
  z-index: 50;
  transition: background 0.3s, transform 0.2s ease-in-out;
}

.fab:hover {
  transform: translateY(-3px);
  opacity: 0.9;
}

.fab:active {
  transform: scale(0.96);
}

/* When dark mode is active */
[data-theme="dark"] .fab {
  box-shadow: 0 3px 10px rgba(255, 255, 255, 0.1);
}

/* ----------------------------------------------------------
   15. APP - RESPONSIVE ADJUSTMENTS
   ---------------------------------------------------------- */

@media (min-width: 600px) {
  body {
    padding: 2rem;
  }
  main {
    gap: 2rem;
  }
  .fab {
    bottom: 2rem;
    right: 2rem;
  }
}
