/* CSKH — main.css mobile-first */
:root {
  --navy: #1B2A4A;
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --green: #2e7d32;
  --orange: #f57c00;
  --red: #c62828;
  --yellow: #fbc02d;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --required-bg: #fff3e0;
  --critical: #ffebee;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* Header */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 { font-size: 16px; margin: 0; }
.app-header .user { font-size: 12px; opacity: 0.85; }
.app-header a { color: #fff; text-decoration: none; }

/* Container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue);
  margin: 0 0 12px;
  border-bottom: 2px solid var(--blue);
  padding-bottom: 6px;
}

/* Form fields */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 13px;
}
label .required { color: var(--red); margin-left: 2px; }
.hint { color: var(--text-muted); font-size: 12px; font-weight: normal; margin-left: 4px; }

input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
  border-color: var(--blue);
}
input[readonly] { background: #f9fafb; color: var(--text-muted); }
textarea { min-height: 80px; resize: vertical; }

.field { margin-bottom: 14px; }
.field.required input:invalid:not(:placeholder-shown),
.field.required select:invalid {
  border-color: var(--red);
  background: var(--required-bg);
}

.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) {
  .row.two { grid-template-columns: 1fr 1fr; }
  .row.three { grid-template-columns: 1fr 1fr 1fr; }
}

/* Star rating */
.rating { display: flex; gap: 6px; }
.rating input[type=radio] { display: none; }
.rating label.star {
  display: inline-block;
  font-size: 28px;
  cursor: pointer;
  color: #d0d0d0;
  padding: 4px 6px;
  margin: 0;
  font-weight: normal;
}
.rating input[type=radio]:checked ~ label.star,
.rating label.star.active { color: var(--yellow); }
.rating label.star:hover,
.rating label.star:hover ~ label.star { color: var(--yellow); }

/* Checkbox group (multi-select) */
.checkbox-group {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}
@media (min-width: 600px) {
  .checkbox-group { grid-template-columns: 1fr 1fr; }
}
.checkbox-group label.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.1s;
}
.checkbox-group label.chip:hover { background: #f3f4f6; }
.checkbox-group label.chip.checked {
  background: #e3f2fd;
  border-color: var(--blue);
}
.checkbox-group label.chip.critical.checked { background: var(--critical); border-color: var(--red); }
.checkbox-group label.chip input { width: auto; }
.checkbox-group label.chip .badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  margin-left: auto;
}

/* Cause group with category headers */
.cause-group .cause-cat {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 12px;
  margin-bottom: 4px;
  grid-column: 1 / -1;
}

/* Photo upload */
.photo-upload {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  background: #fafbfc;
}
.photo-upload:hover { border-color: var(--blue); background: #f0f7ff; }
.photo-upload input[type=file] { display: none; }
.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(198,40,40,0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-warn { background: var(--orange); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); }

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.actions .btn { flex: 1; }
@media (min-width: 600px) {
  .actions .btn { flex: 0 0 auto; min-width: 140px; }
}

/* Status badges */
.badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-status.open { background: #fef3c7; color: #92400e; }
.badge-status.sm_responding { background: #dbeafe; color: #1e40af; }
.badge-status.cskh_review { background: #e0e7ff; color: #3730a3; }
.badge-status.escalated { background: #fee2e2; color: #991b1b; }
.badge-status.bom_responding { background: #fce7f3; color: #9d174d; }
.badge-status.cskh_review_2 { background: #ddd6fe; color: #5b21b6; }
.badge-status.closed { background: #d1fae5; color: #065f46; }

.badge-sla { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.badge-sla.lvl0 { background: #d1fae5; color: #065f46; }
.badge-sla.lvl1 { background: #fef3c7; color: #92400e; }
.badge-sla.lvl2 { background: #fed7aa; color: #9a3412; }
.badge-sla.lvl3 { background: #fee2e2; color: #991b1b; }

/* Toasts */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: 6px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  max-width: 90%;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* Loading */
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid #ccc; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* List view */
.complaint-row {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}
.complaint-row:hover { box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.complaint-row .row-head { display: flex; justify-content: space-between; align-items: center; }
.complaint-row .row-head strong { font-size: 13px; }
.complaint-row .row-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Filter bar */
.filter-bar {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 12px;
}
@media (min-width: 600px) { .filter-bar { grid-template-columns: repeat(4, 1fr); } }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
