/*
 * Guest Complaint Dashboard styles.
 */
:root {
  /* Primary: burnt orange. Secondary: complementary blue. Tertiary: teal + amber. */
  --primary: #bf5700;
  --primary-dark: #913f00;
  --secondary: #0079bf;        /* complement of the primary hue */
  --tertiary: #00897b;         /* teal accent */
  --accent: #e8a33d;           /* warm amber accent */
  --primary-tint: #fbf0e8;     /* subtle row/hover wash */
  --ink: #27251F;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --bg: #f4f5f7;
  --card: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  padding: 0 24px 48px;
}

.masthead {
  background: linear-gradient(120deg, var(--primary), var(--primary-dark));
  color: #fff;
  margin: 0 -24px 20px;
  padding: 24px 24px 26px;
  border-bottom: 4px solid var(--accent);
}
.masthead h1 { margin: 0; font-size: 26px; letter-spacing: -0.5px; }
.masthead .subtitle { margin: 6px 0 0; opacity: 0.9; font-size: 13px; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.stat .num { font-size: 30px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }

/* Filters */
.filters {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.filters .field { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.filters select, .filters input {
  padding: 7px 8px; border: 1px solid #cfcfcf; border-radius: 7px; font-size: 13px; background: #fff;
}
.filters .actions { flex-direction: row; align-items: flex-end; gap: 8px; }
.filters button {
  background: var(--primary); color: #fff; border: 0; border-radius: 7px;
  padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.filters button:hover { background: var(--primary-dark); }
.filters .reset { color: var(--secondary); font-size: 13px; text-decoration: none; padding: 8px 4px; }
.filters .reset:hover { text-decoration: underline; }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); min-height: 240px; display: flex; flex-direction: column;
}
.card.wide { grid-column: span 2; }
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.card canvas { flex: 1; max-height: 230px; }

/* Insights / analysis */
.insights {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); margin-bottom: 22px;
}
.insights h3 { margin: 0 0 10px; font-size: 14px; }
.insights .analysis { margin: 0 0 16px; font-size: 15px; line-height: 1.5; color: #333; }
.insight-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.insight {
  display: flex; flex-direction: column; gap: 3px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 9px; border-left: 3px solid var(--primary); background: #fcfcfc;
}
.insight-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.insight-value { font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.insight-sub { font-size: 12px; color: var(--secondary); font-weight: 600; }

/* Table */
.table-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04); overflow-x: auto;
}
.table-wrap h3 { margin: 0 0 12px; font-size: 14px; }
.hint-inline { font-weight: 400; color: var(--muted); font-size: 12px; }
/* Scrollable window for the comments list (sticky header stays visible). */
.table-scroll { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.cases { width: 100%; border-collapse: collapse; font-size: 12px; }
table.cases.sortable th.sort-col { cursor: pointer; user-select: none; }
table.cases.sortable th.sort-col:hover { background: #f0f0f0; }
table.cases.sortable th.sorted-asc::after { content: " ▲"; color: var(--primary); font-size: 9px; }
table.cases.sortable th.sorted-desc::after { content: " ▼"; color: var(--primary); font-size: 9px; }
table.cases th, table.cases td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cases th { position: sticky; top: 0; background: #fafafa; font-size: 11px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
table.cases tr:hover td { background: var(--primary-tint); }
table.cases .nowrap { white-space: nowrap; }
table.cases .center { text-align: center; }
table.cases .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
table.cases .comment { max-width: 340px; color: #444; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.yes { background: #d9efec; color: #00695f; }
.badge.no { background: #f1f1f1; color: #777; }

@media (max-width: 1100px) {
  .charts { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .insight-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .charts, .card.wide { grid-template-columns: 1fr; grid-column: auto; }
  .insight-cards { grid-template-columns: 1fr; }
}

/* ====================== App chrome: nav, pages, forms ====================== */
.topnav {
  margin: 0 -24px 0; padding: 12px 24px; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topnav .brand { font-weight: 800; letter-spacing: -0.3px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.topnav .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); display: inline-block; }
.topnav .brand-light { color: var(--accent); }
.topnav .navlinks { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topnav .navlinks a { color: #e8e8e8; text-decoration: none; }
.topnav .navlinks a:hover { color: #fff; }
.topnav .who { color: #b9b9b9; font-size: 13px; }
.topnav .tag, .tag {
  background: var(--primary); color: #fff; border-radius: 999px; font-size: 10px;
  padding: 2px 7px; margin-left: 4px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700;
}
.topnav .linkbtn { background: transparent; border: 1px solid #555; color: #fff; }

/* Flash */
.flash-wrap { margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.flash.notice { background: #e9f3ec; color: #1e7e34; border: 1px solid #cfe6d6; }
.flash.alert { background: #fbeaea; color: #b02a2a; border: 1px solid #f0cccc; }

/* Page shell (everything except the full-bleed dashboard) */
.page { max-width: 1100px; margin: 22px auto 0; }
.page.narrow { max-width: 620px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head .head-actions { display: flex; gap: 8px; }
.muted-sub { font-size: 14px; color: var(--muted); font-weight: 400; }
.empty { color: var(--muted); font-style: italic; }

/* Grid tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.grid th { background: #fafafa; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
table.grid tr:last-child td { border-bottom: 0; }
table.grid a { color: var(--secondary); text-decoration: none; }
table.grid a:hover { text-decoration: underline; }
.actions-cell { display: flex; gap: 10px; align-items: center; white-space: nowrap; }

/* Detail lists */
dl.detail { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin: 0 0 20px; }
dl.detail dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
dl.detail dd { margin: 2px 0 0; font-size: 15px; }
.page h2 { font-size: 16px; margin: 6px 0 12px; }
.muted { color: var(--muted); }

/* Forms */
.page form { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.page .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.page .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.page .field label { font-size: 12px; font-weight: 600; color: #444; }
.page .field input[type=text], .page .field input[type=email], .page .field input[type=tel],
.page .field input[type=password], .page .field select {
  padding: 9px 10px; border: 1px solid #cfcfcf; border-radius: 8px; font-size: 14px; background: #fff; width: 100%;
}
.page .field.check { flex-direction: row; align-items: flex-start; gap: 8px; }
.page .field.check label { font-weight: 400; }
.page .hint { color: var(--muted); font-size: 12px; }
fieldset.checks { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 4px 0 16px; }
fieldset.checks legend { font-size: 12px; font-weight: 600; color: #444; padding: 0 6px; }
fieldset.checks legend small { font-weight: 400; color: var(--muted); }
.checkitem { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.errors { background: #fbeaea; border: 1px solid #f0cccc; color: #b02a2a; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }
.errors ul { margin: 6px 0 0; padding-left: 20px; }

/* Buttons */
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #cfcfcf; }
.btn.danger { background: #b02a2a; color: #fff; }
.linkbtn { background: none; border: 0; color: var(--secondary); cursor: pointer; font-size: 14px; padding: 0; }
.linkbtn.danger { color: #b02a2a; }
.linkbtn:hover { text-decoration: underline; }

/* Devise auth pages */
.page form a, .topnav + .flash-wrap + h2 { color: var(--secondary); }

/* Let the topnav links wrap before they overflow on narrow screens. */
.topnav .navlinks { flex-wrap: wrap; row-gap: 6px; }

@media (max-width: 900px) {
  /* Wide management tables scroll horizontally instead of overflowing. */
  table.grid { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 768px) {
  body { padding: 0 14px 36px; }
  .masthead { margin: 0 -14px 16px; padding: 18px 16px 20px; }
  .masthead h1 { font-size: 21px; }
  .topnav { margin: 0 -14px; }
  .page { margin-top: 16px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head .head-actions { width: 100%; }
}

@media (max-width: 640px) {
  dl.detail, .page .field-row { grid-template-columns: 1fr; }
  .topnav { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .num { font-size: 24px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .table-scroll { max-height: 60vh; }
}

@media (max-width: 420px) {
  .filters { grid-template-columns: 1fr; }
}
