/* style.css - Mobile-optimized styles for building cleaning check forms */

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

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --color-disabled: #9ca3af;
  --color-disabled-bg: #f0f0f0;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-border-active: #2563eb;
  --color-white: #ffffff;
  --color-bg: #f3f4f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --tap-target: 44px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
    'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif;
}

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

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== Layout ===== */
.page-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 40px;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ===== Header ===== */
.site-header {
  background: var(--color-primary);
  color: var(--color-white);
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.site-header .header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header .back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target);
  height: var(--tap-target);
  border-radius: var(--radius-sm);
  color: var(--color-white);
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  font-size: 20px;
  flex-shrink: 0;
  text-decoration: none;
}

.site-header .back-btn:hover {
  background: rgba(255,255,255,0.25);
  text-decoration: none;
}

.site-header h1 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  flex: 1;
}

.site-header .header-sub {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
  font-weight: 400;
}

/* ===== Index Page ===== */
.index-hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1e40af 100%);
  color: var(--color-white);
  padding: 32px 16px 28px;
  text-align: center;
}

.index-hero .hero-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.index-hero h1 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.index-hero p {
  font-size: 14px;
  opacity: 0.88;
}

.index-content {
  padding: 20px 16px;
  max-width: 640px;
  margin: 0 auto;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
  padding-left: 2px;
}

.building-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.building-card {
  display: flex;
  align-items: center;
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  min-height: var(--tap-target);
}

.building-card:hover,
.building-card:active {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--color-text);
}

.building-card .card-icon {
  width: 44px;
  height: 44px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  margin-right: 14px;
}

.building-card .card-body {
  flex: 1;
}

.building-card .card-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.building-card .card-slug {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.building-card .card-arrow {
  font-size: 18px;
  color: var(--color-disabled);
  flex-shrink: 0;
  margin-left: 8px;
}

/* ===== Form Page ===== */
.form-date-bar {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--color-text-secondary);
  display: flex;
  gap: 16px;
}

.form-date-bar .date-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.form-date-bar .date-icon {
  font-size: 14px;
}

/* ===== Form Card Sections ===== */
.form-section {
  background: var(--color-white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.form-section-header {
  background: #f8faff;
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-header .section-icon {
  font-size: 18px;
}

.form-section-header .section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
}

.form-section-body {
  padding: 16px;
}

/* ===== Form Fields ===== */
.form-group {
  margin-bottom: 16px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-label .required-mark {
  color: var(--color-danger);
  margin-left: 3px;
}

.form-input,
.form-textarea {
  width: 100%;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 16px;
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-input[readonly] {
  background: #f8f9fa;
  color: var(--color-text-secondary);
  cursor: default;
}

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

/* ===== Checklist ===== */
.checklist-stats {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: #f8faff;
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  flex-wrap: wrap;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 600;
}

.stat-badge.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.stat-badge.inactive {
  background: #f0f0f0;
  color: var(--color-disabled);
}

.checklist-items {
  padding: 8px 0;
}

.check-item {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  transition: background 0.15s;
}

.check-item:last-child {
  border-bottom: none;
}

.check-item.active-item {
  background: var(--color-white);
}

.check-item.active-item:hover {
  background: #fafbff;
}

.check-item.inactive-item {
  background: var(--color-disabled-bg);
}

.check-item-checkbox {
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
}

.check-item-checkbox input[type="checkbox"] {
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 5px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-white);
  transition: background 0.15s, border-color 0.15s;
  display: block;
  position: relative;
}

.check-item-checkbox input[type="checkbox"]:checked {
  background: var(--color-success);
  border-color: var(--color-success);
}

.check-item-checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 8px;
  height: 13px;
  border: 2.5px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.check-item-checkbox input[type="checkbox"]:disabled {
  background: #e5e7eb;
  border-color: #d1d5db;
  cursor: not-allowed;
}

.check-item-content {
  flex: 1;
  min-width: 0;
}

.check-location {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
  color: var(--color-text);
  line-height: 1.4;
}

.inactive-item .check-location {
  color: var(--color-disabled);
}

.check-tasks {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.inactive-item .check-tasks {
  color: #b0b7c3;
}

.check-schedule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
}

.active-item .check-schedule {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.inactive-item .check-schedule {
  background: #e5e7eb;
  color: var(--color-disabled);
}

.inactive-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: #e5e7eb;
  color: var(--color-disabled);
  letter-spacing: 0.02em;
}

.check-item-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

/* ===== Check Groups (location header + sub-items) ===== */
.check-group {
  border-bottom: 2px solid var(--color-border);
  overflow: hidden;
}

.check-group:last-child {
  border-bottom: none;
}

.check-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  background: #eef2ff;
  border-bottom: 1px solid #c7d2fe;
  gap: 8px;
}

.check-group.all-inactive .check-group-header {
  background: #f0f0f0;
  border-bottom-color: var(--color-border);
}

.check-group-location {
  font-size: 13px;
  font-weight: 700;
  color: #3730a3;
}

.check-group.all-inactive .check-group-location {
  color: var(--color-disabled);
}

.check-subitem {
  display: flex;
  align-items: center;
  padding: 11px 16px 11px 28px;
  border-bottom: 1px solid #f3f4f6;
  gap: 10px;
  transition: background 0.15s;
}

.check-subitem:last-child {
  border-bottom: none;
}

.check-subitem.active-subitem {
  background: var(--color-white);
  cursor: pointer;
}

.check-subitem.active-subitem:hover,
.check-subitem.active-subitem:active {
  background: #f5f7ff;
}

.check-subitem.inactive-subitem {
  background: var(--color-disabled-bg);
  cursor: pointer;
}

.check-subitem.inactive-subitem:hover,
.check-subitem.inactive-subitem:active {
  background: #e8e8e8;
}

.check-subitem-content {
  flex: 1;
  min-width: 0;
}

.check-task {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.4;
}

.inactive-subitem .check-task {
  color: var(--color-disabled);
}

.check-subitem .check-schedule {
  flex-shrink: 0;
}

/* ===== Photo Upload ===== */
.photo-upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fafafa;
}

.photo-upload-area:hover,
.photo-upload-area.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.photo-upload-area .upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
  display: block;
}

