/* Safety Inspection Styles — Mobile-First */

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f0f2f5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Inspection Header
   ======================================== */
.inspect-header {
  background: #1a3a5c;
  color: #ffffff;
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.inspect-header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-date {
  font-size: 0.95rem;
  opacity: 0.85;
  font-weight: 400;
}

/* ========================================
   Main Content
   ======================================== */
.inspect-main {
  padding: 12px 12px 90px;
  max-width: 640px;
  margin: 0 auto;
}

/* ========================================
   Form Sections
   ======================================== */
.form-section {
  background: #ffffff;
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a3a5c;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 2px solid #e8ecf0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b7c93;
  background: #f0f2f5;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ========================================
   Operator Info
   ======================================== */
.operator-info {
  margin-bottom: 10px;
}

.operator-info:last-child {
  margin-bottom: 0;
}

.operator-info label,
.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.operator-info input,
.form-field input,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1.5px solid #d1d8e0;
  border-radius: 8px;
  background: #fafbfc;
  color: #1a1a1a;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.operator-info input:focus,
.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #ffffff;
}

.operator-info input[readonly] {
  background: #eef1f5;
  color: #4a5568;
}

.form-field {
  margin-bottom: 10px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* ========================================
   Accordion Items
   ======================================== */
.accordion-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.accordion-item {
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

/* Pending state (default) */
.accordion-item.pending .accordion-header {
  background: #eef1f5;
  color: #4a5568;
}

/* Active state (blue border) */
.accordion-item.active {
  box-shadow: 0 0 0 2px #3b82f6, 0 2px 8px rgba(59, 130, 246, 0.15);
}

.accordion-item.active .accordion-header {
  background: #eff6ff;
  color: #1a3a5c;
}

/* Completed Good (green) */
.accordion-item.completed-good .accordion-header {
  background: #dcfce7;
  color: #166534;
}

/* Completed N/S (amber) */
.accordion-item.completed-ns .accordion-header {
  background: #fef3c7;
  color: #92400e;
}

/* Completed N/A (gray) */
.accordion-item.completed-na .accordion-header {
  background: #e5e7eb;
  color: #4b5563;
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: 48px;
  transition: background 0.2s;
}

.accordion-header:active {
  opacity: 0.85;
}

.accordion-label {
  font-size: 0.92rem;
  font-weight: 500;
  flex: 1;
  margin-right: 8px;
}

.accordion-item-number {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7c93;
  margin-right: 8px;
  min-width: 22px;
}

.accordion-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-good {
  background: #16a34a;
  color: #ffffff;
}

.badge-ns {
  background: #d97706;
  color: #ffffff;
}

.badge-na {
  background: #6b7280;
  color: #ffffff;
}

/* Accordion Body */
.accordion-body {
  display: none;
  padding: 12px 14px 14px;
  background: #ffffff;
  border-top: 1px solid #e8ecf0;
}

.accordion-item.active .accordion-body {
  display: block;
}

/* Answer Buttons */
.answer-buttons {
  display: flex;
  gap: 8px;
}

.btn-good,
.btn-ns,
.btn-na {
  flex: 1;
  min-height: 52px;
  font-size: 0.95rem;
  font-weight: 700;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  -webkit-appearance: none;
  appearance: none;
}

.btn-good:active,
.btn-ns:active,
.btn-na:active {
  transform: scale(0.96);
}

.btn-good {
  background: #16a34a;
  color: #ffffff;
}

.btn-good:hover {
  background: #15803d;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}

.btn-ns {
  background: #d97706;
  color: #ffffff;
}

.btn-ns:hover {
  background: #b45309;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
}

.btn-na {
  background: #6b7280;
  color: #ffffff;
}

.btn-na:hover {
  background: #4b5563;
  box-shadow: 0 2px 6px rgba(107, 114, 128, 0.3);
}

/* Notes field in operational items */
.item-notes {
  margin-top: 10px;
}

.item-notes label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
  display: block;
}

.item-notes textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1.5px solid #d1d8e0;
  border-radius: 8px;
  background: #fafbfc;
  color: #1a1a1a;
  resize: vertical;
  min-height: 50px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.item-notes textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #ffffff;
}

/* ========================================
   Submit Button
   ======================================== */
.submit-section {
  padding: 16px 14px;
}

.btn-submit {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  background: #1a3a5c;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 52px;
}

.btn-submit:hover {
  background: #1e4a73;
}

.btn-submit:active {
  transform: scale(0.98);
}

.btn-submit:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* ========================================
   Progress Bar (Sticky Bottom)
   ======================================== */
.progress-bar-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  padding: 8px 16px 12px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.progress-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
  text-align: center;
}

.progress-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #16a34a);
  border-radius: 3px;
  transition: width 0.35s ease;
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: 14px;
  padding: 28px 24px 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  line-height: 1;
}

.modal-icon.success {
  color: #16a34a;
}

.modal-icon.error {
  color: #dc2626;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.modal-message {
  font-size: 0.9rem;
  color: #4a5568;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-btn {
  display: inline-block;
  padding: 12px 40px;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: #1a3a5c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.2s;
}

.modal-btn:hover {
  background: #1e4a73;
}

/* ========================================
   Admin Panel Styles
   ======================================== */

/* Login page */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-page .login-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-page .login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a3a5c;
  margin-bottom: 6px;
}

