/* 透明見積もりビルダー - カスタムスタイル (freee風) */

/* ベーススタイル */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* アニメーション */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* フォーム要素 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* プルダウン矢印カスタマイズ */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: 2rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* freee風テーブル */
.freee-table {
  border-collapse: collapse;
}

.freee-table thead th {
  background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
  position: sticky;
  top: 0;
  z-index: 10;
}

.freee-table tbody tr {
  transition: background-color 0.15s ease;
}

.freee-table tbody tr:hover {
  background-color: #eff6ff;
}

.freee-table input,
.freee-table select {
  font-size: 0.875rem;
}

.freee-table input:focus,
.freee-table select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* freee風セクション */
.freee-section {
  margin-bottom: 1.5rem;
}

/* 表示モード切り替えボタン */
.display-mode-btn {
  transition: all 0.2s ease;
}

.display-mode-btn.active {
  background-color: #3B82F6;
  color: white;
  border-color: #3B82F6;
}

/* 見積もりカード */
.estimate-card {
  transition: all 0.2s ease;
}

.estimate-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ステータスバッジ */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

.status-draft { background-color: #F3F4F6; color: #4B5563; }
.status-sent { background-color: #DBEAFE; color: #1D4ED8; }
.status-approved { background-color: #D1FAE5; color: #047857; }
.status-rejected { background-color: #FEE2E2; color: #B91C1C; }

/* セクションヘッダー */
.section-header {
  background: linear-gradient(to right, #F9FAFB, #FFFFFF);
  border-left: 4px solid #3B82F6;
}

/* ドラッグ＆ドロップ */
.draggable {
  cursor: grab;
}

.draggable:active {
  cursor: grabbing;
}

.drag-over {
  border: 2px dashed #3B82F6;
  background-color: #EFF6FF;
}

/* ツールチップ */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  background-color: #1F2937;
  color: white;
  font-size: 0.75rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 50;
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* プリントスタイル - コンパクト見積書 */
@media print {
  /* 印刷時に非表示にする要素 */
  .no-print,
  header,
  nav,
  button,
  select,
  .display-mode-btn,
  .status-badge,
  #chartContainer,
  [onclick],
  input[type="number"]::-webkit-inner-spin-button,
  input[type="number"]::-webkit-outer-spin-button,
  .text-gray-400,
  svg,
  optgroup,
  option {
    display: none !important;
  }

  /* ページ設定 - 余白を小さく */
  @page {
    size: A4;
    margin: 8mm 8mm;
  }

  /* 基本スタイル - フォントサイズを小さく */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: white !important;
    font-size: 8pt !important;
    line-height: 1.2 !important;
    color: #000 !important;
    margin: 0;
    padding: 0;
  }

  /* メインコンテナ */
  main,
  .container,
  [class*="max-w-"] {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 基本情報セクション - コンパクトに */
  .bg-white.rounded-xl {
    padding: 4pt !important;
    margin-bottom: 6pt !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* 入力フィールドを通常テキストとして表示 */
  input,
  select {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 1pt 2pt !important;
    font-size: 8pt !important;
    color: #000 !important;
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.2 !important;
  }

  input:focus,
  select:focus {
    outline: none !important;
    box-shadow: none !important;
  }

  /* テーブルスタイル - コンパクト */
  .freee-table,
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 7pt !important;
    page-break-inside: auto;
  }

  .freee-table thead,
  table thead {
    display: table-header-group;
  }

  .freee-table tr,
  table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .freee-table th,
  .freee-table td,
  table th,
  table td {
    border: 0.5pt solid #999 !important;
    padding: 2pt 3pt !important;
    text-align: left;
    background: white !important;
    font-size: 7pt !important;
    line-height: 1.2 !important;
  }

  .freee-table th,
  table th {
    background: #eee !important;
    font-weight: bold;
    font-size: 7pt !important;
  }

  .freee-table tbody tr:hover {
    background: white !important;
  }

  /* 項目名のセル */
  .freee-table td:first-child {
    max-width: 150pt !important;
  }

  .freee-table td:first-child > div {
    display: block !important;
  }

  .freee-table td:first-child input[type="text"] {
    font-size: 7pt !important;
    font-weight: bold !important;
    padding: 0 !important;
    margin-bottom: 1pt !important;
  }

  /* 説明文 - 1行に収める */
  .freee-table td:first-child input[placeholder*="説明"] {
    font-size: 6pt !important;
    font-weight: normal !important;
    color: #555 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140pt !important;
  }

  /* セクションタイトル */
  .freee-section {
    page-break-inside: avoid;
    margin-bottom: 8pt !important;
  }

  .freee-section > .flex {
    margin-bottom: 2pt !important;
  }

  .freee-section input[type="text"]:first-of-type {
    font-size: 9pt !important;
    font-weight: bold !important;
  }

  /* セクション小計 */
  .text-lg.font-bold.text-blue-600 {
    font-size: 9pt !important;
    color: #000 !important;
  }

  /* 金額表示 */
  .text-right,
  [class*="text-right"] {
    text-align: right !important;
  }

  .font-bold,
  [class*="font-bold"] {
    font-weight: bold !important;
  }

  .text-blue-600 {
    color: #000 !important;
  }

  /* 合計セクション - tfoot */
  .freee-table tfoot td {
    border-top: 1pt solid #333 !important;
    font-weight: bold;
    font-size: 7pt !important;
    padding: 3pt !important;
  }

  /* 「行を追加」ボタン非表示 */
  .freee-table tfoot button,
  .freee-table tfoot td:first-child {
    visibility: hidden;
    font-size: 0 !important;
  }

  /* サマリーボックス */
  .bg-white,
  .rounded-xl,
  .shadow-sm {
    box-shadow: none !important;
    border: 0.5pt solid #ccc !important;
    border-radius: 0 !important;
  }

  /* 金額サマリー */
  #totalAmount,
  #taxAmount,
  #grandTotal {
    font-size: 9pt !important;
  }

  /* 改ページ制御 */
  h1, h2, h3 {
    page-break-after: avoid;
    font-size: 10pt !important;
  }

  /* リンクのスタイル */
  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  /* グリッド・フレックスの調整 */
  .grid {
    display: block !important;
  }

  .lg\\:grid-cols-3 {
    display: flex !important;
    flex-wrap: wrap;
  }

  .lg\\:col-span-2 {
    width: 65% !important;
    flex: none !important;
  }

  .lg\\:col-span-1 {
    width: 35% !important;
    flex: none !important;
  }

  .gap-6,
  .gap-4,
  .gap-3 {
    gap: 4pt !important;
  }

  /* 余白の調整 - すべて小さく */
  .p-6 { padding: 4pt !important; }
  .p-4 { padding: 3pt !important; }
  .p-3 { padding: 2pt !important; }
  .px-6, .px-4, .px-3 { padding-left: 3pt !important; padding-right: 3pt !important; }
  .py-6, .py-4, .py-3 { padding-top: 2pt !important; padding-bottom: 2pt !important; }
  .py-2 { padding-top: 1pt !important; padding-bottom: 1pt !important; }

  .mb-6 { margin-bottom: 6pt !important; }
  .mb-4 { margin-bottom: 4pt !important; }
  .mb-3, .mb-2 { margin-bottom: 2pt !important; }

  /* 数字入力欄の幅 */
  input[type="number"] {
    width: 30pt !important;
    text-align: center !important;
  }

  /* 単価欄 */
  td:nth-child(4) input {
    text-align: right !important;
  }

  /* 表示モードなど不要なセクション */
  .border.rounded-lg.p-4:has(.display-mode-btn) {
    display: none !important;
  }

  /* 日/人台のラベル非表示 */
  .text-xs.text-gray-400 {
    display: none !important;
  }
}

/* レスポンシブ */
@media (max-width: 640px) {
  .freee-table {
    font-size: 0.75rem;
  }
  
  .freee-table th,
  .freee-table td {
    padding: 0.5rem 0.25rem;
  }
  
  .freee-table input {
    font-size: 0.75rem;
    padding: 0.25rem;
  }
}

/* ローディング */
.loading-spinner {
  border: 3px solid #F3F4F6;
  border-top-color: #3B82F6;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
}

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

/* トースト通知 */
.notification-toast {
  transition: all 0.3s ease;
}

/* モーダルオーバーレイ */
.modal-overlay {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* 金額表示 */
.amount-display {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* グラデーションボタン */
.btn-gradient {
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  transition: all 0.2s ease;
}

.btn-gradient:hover {
  background: linear-gradient(135deg, #2563EB 0%, #1E40AF 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-gradient:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* 行追加ボタン */
.freee-table tfoot button {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: background-color 0.15s ease;
}

.freee-table tfoot button:hover {
  background-color: #EFF6FF;
}

/* 空の行 */
.empty-row td {
  background-color: #FAFAFA;
}

/* アイテム行 */
.item-row {
  position: relative;
}

.item-row td:first-child {
  border-left: 3px solid transparent;
}

.item-row:hover td:first-child {
  border-left-color: #3B82F6;
}

/* プログレスバー */
.progress-bar {
  height: 8px;
  background-color: #E5E7EB;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3B82F6, #8B5CF6);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* フォーカス時のスタイル強化 */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 削除ボタンのホバー効果 */
button[title*="削除"]:hover {
  background-color: #FEE2E2;
  border-radius: 0.25rem;
}

/* セクションヘッダーの入力フィールド */
.freee-section input[type="text"]:first-of-type {
  transition: all 0.2s ease;
}

.freee-section input[type="text"]:first-of-type:hover {
  border-bottom-color: #93C5FD;
}

/* 単価設定ページのテーブル */
#settingsContainer table input {
  transition: all 0.15s ease;
}

#settingsContainer table input:hover {
  background-color: #F9FAFB;
}

#settingsContainer table input:focus {
  background-color: white;
}
