@import url("/shared/base.css");

/* ── Form Responses additional variables ───────────────────────────────── */
:root {
  --bg-input-focus: #fff;
  --logo-filter: none;
  --status-paid-bg: #e6f4ed;
  --status-paid-text: #087a59;
  --status-pending-bg: #fff5e6;
  --status-pending-text: #946200;
  --status-failed-bg: #fde7ea;
  --status-failed-text: #d43a4c;
  --kind-form-bg: #e8eefc;
  --kind-form-text: #2555ef;
  --kind-event-bg: #fff5e6;
  --kind-event-text: #c96a14;
}
html.dark {
  --bg-input-focus: #1a1a2e;
  --logo-filter: brightness(1.5) saturate(0.8);
  --status-paid-bg: rgba(45,212,168,0.15);
  --status-paid-text: #2dd4a8;
  --status-pending-bg: rgba(255,190,51,0.15);
  --status-pending-text: #ffbe33;
  --status-failed-bg: rgba(255,107,122,0.15);
  --status-failed-text: #ff6b7a;
  --kind-form-bg: rgba(64,104,215,0.18);
  --kind-form-text: #8aa6f0;
  --kind-event-bg: rgba(240,146,58,0.15);
  --kind-event-text: #f0923a;
}
@media (prefers-color-scheme: dark) {
  html:not(.light):not(.dark) {
    --bg-input-focus: #1a1a2e;
    --logo-filter: brightness(1.5) saturate(0.8);
    --status-paid-bg: rgba(45,212,168,0.15);
    --status-paid-text: #2dd4a8;
    --status-pending-bg: rgba(255,190,51,0.15);
    --status-pending-text: #ffbe33;
    --status-failed-bg: rgba(255,107,122,0.15);
    --status-failed-text: #ff6b7a;
    --kind-form-bg: rgba(64,104,215,0.18);
    --kind-form-text: #8aa6f0;
    --kind-event-bg: rgba(240,146,58,0.15);
    --kind-event-text: #f0923a;
  }
}

body { height: 100vh; overflow: hidden; }

/* ── Theme toggle ──────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex; gap: 4px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px;
}
.theme-toggle button {
  background: transparent; border: none; padding: 4px 8px;
  cursor: pointer; border-radius: 4px; color: var(--text-secondary);
  font-size: 0.95em;
}
.theme-toggle button:hover { background: var(--bg-hover); }
.theme-toggle button.active { background: var(--accent); color: #fff; }

/* ── Login ────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg-page);
}
.login-card {
  background: var(--bg-surface); border-radius: 12px; padding: 40px;
  box-shadow: var(--shadow-card); width: 400px; max-width: 92vw; text-align: center;
}
.login-card img.logo { height: 36px; margin-bottom: 16px; filter: var(--logo-filter); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; color: var(--text-heading); font-weight: 600; }
.login-card p.sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; font-weight: 300; }
.login-card input[type="email"], .login-card input[type="password"] {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 16px; margin-bottom: 12px; outline: none;
  background: var(--bg-input); font-family: inherit; color: var(--text-primary);
}
.login-card input:focus { border-color: var(--accent); background: var(--bg-input-focus); }
.login-card button[type="submit"] {
  width: 100%; padding: 12px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  font-family: inherit;
}
.login-card button[type="submit"]:hover { background: var(--accent-hover); }
.login-card button[type="submit"]:disabled { background: var(--accent-disabled); cursor: not-allowed; }
.login-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.error-msg { color: var(--error); font-size: 12px; margin-bottom: 10px; min-height: 16px; }
.conn-status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.conn-dot.connected { background: var(--success); }
.conn-dot.disconnected { background: var(--error); }
.conn-dot.checking { background: var(--warning); }

/* ── App layout ───────────────────────────────────────────────────────── */
#app-screen { display: none; height: 100vh; flex-direction: column; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left img { height: 28px; filter: var(--logo-filter); }
.header-left h1 { font-size: 1.1em; font-weight: 600; color: var(--text-heading); }
.header-right { display: flex; align-items: center; gap: 12px; }
#user-display { font-size: 0.85em; color: var(--text-secondary); }
.hdr-btn {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; cursor: pointer; font-size: 0.95em; color: var(--text-secondary);
  font-family: inherit;
}
.hdr-btn:hover { background: var(--bg-hover); color: var(--text-strong); }

#app-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  overflow: hidden;
  position: relative;
}
#app-body.detail-open { grid-template-columns: 320px 1fr 380px; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
#side-panel {
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
#panel-header {
  padding: 14px; border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
