/* ── Reset & Base ───────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:      #1F4E79;
  --blue-mid:  #2E75B6;
  --blue-light:#EBF3FB;
  --green:     #28a745;
  --green-bg:  #d4edda;
  --red:       #dc3545;
  --red-bg:    #f8d7da;
  --orange:    #fd7e14;
  --grey:      #6c757d;
  --grey-light:#f4f6f9;
  --border:    #dee2e6;
  --white:     #ffffff;
  --text:      #212529;
  --shadow:    0 2px 12px rgba(0,0,0,0.08);
  --radius:    12px;
}

html, body {
  height: 100%;
  font-family: Arial, sans-serif;
  background: var(--grey-light);
  color: var(--text);
  font-size: 16px;
}

/* ── App Shell ──────────────────────────────────────────────── */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--blue);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-header .back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.app-header .back-btn.visible { display: flex; }
.app-header .header-title { flex: 1; }
.app-header h1 { font-size: 17px; font-weight: bold; }
.app-header .header-sub { font-size: 12px; opacity: 0.75; margin-top: 2px; }

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar-wrap {
  background: rgba(255,255,255,0.2);
  height: 4px;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}
.progress-bar-fill {
  height: 100%;
  background: #90CAF9;
  transition: width 0.4s ease;
}

/* ── Screen Container ───────────────────────────────────────── */
.screen {
  display: none;
  flex: 1;
  padding: 20px 16px 32px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.25s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 15px;
  font-weight: bold;
  color: var(--blue);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--blue-light);
}

/* ── Form Elements ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  color: #555;
  margin-bottom: 6px;
}
.form-group label .required { color: var(--red); margin-left: 2px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: Arial, sans-serif;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(46,117,182,0.12);
}
.form-group textarea {
  min-height: 90px;
  resize: vertical;
}
.form-group .hint {
  font-size: 12px;
  color: var(--grey);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { flex: 1; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
  margin-bottom: 10px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary  { background: var(--blue-mid); color: white; }
.btn-success  { background: var(--green);    color: white; }
.btn-danger   { background: var(--red);      color: white; }
.btn-outline  {
  background: white;
  color: var(--blue-mid);
  border: 2px solid var(--blue-mid);
}
.btn-grey {
  background: var(--grey-light);
  color: var(--grey);
  border: 1.5px solid var(--border);
}

/* ── Toggle (Solved / Unsolved) ─────────────────────────────── */
.status-toggle {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  margin-bottom: 0;
}
.status-toggle input[type="radio"] { display: none; }
.status-toggle label {
  flex: 1;
  padding: 13px;
  text-align: center;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  background: white;
  color: var(--grey);
  transition: all 0.2s;
  border: none;
  margin: 0;
}
#status-solved:checked   ~ .toggle-labels .label-solved,
.status-toggle input#status-solved:checked   + label { background: var(--green); color: white; }
#status-unsolved:checked ~ .toggle-labels .label-unsolved,
.status-toggle input#status-unsolved:checked + label { background: var(--red);   color: white; }

.toggle-wrap {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
}
.toggle-wrap .toggle-opt {
  flex: 1;
  padding: 13px;
  text-align: center;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  background: white;
  color: var(--grey);
  transition: all 0.2s;
  border: none;
  user-select: none;
}
.toggle-wrap .toggle-opt.active-solved   { background: var(--green); color: white; }
.toggle-wrap .toggle-opt.active-unsolved { background: var(--red);   color: white; }

/* ── Ticket Cards ───────────────────────────────────────────── */
.ticket-item {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.ticket-item:hover { border-color: var(--blue-mid); box-shadow: var(--shadow); }
.ticket-item .ticket-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.ticket-item.fsr-done .ticket-icon { background: var(--green-bg); color: var(--green); }
.ticket-item .ticket-info { flex: 1; min-width: 0; }
.ticket-item .ticket-num {
  font-size: 12px;
  font-weight: bold;
  color: var(--blue-mid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ticket-item .ticket-subject {
  font-size: 14px;
  font-weight: bold;
  color: var(--text);
  margin: 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-item .ticket-meta {
  font-size: 12px;
  color: var(--grey);
}
.ticket-item .ticket-arrow {
  font-size: 20px;
  color: var(--border);
  align-self: center;
}
.ticket-item.fsr-done { opacity: 0.65; }
.badge-done {
  display: inline-block;
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: bold;
  margin-top: 3px;
}

/* ── Photo Upload ───────────────────────────────────────────── */
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--grey);
  font-size: 14px;
}
.photo-upload-area:hover { border-color: var(--blue-mid); background: var(--blue-light); }
.photo-upload-area .upload-icon { font-size: 32px; margin-bottom: 8px; }
#photo-input { display: none; }

.photo-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.photo-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--border);
  position: relative;
}
.photo-thumb-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}
.photo-thumb-wrap .remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Signature Pad ──────────────────────────────────────────── */
.signature-wrap {
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: white;
}
#signature-canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
  cursor: crosshair;
}
.signature-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn-sm {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  border-radius: 8px;
  margin: 0;
}
.sig-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #bbb;
  font-size: 14px;
  pointer-events: none;
}

/* ── Summary Box ────────────────────────────────────────────── */
.summary-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--grey-light);
  font-size: 14px;
  gap: 10px;
}
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--grey); min-width: 120px; font-size: 13px; flex-shrink: 0; }
.summary-value { color: var(--text); font-weight: 500; flex: 1; }

/* ── Alert / Messages ───────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}
.alert-error   { background: var(--red-bg);   color: #721c24; }
.alert-success { background: var(--green-bg); color: #155724; }
.alert-info    { background: var(--blue-light); color: var(--blue); }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner-wrap {
  text-align: center;
  padding: 40px;
  color: var(--grey);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--blue-mid);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Confirmation Screen ────────────────────────────────────── */
.confirm-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  font-size: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto 16px;
}
.confirm-title {
  text-align: center;
  font-size: 22px;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 6px;
}
.confirm-sub {
  text-align: center;
  color: var(--grey);
  font-size: 14px;
  margin-bottom: 24px;
}
.fsr-ref {
  text-align: center;
  background: var(--blue-light);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.fsr-ref .ref-label { font-size: 12px; color: var(--grey); text-transform: uppercase; }
.fsr-ref .ref-num   { font-size: 28px; font-weight: bold; color: var(--blue); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--grey);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Section Divider ────────────────────────────────────────── */
.section-label {
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--grey);
  margin: 20px 0 10px;
}

/* ── PMS Checklist ───────────────────────────────────────────── */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--dark);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--light-grey);
  transition: background 0.15s;
}

.check-item:hover { background: #e8f0fe; }

.check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue-mid);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── PMS AC Card ─────────────────────────────────────────────── */
.ac-card {
  background: var(--light-grey);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-left: 4px solid var(--blue-mid);
}

.ac-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 400px) {
  .screen { padding: 12px 10px 28px; }
  .card   { padding: 16px; }
  .form-row { flex-direction: column; gap: 0; }
  #signature-canvas { height: 150px; }
}
