/* ==========================================
   Design System & Variable Tokens
   ========================================== */
:root {
  --font-primary: 'Inter', -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Premium Light Palette */
  --bg-app: #F1F5F9;
  --bg-phone: #FFFFFF;
  --bg-card: rgba(248, 250, 252, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --border-color: rgba(0, 0, 0, 0.08);
  
  /* Primary Gradients & Accents (Adjusted for light background) */
  --primary: #7C3AED; /* Deeper Violet */
  --primary-glow: rgba(124, 58, 237, 0.15);
  --accent: #DB2777; /* Deeper Pink */
  --gradient-primary: linear-gradient(135deg, #7C3AED 0%, #DB2777 100%);
  --gradient-success: linear-gradient(135deg, #059669 0%, #10B981 100%);
  --gradient-warning: linear-gradient(135deg, #D97706 0%, #F59E0B 100%);
  
  /* Semantic Colors */
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-text: #334155; /* Slate 700 */
  --color-text-muted: #64748B; /* Slate 500 */
  --color-text-dark: #0F172A; /* Slate 900 */
}

/* ==========================================
   Base & Reset
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(at 0% 0%, rgba(124, 58, 237, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(219, 39, 119, 0.08) 0px, transparent 50%);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: hidden;
}

/* ==========================================
   Phone Simulator Frame
   ========================================== */
.phone-wrapper {
  position: relative;
  width: 100%;
  max-width: 410px;
  height: 840px;
  background: #0F172A; /* Slate 900 for dark phone bezel */
  border-radius: 48px;
  padding: 12px;
  box-shadow: 
    0 25px 50px -12px rgba(15, 23, 42, 0.25),
    0 0 40px rgba(124, 58, 237, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.2);
}

.phone-container {
  width: 100%;
  height: 100%;
  background-color: var(--bg-phone);
  border-radius: 38px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Status Bar Mock */
.phone-status-bar {
  height: 34px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  z-index: 10;
  background-color: var(--bg-phone);
}
.status-icons {
  display: flex;
  gap: 6px;
}
.icon-small {
  width: 14px;
  height: 14px;
}
.icon-tiny {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
}

/* ==========================================
   App Header Component
   ========================================== */
.app-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.85); /* Lighter glassmorphism */
  backdrop-filter: blur(10px);
  z-index: 10;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.avatar-icon {
  width: 22px;
  height: 22px;
  color: white;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.restaurant-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tax-badge {
  font-size: 10px;
  font-weight: 700;
  color: #60A5FA;
  display: inline-block;
  margin-top: 2px;
}

.btn-refresh {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-color);
  color: var(--color-text-muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
}
.btn-refresh:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-dark);
  transform: rotate(30deg);
}

/* ==========================================
   Content Area & Tab System
   ========================================== */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 80px 20px; /* ボトムバーの余白を多めに確保 */
  scroll-behavior: smooth;
}
.app-content::-webkit-scrollbar {
  display: none;
}

.screen-panel {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.screen-panel.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.subsection-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

/* ==========================================
   Home Screen Component (Dashboard)
   ========================================== */
.summary-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.summary-card.total {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.06) 0%, rgba(219, 39, 119, 0.06) 100%);
  border: 1px solid rgba(124, 58, 237, 0.15);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.03);
}
.summary-card.total::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 120px;
  height: 120px;
  background: var(--gradient-primary);
  opacity: 0.06;
  filter: blur(40px);
  border-radius: 50%;
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.card-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}

.card-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.text-up { color: var(--accent); }

.summary-sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-card.pending {
  border-left: 4px solid var(--color-warning);
}
.summary-card.verified {
  border-left: 4px solid var(--color-success);
}
.card-value-sub {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--color-text);
}

/* Category Bars */
.analytics-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
}

.category-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cat-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
}
.cat-name { color: var(--color-text); }
.cat-val { color: var(--color-text-muted); }

.cat-track {
  height: 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  overflow: hidden;
}
.cat-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  transition: width 1s ease-out;
}