#panel-header input[type="text"] {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-input); color: var(--text-primary); font-family: inherit;
  font-size: 0.9em;
}
#panel-header input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--bg-input-focus); }
#filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px;
  font-size: 0.78em; color: var(--text-secondary); cursor: pointer;
}
.chip input { margin: 0; }
.chip:has(input:checked) { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
#forms-count { margin-top: 10px; font-size: 0.8em; color: var(--text-muted); }

#forms-list { flex: 1; overflow-y: auto; padding: 8px 6px; }
.form-item {
  display: block; padding: 12px 14px; border-radius: 8px; cursor: pointer;
  margin-bottom: 4px; border: 1px solid transparent;
}
.form-item:hover { background: var(--bg-hover); }
.form-item.active { background: var(--bg-selected); border-color: var(--accent); }
.form-item .form-name {
  font-weight: 500; color: var(--text-strong); font-size: 0.92em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.form-item .form-meta {
  font-size: 0.78em; color: var(--text-muted); margin-top: 2px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.kind-badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 0.72em; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px;
}
.kind-badge.form { background: var(--kind-form-bg); color: var(--kind-form-text); }
.kind-badge.event { background: var(--kind-event-bg); color: var(--kind-event-text); }
.archived-badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 0.72em; background: var(--bg-input); color: var(--text-muted);
}

/* ── Main panel ───────────────────────────────────────────────────────── */
#main-panel {
  background: var(--bg-page); overflow: hidden; display: flex; flex-direction: column;
}

#empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); text-align: center; padding: 40px;
}
.empty-icon { font-size: 3em; margin-bottom: 12px; opacity: 0.6; }
#empty-state h2 { font-size: 1.2em; color: var(--text-heading); font-weight: 500; margin-bottom: 6px; }

#responses-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#responses-header {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 16px 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; align-items: flex-start; flex-wrap: wrap;
}
#responses-title {
  font-size: 1.2em; font-weight: 600; color: var(--text-heading); margin-bottom: 2px;
}
#responses-meta { font-size: 0.85em; color: var(--text-muted); }
#responses-actions { display: flex; align-items: center; gap: 8px; }
#responses-filter {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-input); color: var(--text-primary); font-family: inherit;
  font-size: 0.88em; min-width: 200px;
}
#responses-filter:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--bg-input-focus); }

#summary-strip {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--bg-surface); border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.summary-stat {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; min-width: 110px;
}
.summary-stat .label {
  font-size: 0.75em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.summary-stat .value {
  font-size: 1.2em; font-weight: 600; color: var(--text-strong); margin-top: 2px;
}

#responses-table-wrap { flex: 1; overflow: auto; padding: 0 20px 20px; }
#responses-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 0.88em; margin-top: 12px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px;
}
#responses-table thead th {
  text-align: left; padding: 10px 12px; background: var(--bg-muted);
  border-bottom: 1px solid var(--border); color: var(--text-heading); font-weight: 600;
  position: sticky; top: 0; z-index: 1; font-size: 0.85em;
  white-space: nowrap;
}
#responses-table tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-light);
  color: var(--text-body); white-space: nowrap; max-width: 240px; overflow: hidden;
  text-overflow: ellipsis;
}
#responses-table tbody tr { cursor: pointer; }
#responses-table tbody tr:hover { background: var(--bg-hover); }
#responses-table tbody tr.active { background: var(--bg-selected); }

.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.78em; font-weight: 500;
}
.status-badge.paid { background: var(--status-paid-bg); color: var(--status-paid-text); }
.status-badge.partial { background: var(--status-pending-bg); color: var(--status-pending-text); }
.status-badge.unpaid { background: var(--status-failed-bg); color: var(--status-failed-text); }
.status-badge.pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.status-badge.confirmed { background: var(--status-paid-bg); color: var(--status-paid-text); }
.status-badge.cancelled { background: var(--status-failed-bg); color: var(--status-failed-text); }

#responses-empty { padding: 40px; text-align: center; color: var(--text-muted); }

/* ── Detail panel ─────────────────────────────────────────────────────── */
#detail-panel {
  background: var(--bg-surface); border-left: 1px solid var(--border);
  display: none; flex-direction: column; overflow: hidden;
}
#app-body.detail-open #detail-panel { display: flex; }
#detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
#detail-header h2 {
  font-size: 1em; font-weight: 600; color: var(--text-heading);
}
#detail-body { flex: 1; overflow-y: auto; padding: 16px 18px; font-size: 0.9em; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin-bottom: 8px; font-weight: 600;
}
.detail-row {
  display: grid; grid-template-columns: 130px 1fr; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border-light);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); font-size: 0.85em; }
.detail-row .value { color: var(--text-strong); word-break: break-word; }

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  #app-body { grid-template-columns: 1fr; }
  #app-body.detail-open { grid-template-columns: 1fr; }
  #side-panel { display: none; }
  #app-body.show-list #side-panel { display: flex; position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; }
  #detail-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 100%; max-width: 380px; z-index: 11; }
}
