/* ===== Forget Me Not — Stylesheet ===== */
/* Mobile-first PWA design */

:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D9;
  --primary-light: #8B83FF;
  --bg: #F5F5FA;
  --card-bg: #FFFFFF;
  --text: #1A1A2E;
  --text-muted: #8E8E93;
  --border: #E5E5EA;
  --success: #34C759;
  --danger: #FF3B30;
  --warning: #FF9500;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: calc(var(--safe-top) + 16px) 16px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(108,99,255,0.3);
}

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

.header-top h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 1.1rem;
}

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

/* Mode Toggle */
.mode-toggle {
  display: flex;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  padding: 10px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
}

.mode-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* Progress */
.progress-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: white;
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}

/* ===== Main Content ===== */
.checklist-container {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--safe-bottom) + 30px);
}

/* Quick Add */
.quick-add {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-add input[type="text"] {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card-bg);
}

.quick-add input[type="text"]:focus {
  border-color: var(--primary);
}

.quick-add select {
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 0.85rem;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  cursor: pointer;
  max-width: 110px;
}

.add-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.add-btn:active {
  background: var(--primary-dark);
}

/* Template Section */
.template-section {
  position: relative;
  margin-bottom: 16px;
}

.template-btn {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.template-btn:active {
  border-color: var(--primary);
  color: var(--primary);
}

.template-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  overflow: hidden;
  margin-top: 4px;
}

.template-dropdown button {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text);
}

.template-dropdown button:active {
  background: var(--bg);
}

.template-dropdown button:last-child {
  color: var(--danger);
  border-top: 1px solid var(--border);
}

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

.category-group {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.checklist-item:active {
  background: var(--bg);
}

/* Checkbox */
.checkbox {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.checkbox.checked.unpacking-mode {
  background: var(--warning);
  border-color: var(--warning);
}

.checkbox svg {
  opacity: 0;
  transition: opacity 0.2s;
}

.checkbox.checked svg {
  opacity: 1;
}

/* Item Text */
.item-text {
  flex: 1;
  font-size: 1rem;
  transition: all 0.2s;
}

.checklist-item.packed .item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Item Status Badge */
.item-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.item-status.packed {
  background: rgba(52,199,89,0.12);
  color: var(--success);
}

.item-status.returned {
  background: rgba(255,149,0,0.12);
  color: var(--warning);
}

/* Delete Button */
.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.checklist-item .delete-btn {
  opacity: 0.4;
}

.delete-btn:active {
  opacity: 1;
  color: var(--danger);
  background: rgba(255,59,48,0.1);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 600;
}

.empty-sub {
  font-size: 0.9rem !important;
  font-weight: 400 !important;
  margin-top: 4px;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.modal-content {
  background: var(--card-bg);
  width: 100%;
  max-width: 600px;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  padding-bottom: calc(var(--safe-bottom) + 24px);
  animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-header h2 {
  font-size: 1.3rem;
}

.modal-body label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}

.modal-body input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--bg);
}

.modal-body input:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.primary-btn {
  flex: 1;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

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

.danger-btn {
  flex: 1;
  padding: 16px;
  background: rgba(255,59,48,0.1);
  color: var(--danger);
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.danger-btn:active {
  background: rgba(255,59,48,0.2);
}

/* ===== Utilities ===== */
.hidden {
  display: none !important;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .modal-content {
    border-radius: 24px;
    margin: 40px;
  }
}

/* ===== iOS Safe Areas ===== */
@supports (padding: max(0px)) {
  .app-header {
    padding-top: max(16px, var(--safe-top) + 16px);
  }
}