.login-page .login-card p {
  font-size: 0.9rem;
  color: #6b7c93;
  margin-bottom: 24px;
}

.login-page .login-card label {
  display: block;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.login-page .login-card input {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1.5px solid #d1d8e0;
  border-radius: 8px;
  margin-bottom: 16px;
  background: #fafbfc;
  -webkit-appearance: none;
  appearance: none;
}

.login-page .login-card input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-page .login-card button {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background: #1a3a5c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.2s;
}

.login-page .login-card button:hover {
  background: #1e4a73;
}

.login-page .login-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-top: 10px;
  display: none;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  background: #ffffff;
  border-bottom: 2px solid #e8ecf0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px;
}

.admin-tab {
  flex: 0 0 auto;
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #6b7c93;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
}

.admin-tab:hover {
  color: #1a3a5c;
}

.admin-tab.active {
  color: #1a3a5c;
  border-bottom-color: #3b82f6;
}

.admin-panel {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 12px;
}

.admin-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.admin-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1a3a5c;
  margin-bottom: 12px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* QR Code result */
.qr-result {
  text-align: center;
  padding: 16px;
}

.qr-result img {
  max-width: 240px;
  width: 100%;
  height: auto;
  border: 2px solid #e8ecf0;
  border-radius: 8px;
  margin-bottom: 12px;
}

.qr-result .qr-url {
  font-size: 0.82rem;
  color: #4a5568;
  word-break: break-all;
  margin-bottom: 12px;
}

.qr-result .btn-download {
  display: inline-block;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
  background: #1a3a5c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}

/* Email list */
.email-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
}

.email-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #fafbfc;
  border: 1px solid #e8ecf0;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.email-list li .email-address {
  flex: 1;
  word-break: break-all;
  margin-right: 8px;
}

.email-list li .btn-remove {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  min-height: 32px;
}

.email-list li .btn-remove:hover {
  background: #fee2e2;
}

.email-add {
  display: flex;
  gap: 8px;
}

.email-add input {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1.5px solid #d1d8e0;
  border-radius: 8px;
  background: #fafbfc;
  -webkit-appearance: none;
  appearance: none;
}

.email-add input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.email-add button {
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
  background: #16a34a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
}

/* SMTP form */
.smtp-form .form-row {
  margin-bottom: 12px;
}

.smtp-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.smtp-form input,
.smtp-form select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1.5px solid #d1d8e0;
  border-radius: 8px;
  background: #fafbfc;
  -webkit-appearance: none;
  appearance: none;
}

.smtp-form input:focus,
.smtp-form select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.smtp-form .btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.smtp-form .btn-save {
  flex: 1;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background: #1a3a5c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 48px;
}

.smtp-form .btn-test {
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a3a5c;
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  border-radius: 8px;
  cursor: pointer;
  min-height: 48px;
}

/* Admin status messages */
.admin-status {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-top: 10px;
  display: none;
}

.admin-status.success {
  background: #dcfce7;
  color: #166534;
  display: block;
}

.admin-status.error {
  background: #fef2f2;
  color: #991b1b;
  display: block;
}

/* ========================================
   Tablet Breakpoint (min-width: 600px)
   ======================================== */
@media (min-width: 600px) {
  .inspect-header {
    padding: 20px 24px 18px;
  }

  .inspect-header h1 {
    font-size: 1.35rem;
  }

  .header-date {
    font-size: 1.05rem;
  }

  .inspect-main {
    padding: 20px 20px 100px;
    max-width: 680px;
  }

  .form-section {
    padding: 18px;
    margin-bottom: 16px;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .accordion-header {
    padding: 14px 16px;
  }

  .accordion-label {
    font-size: 0.95rem;
  }

  .answer-buttons {
    gap: 10px;
  }

  .btn-good,
  .btn-ns,
  .btn-na {
    min-height: 56px;
    font-size: 1rem;
  }

  .progress-bar-container {
    padding: 10px 24px 14px;
  }

  .progress-text {
    font-size: 0.85rem;
  }

  .progress-track {
    height: 8px;
  }

  .admin-panel {
    padding: 24px 20px;
  }
}

/* ========================================
   Large Tablet / Desktop (min-width: 900px)
   ======================================== */
@media (min-width: 900px) {
  .inspect-main {
    max-width: 720px;
    padding: 28px 24px 110px;
  }

  .form-section {
    padding: 22px;
  }

  .answer-buttons {
    max-width: 480px;
  }

  .admin-panel {
    max-width: 800px;
  }

  .admin-tabs {
    justify-content: center;
  }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
  body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  .inspect-header {
    position: static;
    background: none;
    color: #000000;
    border-bottom: 2px solid #000000;
    padding: 8px 0;
    box-shadow: none;
  }

  .inspect-main {
    padding: 0;
    max-width: 100%;
  }

  .form-section {
    box-shadow: none;
    border: 1px solid #cccccc;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .progress-bar-container {
    display: none;
  }

  .modal-overlay {
    display: none !important;
  }

  .btn-submit {
    display: none;
  }

  .accordion-item .accordion-body {
    display: none;
  }

  .accordion-header {
    min-height: auto;
    padding: 6px 10px;
  }

  .accordion-badge {
    border: 1px solid #000000;
  }

  .answer-buttons {
    display: none;
  }

  .item-notes textarea {
    border: 1px solid #cccccc;
  }
}
