/* ========================================
   糸島農販 受発注システム — 共通スタイル
   Mobile-first / BtoB / シンプル設計
======================================== */

:root {
  --primary: #1E7B4D;
  --primary-dark: #155C3A;
  --primary-light: #52B788;
  --primary-bg: #F0FAF4;
  --accent: #95D5B2;
  --bg: #F4F6F8;
  --white: #FFFFFF;
  --text: #1A1A2E;
  --text-sub: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --success: #059669;
  --success-bg: #ECFDF5;
  --info: #2563EB;
  --info-bg: #EFF6FF;
  --sh-sm: 0 1px 2px rgba(0,0,0,.06);
  --sh: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --sh-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --sh-lg: 0 10px 25px rgba(0,0,0,.12);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --ease: all 0.2s ease;
}

*,*::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', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ─── Layout ────────────────────────────────── */
.app-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

.container {
  width: 100%; max-width: 960px;
  margin: 0 auto; padding: 0 16px;
}
.container-sm {
  width: 100%; max-width: 480px;
  margin: 0 auto; padding: 0 16px;
}

/* ─── Header ─────────────────────────────────── */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--sh-sm);
}
.header-inner {
  display: flex; align-items: center;
  justify-content: space-between;
  height: 56px; padding: 0 16px;
  max-width: 960px; margin: 0 auto;
}
.header-logo {
  font-size: 15px; font-weight: 700;
  color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.logo-icon {
  width: 28px; height: 28px;
  background: var(--primary); border-radius: 8px;
  display: flex; align-items: center;
  justify-content: center;
  color: white; font-size: 14px;
}
.header-right {
  display: flex; align-items: center; gap: 10px;
}
.header-user-name {
  font-size: 13px; color: var(--text-sub);
  max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.role-badge {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 12px;
  background: var(--primary-bg); color: var(--primary);
}

/* ─── Tab Nav ────────────────────────────────── */
.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-nav-inner {
  display: flex; padding: 0 12px;
  min-width: max-content;
}
.tab-btn {
  padding: 12px 14px; font-size: 13px; font-weight: 600;
  color: var(--text-sub); background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: var(--ease);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Main ───────────────────────────────────── */
.main-content {
  flex: 1; padding: 20px 16px;
  max-width: 960px; margin: 0 auto; width: 100%;
}

/* ─── Card ───────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px; box-shadow: var(--sh-sm);
}
.card + .card { margin-top: 12px; }
.card-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; }

/* ─── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center;
  justify-content: center; gap: 6px;
  padding: 10px 18px; font-size: 14px;
  font-weight: 600; border: none;
  border-radius: var(--r-sm); cursor: pointer;
  transition: var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); text-decoration: none; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; text-decoration: none; }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; text-decoration: none; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #B45309; text-decoration: none; }
.btn-ghost {
  background: none; color: var(--text-sub);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: var(--r); }
.btn-block { width: 100%; }

/* ─── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-sub); margin-bottom: 5px;
}
.form-label .req { color: var(--error); margin-left: 2px; }
.form-control {
  display: block; width: 100%;
  padding: 10px 13px; font-size: 15px;
  color: var(--text); background: var(--white);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: var(--ease); font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,123,77,.1);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled {
  background: var(--bg); color: var(--text-sub); cursor: not-allowed;
}
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-error { font-size: 12px; color: var(--error); margin-top: 4px; display: none; }
.form-control.is-error { border-color: var(--error); }
.form-control.is-error + .form-error { display: block; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-group { display: flex; gap: 8px; align-items: flex-start; }
.input-group .form-control { flex: 1; }
.input-addon {
  padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; color: var(--text-sub);
  white-space: nowrap; display: flex; align-items: center;
  min-width: 44px; justify-content: center;
}

/* ─── Badges / Status ─────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; font-size: 11px;
  font-weight: 700; border-radius: 20px; white-space: nowrap;
}
.s-received   { background: #DBEAFE; color: #1D4ED8; }
.s-checking   { background: #FEF3C7; color: #92400E; }
.s-available  { background: #D1FAE5; color: #065F46; }
.s-unavailable{ background: #FEE2E2; color: #991B1B; }
.s-delivered  { background: #E0E7FF; color: #3730A3; }

/* ─── Tables ─────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg); color: var(--text-sub);
  font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 9px 12px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td {
  padding: 11px 12px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }

/* ─── Stats Grid ─────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2,1fr);
  gap: 10px; margin-bottom: 20px;
}
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; text-align: center;
  box-shadow: var(--sh-sm);
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* ─── Section Header ─────────────────────────── */
.section-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.section-title { font-size: 15px; font-weight: 700; }

/* ─── Filter Bar ─────────────────────────────── */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-btn {
  padding: 5px 13px; font-size: 12px; font-weight: 600;
  border-radius: 20px; border: 1px solid var(--border);
  background: var(--white); color: var(--text-sub);
  cursor: pointer; transition: var(--ease);
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ─── Empty State ────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; }
.empty-text { font-size: 13px; }

/* ─── Alerts ─────────────────────────────────── */
.alert {
  padding: 11px 14px; border-radius: var(--r-sm);
  font-size: 13px; margin-bottom: 14px; display: none;
}
.alert.show { display: block; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #FECACA; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #A7F3D0; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #BFDBFE; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #FDE68A; }

/* ─── Info Box ───────────────────────────────── */
.info-box {
  background: var(--primary-bg); border: 1px solid var(--accent);
  border-radius: var(--r-sm); padding: 12px 14px;
  font-size: 13px; color: var(--text-sub); margin-bottom: 14px;
}
.info-box strong { color: var(--primary); }

/* ─── Modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: flex; align-items: center;
  justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: var(--ease);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--white); border-radius: var(--r-lg);
  padding: 24px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--sh-lg);
  transform: translateY(16px); transition: var(--ease);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 22px; line-height: 1;
  padding: 2px 4px; margin: -4px;
}
.modal-close:hover { color: var(--text); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; flex-wrap: wrap;
}

/* ─── Email Preview (notification simulation) ── */
.email-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 14px;
  margin-bottom: 10px; font-size: 13px;
}
.email-card-type {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted); margin-bottom: 8px;
}
.email-field { display: flex; gap: 8px; margin-bottom: 3px; font-size: 12px; }
.email-field-label {
  font-weight: 600; color: var(--text-sub);
  min-width: 46px; flex-shrink: 0;
}
.email-field-value { color: var(--text); word-break: break-all; }
.email-body {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  white-space: pre-wrap; color: var(--text); line-height: 1.7;
  font-size: 12px;
}
.email-action-link {
  display: inline-block; margin-top: 6px; margin-right: 8px;
  padding: 5px 14px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; text-decoration: none;
  cursor: pointer; border: none; font-family: inherit;
}
.link-available { background: var(--success); color: white; }
.link-unavailable { background: var(--error); color: white; }

/* ─── Toast ──────────────────────────────────── */
.toast-wrap {
  position: fixed; top: 16px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column;
  gap: 8px; max-width: 300px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--r);
  box-shadow: var(--sh-md); font-size: 13px; font-weight: 500;
  background: var(--white);
  border-left: 4px solid transparent;
  opacity: 0; transform: translateX(20px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.toast.in { opacity: 1; transform: translateX(0); }
.toast-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--error); }
.toast-info    { border-left-color: var(--info); }
.toast-warning { border-left-color: var(--warning); }
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--error); }
.toast-info    .toast-icon { color: var(--info); }
.toast-warning .toast-icon { color: var(--warning); }

