/* CSS変数の定義 */
:root {
  --bg-color: #121214;
  --panel-bg: rgba(30, 30, 38, 0.75);
  --primary-color: #009999;
  --primary-hover: #008080;
  --accent-color: #00cc99;
  --danger-color: #ef4444;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-color: rgba(255, 255, 255, 0.08);
}

/* 基本リセット */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem;
  overflow-x: hidden;
}

/* コンテナ */
.app-container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ヘッダー */
header {
  text-align: center;
  margin-top: 0.5rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #a5f3fc, var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ステータスバー */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.network-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  display: inline-block;
}

.status-dot.online {
  background-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
}

.status-dot.offline {
  background-color: var(--danger-color);
  box-shadow: 0 0 8px var(--danger-color);
}

.queue-badge {
  background: rgba(0, 153, 153, 0.2);
  color: #a5f3fc;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* カメラビューポート */
.camera-panel {
  position: relative;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

#preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* カメラ停止・不許可時の代替表示（完全に上下左右中央揃え） */
.camera-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 上下中央揃え */
  gap: 0.5rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  z-index: 5;
}

.camera-placeholder svg {
  width: 52px;
  height: 52px;
  stroke: var(--primary-color);
  stroke-width: 1.5;
  margin-bottom: 0.25rem;
}

/* スキャン成功時のフリーズ＆オーバーレイ */
.result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 18, 20, 0.85); /* 暗めのすりガラス背景 */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fade-in 0.25s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0, 153, 153, 0.1);
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 153, 153, 0.3);
  animation: scale-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scale-up {
  from { transform: scale(0.6); }
  to { transform: scale(1); }
}

.result-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.result-code {
  font-family: monospace;
  font-size: 2.2rem;
  font-weight: 800;
  color: #a5f3fc;
  text-shadow: 0 0 10px rgba(165, 243, 252, 0.3);
}

/* スキャンのアニメーションガイド */
.scan-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame {
  width: 60%;
  height: 60%;
  border: 2px solid rgba(0, 153, 153, 0.4);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.5);
}

/* 角のL字マーク */
.scan-frame::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 20px;
  height: 20px;
  border-top: 4px solid var(--primary-color);
  border-left: 4px solid var(--primary-color);
  border-top-left-radius: 8px;
}

.scan-frame::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-top: 4px solid var(--primary-color);
  border-right: 4px solid var(--primary-color);
  border-top-right-radius: 8px;
}

.scan-frame-bottom::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: -2px;
  width: 20px;
  height: 20px;
  border-bottom: 4px solid var(--primary-color);
  border-left: 4px solid var(--primary-color);
  border-bottom-left-radius: 8px;
}

.scan-frame-bottom::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-bottom: 4px solid var(--primary-color);
  border-right: 4px solid var(--primary-color);
  border-bottom-right-radius: 8px;
}

/* スキャンレーザー線 */
.scan-line {
  position: absolute;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
  box-shadow: 0 0 8px var(--primary-color);
  top: 0;
  animation: scan-move 2s linear infinite;
}

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

/* ふわっと光るエフェクト用オーバーレイ */
.flash-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 153, 153, 0.4); /* エメラルドグリーンで光る */
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.flash-active {
  animation: flash-animation 0.5s ease-out;
}

@keyframes flash-animation {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* アクションパネル */
.action-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 送信ボタン */
.btn {
  width: 100%;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 12px rgba(0, 153, 153, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 153, 153, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

/* ログ・結果リスト */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
}

.history-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 4px;
}

/* スクロールバー装飾 */
.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-track {
  background: transparent;
}
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
}

.history-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.item-code {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: bold;
  color: #a5f3fc;
}

.item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.item-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}

.status-badge.unsent {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.sent {
  background: rgba(0, 204, 153, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(0, 204, 153, 0.3);
}

/* 個別削除ボタン */
.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-delete:hover {
  color: var(--danger-color);
  background: rgba(239, 68, 68, 0.1);
}

/* トースト通知 */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e1e2e;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* 最下部CSVボタンのスタイル */
.btn-csv {
  background: rgba(0, 153, 153, 0.05);
  border: 1px dashed var(--primary-color);
  color: #a5f3fc;
  margin-top: 0.5rem;
  margin-bottom: 2rem;
  box-shadow: none;
}

.btn-csv:hover:not(:disabled) {
  background: rgba(0, 153, 153, 0.15);
  border-style: solid;
  transform: translateY(-1px);
}