.photo-upload-area .upload-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.photo-upload-area .upload-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
}

#photo-input {
  display: none;
}

.photo-previews {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.photo-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f0f0f0;
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-preview-item .remove-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.photo-preview-item .upload-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.02em;
}

.upload-status.uploading {
  background: rgba(37,99,235,0.85);
  color: white;
}

.upload-status.done {
  background: rgba(22,163,74,0.85);
  color: white;
}

.upload-status.error {
  background: rgba(220,38,38,0.85);
  color: white;
}

/* ===== Submit Button ===== */
.submit-btn {
  width: 100%;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  font-family: var(--font-family);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-target);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
  letter-spacing: 0.02em;
}

.submit-btn:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}

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

.submit-btn:disabled {
  background: var(--color-disabled);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.submit-btn .btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== Success Screen ===== */
.success-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  min-height: 60vh;
}

.success-screen.visible {
  display: flex;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: var(--color-success-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 20px;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--color-success);
  margin-bottom: 10px;
}

.success-message {
  font-size: 15px;
  color: var(--color-text-secondary);
  margin-bottom: 28px;
  line-height: 1.7;
}

.success-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-white);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  text-decoration: none;
}

.success-back-btn:hover {
  background: var(--color-primary-light);
  text-decoration: none;
}

/* ===== Error Messages ===== */
.error-message {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--color-danger);
  margin-top: 12px;
}

.error-message.visible {
  display: block;
}

/* ===== 404 / Not Found ===== */
.not-found {
  text-align: center;
  padding: 60px 24px;
}

.not-found .nf-icon {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
}

.not-found h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.not-found p {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

/* ===== Utility ===== */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--color-text-secondary); }
.hidden { display: none !important; }

/* ===== Loading Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ===== Responsive Fine-tuning ===== */
@media (max-width: 380px) {
  .photo-previews {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-header h1 {
    font-size: 15px;
  }
}

@media (min-width: 641px) {
  .page-wrapper,
  .container,
  .index-content,
  .site-header .header-inner {
    max-width: 680px;
  }
}

/* ===== Print (hide nav/header for potential printing) ===== */
@media print {
  .site-header,
  .submit-btn,
  .photo-upload-area {
    display: none;
  }
}
