/* FireTag - Mobile-First Styles */

:root {
  --primary: #4a6270;
  --primary-dark: #3a4e5a;
  --secondary: #616161;
  --success: #7cb342;
  --warning: #c2974e;
  --danger: #e57373;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #212121;
  --text-light: #757575;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Loading Spinner */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  margin-top: 16px;
  color: var(--text-light);
  font-size: 16px;
}

/* Header */
header {
  background: var(--primary);
  color: white;
  padding: 16px;
  box-shadow: var(--shadow);
}

header h1 {
  margin: 0 0 16px 0;
  font-size: 24px;
  font-weight: 700;
}

.form-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-header h1 {
  margin: 0;
  font-size: 20px;
}

.btn-back {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-back:active {
  background: rgba(255, 255, 255, 0.3);
}

/* Vehicle Card */
.vehicle-card {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  backdrop-filter: blur(10px);
}

.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.apparatus-id {
  font-size: 24px;
  font-weight: 700;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.3);
}

.status-badge.status-active {
  background: var(--success);
}

.status-badge.status-out_of_service {
  background: var(--danger);
}

.status-badge.status-in_repair {
  background: var(--warning);
}

.status-badge.status-open {
  background: var(--warning);
  color: white;
}

.status-badge.status-closed {
  background: var(--success);
  color: white;
}

.status-badge.status-passed {
  background: #4caf50;
  color: white;
}

.status-badge.status-failed {
  background: #f44336;
  color: white;
}

.vehicle-details {
  color: rgba(255, 255, 255, 0.95);
}

.vehicle-details p {
  margin: 6px 0;
  font-size: 14px;
}

.vehicle-details strong {
  font-weight: 600;
  margin-right: 6px;
}

/* Main Content */
main {
  padding: 20px 16px;
  max-width: 800px;
  margin: 0 auto;
}

main h2 {
  font-size: 20px;
  margin: 0 0 20px 0;
  color: var(--text);
}