.no-data-msg {
  text-align: center;
  padding: 16px 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Recent Pending List */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================
   Scan & Voice Screen
   ========================================== */
.sensor-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.sensor-tab {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.sensor-tab.active {
  background: #ffffff;
  color: var(--color-text-dark);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sensor-panel {
  display: none;
}
.sensor-panel.active {
  display: block;
}

/* Viewports */
.camera-viewport, .voice-viewport {
  width: 100%;
  height: 240px;
  background: #1E293B; /* Slate 800 for nice viewport contrast */
  border-radius: 20px;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
}

.camera-video-elem, .camera-captured-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.camera-video-elem.hidden, .camera-captured-img.hidden {
  display: none;
}

.camera-placeholder, .voice-placeholder {
  text-align: center;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--color-text-muted);
  z-index: 2;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  color: rgba(255, 255, 255, 0.3);
  transition: color 0.3s ease;
}

.camera-viewport:hover .placeholder-icon,
.voice-viewport:hover .placeholder-icon {
  color: var(--primary);
}

.location-badge {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #A78BFA;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Camera Scanline Animation */
.scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--gradient-primary);
  opacity: 0.7;
  box-shadow: 0 0 12px var(--primary);
  animation: scan 3s linear infinite;
  z-index: 1;
}

@keyframes scan {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

/* Camera Overlay Corners */
.camera-overlay-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  z-index: 2;
}
.top-left { top: 15px; left: 15px; border-right: none; border-bottom: none; }
.top-right { top: 15px; right: 15px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 15px; left: 15px; border-right: none; border-top: none; }
.bottom-right { bottom: 15px; right: 15px; border-left: none; border-top: none; }

/* Voice Wave Animation */
.voice-wave {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 60px;
  bottom: 30px;
  opacity: 0.1;
  transition: opacity 0.3s ease;
}
.voice-wave.active {
  opacity: 0.8;
}
.wave-bar {
  width: 4px;
  height: 8px;
  background: var(--gradient-primary);
  border-radius: 2px;
}
.voice-wave.active .wave-bar {
  animation: bounce 0.6s ease infinite alternate;
}
.voice-wave.active .wave-bar:nth-child(1) { animation-delay: 0.1s; }
.voice-wave.active .wave-bar:nth-child(2) { animation-delay: 0.3s; }
.voice-wave.active .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-wave.active .wave-bar:nth-child(4) { animation-delay: 0.4s; }
.voice-wave.active .wave-bar:nth-child(5) { animation-delay: 0.15s; }

@keyframes bounce {
  from { height: 8px; }
  to { height: 40px; }
}

/* Action buttons */
.action-bar {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

/* Fact Preview Form Card */
.fact-preview-card {
  background: #ffffff;
  border: 1px solid rgba(124, 58, 237, 0.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 16px;
  margin-top: 10px;
  backdrop-filter: blur(12px);
  animation: slideUp 0.3s ease-out;
}
.fact-preview-card.hidden {
  display: none;
}

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

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.preview-badge {
  font-size: 11px;
  font-weight: 700;
  color: #A78BFA;
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

/* Form Styling */
.preview-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.preview-form label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.preview-form input, 
.preview-form select, 
.preview-form textarea {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--color-text-dark);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}
.preview-form input:focus, 
.preview-form select:focus, 
.preview-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}
.preview-form textarea {
  resize: none;
}

.geo-info {
  font-size: 10px;
  color: var(--color-text-muted);
  display: flex;
  gap: 10px;
  margin-top: -4px;
}

/* ==========================================
   History Screen Component
   ========================================== */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}
.filter-tab {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-color);
  color: var(--color-text-muted);
  padding: 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-tab.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Record Item Card */
.record-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, background 0.2s ease;
}
.record-item:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.record-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.record-meta {
  display: flex;
  gap: 10px;
}

.sensor-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.08);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--primary);
}

.record-details {
  display: flex;
  flex-direction: column;
}

.vendor {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.datetime-location {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.record-financial {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.amount {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.category-badge {
  font-size: 9px;
  background: rgba(139, 92, 246, 0.1);
  color: #A78BFA;
  padding: 2px 6px;
  border-radius: 6px;
  margin-top: 4px;
  font-weight: 600;
}

/* OCR Text Detail in Card */
.record-extra {
  font-size: 11px;
  color: var(--color-text-muted);
  background: rgba(0, 0, 0, 0.03);
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 2px solid var(--primary);
}

.record-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 8px;
  margin-top: 2px;
}

/* Status Badges */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
}

.status-indicator.pending {
  color: var(--color-warning);
}
.status-indicator.verified {
  color: var(--color-success);
}

/* ==========================================
   Buttons UI
   ========================================== */
button {
  font-family: var(--font-primary);
  outline: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.btn-primary:active {
  transform: scale(0.97);
}

.btn-glow {
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-glow:hover {
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  transition: all 0.2s ease;
}
.btn-success:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-verify {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--color-success);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.btn-verify:hover {
  background: var(--color-success);
  color: white;
}

/* ==========================================
   Loading Spinner Component
   ========================================== */
.loading-spinner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 40px 0;
  color: var(--color-text-muted);
  font-size: 13px;
}
.spin {
  animation: spinner 1s linear infinite;
  width: 24px;
  height: 24px;
  color: var(--primary);
}
@keyframes spinner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================
   Bottom Navigation Component
   ========================================== */
.app-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 68px;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(15px);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  z-index: 10;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  height: 100%;
  transition: all 0.2s ease;
}
.nav-item span {
  font-size: 10px;
  font-weight: 500;
}
.nav-item.active {
  color: var(--primary);
}
.nav-icon-main {
  width: 26px;
  height: 26px;
  color: #EC4899;
}
.nav-item.active .nav-icon-main {
  transform: scale(1.1);
  filter: drop-shadow(0 0 6px rgba(236, 72, 153, 0.5));
}