/* ─── Login Page ─────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary-light) 100%);
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: var(--r-lg);
  padding: 32px 28px; width: 100%; max-width: 380px;
  box-shadow: var(--sh-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 54px; height: 54px; background: var(--primary);
  border-radius: var(--r); display: flex; align-items: center;
  justify-content: center; margin: 0 auto 10px; font-size: 24px;
}
.login-logo-title { font-size: 18px; font-weight: 800; color: var(--text); }
.login-logo-sub { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.login-or {
  text-align: center; position: relative; margin: 18px 0;
}
.login-or::before {
  content: ''; position: absolute; top: 50%;
  left: 0; right: 0; height: 1px; background: var(--border);
}
.login-or span {
  position: relative; background: white;
  padding: 0 12px; font-size: 12px; color: var(--text-muted);
}
.test-creds {
  background: var(--primary-bg); border: 1px solid var(--accent);
  border-radius: var(--r-sm); padding: 12px; margin-top: 18px;
}
.test-creds-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--primary); margin-bottom: 8px;
}
.test-creds-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-sub); margin-bottom: 4px;
}
.test-creds-row code {
  font-family: 'SF Mono',Consolas,monospace; font-size: 11px;
  color: var(--primary);
}

/* ─── Order Cards (restaurant history) ────────── */
.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px;
  box-shadow: var(--sh-sm);
}
.order-item-top {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 8px;
}
.order-item-name { font-size: 15px; font-weight: 600; }
.order-item-qty { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.order-item-meta {
  display: flex; gap: 12px; font-size: 12px; color: var(--text-muted);
}

/* ─── Farmer Response Page ────────────────────── */
.res-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.res-card {
  background: var(--white); border-radius: var(--r-lg);
  padding: 36px 28px; width: 100%; max-width: 400px;
  box-shadow: var(--sh-lg); text-align: center;
}
.res-icon { font-size: 48px; margin-bottom: 16px; }
.res-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.res-text { font-size: 14px; color: var(--text-sub); margin-bottom: 24px; }

/* ─── Misc Utilities ─────────────────────────── */
.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; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-sub { color: var(--text-sub); }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 14px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ─── Responsive ─────────────────────────────── */
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4,1fr); }
  .form-row-md { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
@media (max-width: 639px) {
  .hide-sm { display: none !important; }
  .toast-wrap { right: 8px; left: 8px; max-width: none; }
  .modal { padding: 20px 16px; }
}
@media (min-width: 640px) {
  .show-sm { display: none !important; }
}

/* ─── WordPress 埋め込み調整（テーマ内での表示崩れ防止） ─── */
#inohan-app { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
  'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif; color: var(--text); line-height: 1.6; }
#inohan-app *, #inohan-app *::before, #inohan-app *::after { box-sizing: border-box; }
#inohan-app .login-page,
#inohan-app .res-page { border-radius: var(--r-lg); }
#inohan-app a:hover { text-decoration: none; }
/* テーマのコンテンツ幅に縛られず全幅で表示したい場合に利用できるクラス */
.inohan-fullwidth #inohan-app { margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); }

/* ─── Standalone full-page (theme-bypassed dashboard) ─────────── */
html { margin-top: 0 !important; }
body.inohan-standalone { min-height: 100vh; background: var(--bg); }
body.inohan-standalone #inohan-app { min-height: 100vh; }

/* ─── v1.2: new status, labeled meta, icon-free accents ──────── */
.s-confirmed { background: #CCFBF1; color: #0F766E; }

/* Brand monogram (replaces emoji logo) */
.logo-icon, .login-logo-icon { font-weight: 800; }

/* Labeled order-card meta (replaces 📅 🚚 📝) */
.order-item-meta { flex-wrap: wrap; }
.ord-meta { display: inline-flex; align-items: baseline; gap: 5px; }
.ord-meta-k {
  font-size: 10px; font-weight: 700; color: var(--text-sub);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; letter-spacing: .02em;
}

/* Toast accent dot (replaces ✓ ✕ ⚠ ℹ) */
.toast-bar { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; background: var(--text-muted); }
.toast-success .toast-bar { background: var(--success); }
.toast-error   .toast-bar { background: var(--error); }
.toast-info    .toast-bar { background: var(--info); }
.toast-warning .toast-bar { background: var(--warning); }

/* Farmer email-link result card accent (replaces ✅ ❌) */
.res-ok   { border-top: 4px solid var(--success); }
.res-ng   { border-top: 4px solid var(--error); }
.res-info { border-top: 4px solid var(--info); }
.res-warn { border-top: 4px solid var(--warning); }
