/**
 * google-survey app.css
 * Mobile-first, responsive, accessible styling
 */

/* ============================================================================
   Reset & Base
   ========================================================================== */

:root {
  color-scheme: light dark;
  --accent-color: #0066cc;
  --error-color: #b00020;
  --border-color: #ccc;
  --text-color: #000;
  --bg-color: #fff;
  --muted-color: #6b7280;
}

@media (prefers-color-scheme: dark) {
  :root {
    --border-color: #444;
    --text-color: #fff;
    --bg-color: #1a1a1a;
    --muted-color: #9ca3af;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 1.5rem;
  max-width: 60rem;
  margin-inline: auto;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
}

/* ============================================================================
   Typography
   ========================================================================== */

h1 {
  font-size: 1.75rem;
  margin: 0 0 1rem 0;
  font-weight: 600;
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem 0;
  font-weight: 600;
}

p {
  margin: 0.5rem 0;
}

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

a:hover,
a:focus {
  text-decoration: underline;
}

/* ============================================================================
   Forms & Controls
   ========================================================================== */

label {
  font-weight: 600;
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

label:first-child {
  margin-top: 0;
}

input,
textarea,
select {
  font: inherit;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  width: 100%;
  max-width: 30rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

button {
  font: inherit;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  cursor: pointer;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-weight: 500;
}

button:hover,
button:focus {
  background-color: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  outline: none;
}

button:active {
  opacity: 0.9;
}

button[type="submit"] {
  background-color: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

button[type="submit"]:hover,
button[type="submit"]:focus {
  background-color: #0052a3;
}

/* ============================================================================
   Errors
   ========================================================================== */

.error {
  color: var(--error-color);
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ============================================================================
   Landing Page
   ========================================================================== */

.landing {
  text-align: center;
  padding: 2rem 0;
}

.logo {
  max-width: 18rem;
  max-height: 10rem;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 1.5rem;
  border-radius: 0.5rem;
}

.landing h1 {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.landing > p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* Stars: Accessible 5-star rating widget */
.stars {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  font-size: 3rem;
  margin: 2rem 0 0.5rem;
  flex-wrap: wrap;
}

/* Numeric labels (1..5) sitting directly under each star. Mirrors the
   .stars flex layout (same gap + per-item width) so each number lines up
   under its star. */
.star-numbers {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 0 2rem;
}

.star-numbers span {
  width: 3.5rem;
  min-width: 44px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted-color, #6b7280);
}

.prompt-sub {
  color: var(--muted-color, #6b7280);
  margin-top: -0.5rem;
}

.star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  min-width: 44px;
  min-height: 44px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  line-height: 1;
}

.star:hover,
.star:focus {
  transform: scale(1.1);
  border-color: var(--accent-color);
  outline: none;
}

.star:active {
  transform: scale(0.95);
}

/* Progressive enhancement: fill effect when JS is active */
.star--filled {
  color: #ffa500;
  filter: drop-shadow(0 0 0.25rem rgba(255, 165, 0, 0.5));
}

/* ============================================================================
   Feedback Form
   ========================================================================== */

.feedback-form {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

.feedback-card {
  width: 100%;
  max-width: 34rem;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.feedback-card h1 {
  margin: 0 0 0.75rem;
  font-size: 1.6rem;
}

.feedback-card > p {
  margin: 0 auto 1.75rem;
  max-width: 28rem;
  font-size: 1.05rem;
  color: var(--muted-color, #6b7280);
  line-height: 1.6;
}

.feedback-card form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  text-align: left;
}

.feedback-card form > div {
  display: flex;
  flex-direction: column;
}

.feedback-card label {
  font-size: 0.9rem;
}

.feedback-card .optional {
  font-weight: 400;
  color: var(--muted-color, #6b7280);
}

.feedback-card input,
.feedback-card textarea {
  max-width: 100%;
}

.feedback-card textarea {
  min-height: 7rem;
}

.feedback-card button[type="submit"] {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.9rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 0.5rem;
}

/* ============================================================================
   Thank You Page
   ========================================================================== */

.thankyou {
  text-align: center;
  padding: 2rem 0;
}

.thankyou h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.thankyou p {
  font-size: 1.1rem;
  line-height: 1.6;
}

/* ============================================================================
   Not Found Page
   ========================================================================== */

.notfound {
  text-align: center;
  padding: 2rem 0;
}

.notfound h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--error-color);
}

/* ============================================================================
   Admin Layout & Navigation
   ========================================================================== */

nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1rem;
}

nav a {
  text-decoration: none;
  color: var(--accent-color);
  font-weight: 500;
  padding: 0.5rem 0;
  border-bottom: 3px solid transparent;
  transition: border-color 0.2s;
}

nav a:hover,
nav a:focus {
  border-bottom-color: var(--accent-color);
  text-decoration: none;
  outline: none;
}

nav form {
  margin: 0;
}

/* ============================================================================
   Admin Login
   ========================================================================== */

.login {
  max-width: 20rem;
  margin: 3rem auto;
  padding: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

.login h1 {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login form > div {
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   Clients (Admin List)
   ========================================================================== */

.clients h1 {
  margin-bottom: 1.5rem;
}

.search {
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.search label {
  margin-top: 0;
  margin-bottom: 0;
}

.search input {
  margin: 0;
  flex: 1;
  min-width: 200px;
  max-width: 100%;
}

.search button {
  white-space: nowrap;
}

.clients > p {
  margin-bottom: 1rem;
}

.clients a {
  color: var(--accent-color);
}

/* ============================================================================
   Client Form (Admin Create/Edit)
   ========================================================================== */

.client-form h1 {
  margin-bottom: 1.5rem;
}

.client-form form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.client-form form > label {
  margin-top: 1rem;
}

.client-form form > label:first-of-type {
  margin-top: 0;
}

.client-form input[type="file"] {
  padding: 0.5rem;
  border: 2px dashed var(--border-color);
}

/* ============================================================================
   Tables (responsive)
   ========================================================================== */

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
}

th,
td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  word-wrap: break-word;
}

th {
  background-color: rgba(0, 102, 204, 0.05);
  font-weight: 600;
}

tfoot th {
  border-top: 2px solid var(--border-color);
  font-weight: 600;
}

/* Mobile table responsive: stack on narrow screens */
@media (max-width: 640px) {
  table,
  thead,
  tbody,
  tfoot,
  th,
  td,
  tr {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr,
  tfoot tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    overflow: hidden;
  }

  td,
  th {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
  }

  td::before,
  th::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 1rem;
    flex: 0 0 auto;
  }

  td:last-child,
  th:last-child {
    border-bottom: none;
  }
}

/* ============================================================================
   Table Actions
   ========================================================================== */

.actions {
  display: flex !important;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.actions button,
.actions a {
  flex: 0 1 auto;
  white-space: nowrap;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
}

.copy-review-url {
  background-color: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.copy-review-url:hover {
  background-color: #0052a3;
  border-color: #0052a3;
}

.form.inline {
  display: inline;
  margin: 0;
}

/* ============================================================================
   Analytics
   ========================================================================== */

.analytics h1 {
  margin-bottom: 1.5rem;
}

.analytics table {
  font-size: 0.95rem;
}

.analytics th,
.analytics td {
  padding: 0.6rem;
}

/* ============================================================================
   Feedback Inbox
   ========================================================================== */

.inbox h1 {
  margin-bottom: 1.5rem;
}

.inbox table {
  font-size: 0.95rem;
}

.inbox th,
.inbox td {
  padding: 0.6rem;
  word-break: break-word;
}

.inbox td[data-label="Feedback"] {
  max-width: 30rem;
  white-space: normal;
}

/* ============================================================================
   Admin Layout Responsiveness
   ========================================================================== */

@media (max-width: 768px) {
  body {
    max-width: 100%;
    padding: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  nav a,
  nav button {
    display: block;
    width: 100%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 1rem 0.75rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .stars {
    font-size: 2.5rem;
    gap: 0.5rem;
  }

  .star {
    width: 3rem;
    height: 3rem;
  }

  /* Keep the numeric labels aligned with the smaller/tighter mobile stars. */
  .star-numbers {
    gap: 0.5rem;
  }

  .star-numbers span {
    width: 3rem;
  }

  input,
  textarea,
  select {
    max-width: 100%;
  }

  button {
    font-size: 1rem;
  }

  .search {
    flex-direction: column;
  }

  .search input {
    min-width: 100%;
  }

  .search button {
    width: 100%;
  }

  .login {
    margin: 2rem auto;
    padding: 1.5rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions button,
  .actions a {
    width: 100%;
    text-align: center;
  }
}

/* ============================================================================
   Utility Classes
   ========================================================================== */

.inline {
  display: inline;
}

/* ============================================================================
   Accessibility
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

button:focus-visible {
  outline-offset: -2px;
}

a:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  button {
    border-width: 2px;
  }

  .star {
    border-width: 2px;
  }

  table {
    border-width: 2px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .star {
    transition: none;
  }
}