main h3 {
  font-size: 18px;
  margin: 24px 0 12px 0;
  color: var(--text);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.btn {
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:active {
  background: #e65100;
  transform: scale(0.98);
}

.btn-submit {
  width: 100%;
  margin-top: 24px;
  justify-content: center;
  font-size: 18px;
  padding: 18px 24px;
  background: var(--primary);
  color: white;
}

.btn-submit:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

/* Recent Activity */
.recent-activity {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  padding: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.activity-type {
  font-weight: 600;
  font-size: 14px;
}

.activity-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: capitalize;
}

.activity-status.status-passed,
.activity-status.status-completed {
  background: #f0f0f0;
  color: #5a7a3f;
}

.activity-status.status-failed {
  background: #f0f0f0;
  color: #a85858;
}

.activity-status.status-open,
.activity-status.status-pending {
  background: #fff3e0;
  color: var(--warning);
}

.activity-meta {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  gap: 6px;
}

.no-activity {
  text-align: center;
  color: var(--text-light);
  padding: 20px;
}

/* Forms */
.inspection-form {
  padding: 20px 16px;
  max-width: 800px;
  margin: 0 auto;
}

.form-section {
  margin-bottom: 24px;
  background: var(--card-bg);
  padding: 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.form-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
}

.form-section input[type="text"],
.form-section input[type="number"],
.form-section input[type="tel"],
.form-section input[type="date"],
.form-section select,
.form-section textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
  min-height: 48px;
}

.form-section input:focus,
.form-section select:focus,
.form-section textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-section textarea {
  resize: vertical;
  min-height: 100px;
}

.form-help {
  font-size: 13px;
  color: var(--text-light);
  margin: -4px 0 12px 0;
}

/* Checklist Items */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checklist-item {
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.item-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
}

.radio-group {
  display: flex;
  gap: 8px;
}

.radio-option {
  flex: 1;
  position: relative;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.radio-label {
  display: block;
  padding: 10px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.radio-option input:checked + .radio-label {
  border-width: 3px;
}

.radio-label.pass {
  color: var(--success);
}

.radio-option input:checked + .radio-label.pass {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.radio-label.fail {
  color: var(--danger);
}

.radio-option input:checked + .radio-label.fail {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.radio-label.na {
  color: var(--text-light);
}

.radio-option input:checked + .radio-label.na {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

/* Monthly Inspection Items */
.monthly-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.monthly-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  position: relative;
}

.monthly-item-header {
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-label {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-label.status-ok {
  background: var(--success);
  color: white;
}

.status-label.status-needs_repair {
  background: var(--warning);
  color: white;
}

.status-label.status-out_of_service {
  background: var(--danger);
  color: white;
}

.status-label.status-na {
  background: var(--secondary);
  color: white;
}

.monthly-item-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.radio-group-compact {
  display: flex;
  gap: 4px;
}

.radio-label-sm {
  display: block;
  width: 36px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.radio-option input:checked + .radio-label-sm.ok {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.radio-option input:checked + .radio-label-sm.needs-repair {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}

.radio-option input:checked + .radio-label-sm.out-of-service {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.radio-option input:checked + .radio-label-sm.na {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.remarks-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.remarks-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Notification Banner */
.notification-banner {
  padding: 16px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 16px;
  line-height: 1.6;
  box-shadow: var(--shadow);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.notification-banner.success {
  background: #e8f5e9;
  border-left: 4px solid var(--success);
  color: #2e7d32;
}

.notification-banner.failed {
  background: #fff3e0;
  border-left: 4px solid var(--warning);
  color: #e65100;
}

.notification-banner strong {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.notification-banner p {
  margin: 8px 0 0 0;
}

.notification-banner .repair-suggestion {
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.notification-banner .repair-suggestion strong {
  font-size: 14px;
  margin-bottom: 6px;
}

.notification-banner button {
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--warning);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.notification-banner button:active {
  background: #e65100;
}

.notification-banner .close-btn {
  float: right;
  background: none;
  color: inherit;
  font-size: 20px;
  padding: 0;
  width: 24px;
  height: 24px;
  line-height: 24px;
  margin: -4px -4px 0 0;
  opacity: 0.6;
}

.notification-banner .close-btn:hover {
  opacity: 1;
  background: none;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: white;
  font-weight: 700;
}

.error-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: var(--danger);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: white;
  font-weight: 700;
}

.modal-content h2 {
  margin: 0 0 12px 0;
  font-size: 24px;
}

.modal-content p {
  margin: 0 0 24px 0;
  color: var(--text-light);
  font-size: 16px;
}

/* Reports View */
.reports-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.report-header > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-type {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.report-date {
  font-size: 13px;
  color: var(--text-light);
}

.report-details {
  color: var(--text);
}

.report-details p {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.5;
}

.report-details strong {
  font-weight: 600;
  margin-right: 6px;
}

.priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.priority-badge.priority-urgent {
  background: #ffebee;
  color: var(--danger);
}

.priority-badge.priority-high {
  background: #fff3e0;
  color: var(--warning);
}

.priority-badge.priority-normal {
  background: #e3f2fd;
  color: #1976d2;
}

.priority-badge.priority-low {
  background: #f5f5f5;
  color: var(--text-light);
}

/* Report Detail View */
.report-detail-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #1565c0 100%);
  color: white;
  border-bottom: 4px solid rgba(255, 255, 255, 0.2);
}

.detail-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.detail-section {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.detail-section:last-child {
  border-bottom: none;
}

.detail-section h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.detail-grid div {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.detail-grid strong {
  display: block;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Issues Section */
.issues-section {
  background: #fff3e0;
  border-left: 4px solid var(--warning);
}

.issues-section h3 {
  color: var(--warning);
}

.issues-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.issues-list li {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: white;
  border-radius: 8px;
  border-left: 3px solid var(--warning);
  font-weight: 500;
  color: var(--text);
}

.issue-item {
  padding: 12px;
  margin-bottom: 12px;
  background: white;
  border-radius: 8px;
  border-left: 3px solid var(--warning);
}

.issue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

.issue-remarks {
  font-size: 13px;
  color: var(--text-light);
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

/* Notes Section */
.notes-section {
  background: #e3f2fd;
  border-left: 4px solid #1976d2;
}

.notes-section h3 {
  color: #1976d2;
}

.notes-text {
  padding: 16px;
  background: white;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Inspection Items Table */
.inspection-items-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.inspection-items-table thead {
  background: var(--primary);
  color: white;
}

.inspection-items-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.inspection-items-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

.inspection-items-table tbody tr:last-child td {
  border-bottom: none;
}

.inspection-items-table tbody tr:hover {
  background: #f5f5f5;
}

/* Item Status Badges */
.item-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.item-status.status-pass {
  background: #e8f5e9;
  color: var(--success);
}

.item-status.status-fail {
  background: #ffebee;
  color: var(--danger);
}

.item-status.status-na {
  background: #f5f5f5;
  color: var(--text-light);
}

.item-status.status-needs_repair {
  background: #fff3e0;
  color: var(--warning);
}

/* Vehicle Selection */
.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  margin: 0;
  font-weight: 400;
}

.vehicle-list-section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.vehicle-list-section h2 {
  margin-top: 0;
  font-size: 18px;
  color: var(--text);
}

.vehicle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.station-header {
  font-size: 16px;
  color: var(--text-light);
  margin: 16px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--border);
}

.station-header:first-child {
  margin-top: 0;
}

.vehicle-card-selectable {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
}

.vehicle-card-selectable:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.vehicle-card-selectable:active {
  transform: translateY(0);
}

.vehicle-card-selectable .vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.vehicle-card-selectable .apparatus-id {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.vehicle-card-selectable .vehicle-details {
  color: var(--text);
}

.vehicle-card-selectable .vehicle-details p {
  margin: 4px 0;
  font-size: 14px;
}

.loading-text {
  text-align: center;
  color: var(--text-light);
  padding: 20px;
  font-style: italic;
}

.no-vehicles {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
  font-size: 16px;
}

.error-text {
  text-align: center;
  color: var(--danger);
  padding: 20px;
  font-weight: 600;
}

/* Repair Order Form Grid Layouts */
.repair-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.repair-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.repair-grid-2-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.repair-grid-field {
  display: flex;
  flex-direction: column;
}

.repair-grid-field label {
  margin-bottom: 4px;
  font-weight: 500;
  font-size: 14px;
}

.repair-grid-field input[type="date"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  line-height: normal;
}

/* Responsive */
@media (min-width: 768px) {
  .action-buttons {
    flex-direction: row;
  }

  .btn {
    flex: 1;
  }

  .monthly-item-fields {
    grid-template-columns: auto 1fr;
  }

  /* Repair order grids on tablet and up */
  .repair-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .repair-grid-2 {
    grid-template-columns: 1fr 2fr;
  }

  .repair-grid-2-1 {
    grid-template-columns: 2fr 1fr;
  }
}

/* Print Styles */
@media print {
  .btn-back,
  .action-buttons,
  .btn-submit {
    display: none;
  }

  body {
    background: white;
  }

  .form-section {
    box-shadow: none;
    border: 1px solid var(--border);
  }
}
