/* ============================================
   Recipe Log AI - Global Stylesheet
   Theme: Warm Orange (#f97316)
   Mobile-first / PWA
   ============================================ */

/* --- CSS Variables --- */
:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #fed7aa;
  --primary-bg: #fff7ed;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #eab308;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #fafafa;
  --white: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --nav-height: 64px;
}

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

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

/* --- Body --- */
body {
  font-family: 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-height) + 16px);
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- Container --- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* --- Card --- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-decoration: none;
  text-align: center;
  line-height: 1.4;
  gap: 6px;
  font-family: inherit;
}

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

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

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

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-bg);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
}

.btn-secondary:hover {
  background: #d1d5db;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
  color: var(--text);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: #9ca3af;
}

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

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
}

.form-hint {
  color: var(--text-light);
  font-size: 13px;
  margin-top: 4px;
}

/* --- App Header --- */
.app-header {
  background: var(--primary);
  color: var(--white);
  padding: 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.app-header-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.app-header-back {
  position: absolute;
  left: 0;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 11px;
  font-weight: 500;
  gap: 2px;
  transition: color 0.2s;
}

.nav-item:active {
  opacity: 0.7;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 24px;
  line-height: 1;
}

/* --- Toast Notification --- */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  animation: slideDown 0.3s ease;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-warning {
  background: var(--warning);
  color: var(--text);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* --- Loading Overlay --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

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

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

/* --- Auth Pages --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
  padding: 32px 16px;
}

.auth-logo {
  font-size: 48px;
  margin-bottom: 8px;
  line-height: 1;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--text-light);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 32px;
}

.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(249, 115, 22, 0.12);
}

.auth-link {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-light);
}

.auth-link a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--text-light);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider::before {
  margin-right: 12px;
}

.auth-divider::after {
  margin-left: 12px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  animation: scaleIn 0.2s ease;
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Tags / Badges --- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary);
  color: var(--white);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 16px;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state-text {
  font-size: 15px;
  color: var(--text-light);
  line-height: 1.6;
}

/* --- Utility Classes --- */
.text-center {
  text-align: center;
}

.text-sm {
  font-size: 14px;
}

.text-xs {
  font-size: 12px;
}

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

.text-primary {
  color: var(--primary);
}

.text-danger {
  color: var(--danger);
}

.font-bold {
  font-weight: 700;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.mb-3 {
  margin-bottom: 24px;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

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

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* FABボタン（記録ページへの＋ボタン） */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform 0.2s;
  text-decoration: none;
}
.fab:hover { text-decoration: none; }
.fab:active { transform: scale(0.9); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
