@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================
   Design System - Sophistication & Trust
   Stripe/Mercury風のクールで洗練されたデザイン
   ============================================ */

@layer base {
  :root {
    /* 層状シャドウ */
    --shadow-layered-sm: 0 0 0 0.5px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.03), 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-layered: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.03), 0 4px 8px rgba(0, 0, 0, 0.02);
    --shadow-layered-md: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04), 0 4px 8px rgba(0, 0, 0, 0.03), 0 8px 16px rgba(0, 0, 0, 0.02);
    --shadow-layered-lg: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 4px 8px rgba(0, 0, 0, 0.04), 0 8px 16px rgba(0, 0, 0, 0.03), 0 16px 32px rgba(0, 0, 0, 0.02);

    /* トランジション */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  body {
    @apply antialiased;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  }
}

/* ============================================
   Admin Component Classes
   ============================================ */
@layer components {
  /* カード */
  .card {
    @apply bg-white rounded-lg border border-surface-200;
    box-shadow: var(--shadow-layered);
  }

  .card-hover {
    @apply bg-white rounded-lg border border-surface-200 transition-all duration-200;
    box-shadow: var(--shadow-layered);
  }

  .card-hover:hover {
    box-shadow: var(--shadow-layered-md);
    @apply border-surface-300;
  }

  /* ボタン */
  .btn {
    @apply inline-flex items-center justify-center px-4 py-2 text-sm font-medium rounded-md transition-all duration-150;
  }

  .btn-primary {
    @apply btn bg-primary-500 text-white hover:bg-primary-600 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2;
  }

  .btn-secondary {
    @apply btn bg-white text-surface-700 hover:bg-surface-50 border border-surface-300 focus:outline-none focus:ring-2 focus:ring-surface-500 focus:ring-offset-2;
  }

  .btn-ghost {
    @apply btn text-surface-600 hover:bg-surface-100 hover:text-surface-900;
  }

  .btn-danger {
    @apply btn bg-error-500 text-white hover:bg-error-600 focus:outline-none focus:ring-2 focus:ring-error-500 focus:ring-offset-2;
  }

  .btn-sm {
    @apply px-3 py-1.5 text-xs;
  }

  .btn-xs {
    @apply px-2 py-1 text-xs;
  }

  /* バッジ */
  .badge {
    @apply inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-md;
  }

  .badge-success {
    @apply badge bg-success-100 text-success-700;
  }

  .badge-warning {
    @apply badge bg-warning-100 text-warning-700;
  }

  .badge-error {
    @apply badge bg-error-100 text-error-700;
  }

  .badge-info {
    @apply badge bg-primary-100 text-primary-700;
  }

  .badge-neutral {
    @apply badge bg-surface-100 text-surface-700;
  }

  /* フォーム入力 */
  .input {
    @apply w-full px-3 py-2 text-sm border border-surface-300 rounded-md bg-white text-surface-900 placeholder-surface-400;
    @apply focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500;
    @apply transition-all duration-150;
  }

  .input-error {
    @apply input border-error-500 focus:ring-error-500 focus:border-error-500;
  }

  .select {
    @apply input appearance-none bg-no-repeat cursor-pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
  }

  .label {
    @apply block text-sm font-medium text-surface-700 mb-1.5;
  }

  /* テーブル */
  .table-header {
    @apply bg-surface-50 text-surface-600 text-xs font-semibold uppercase tracking-wider;
  }

  .table-cell {
    @apply px-6 py-4 text-sm text-surface-900;
  }

  .table-row {
    @apply border-b border-surface-100 hover:bg-surface-50 transition-colors duration-150;
  }

  /* データ表示用モノスペース */
  .font-data {
    @apply font-mono tabular-nums;
  }

  /* リンク */
  .link {
    @apply text-primary-600 hover:text-primary-700 hover:underline;
  }

  /* セクション見出し */
  .section-title {
    @apply text-lg font-semibold text-surface-900;
  }

  .section-subtitle {
    @apply text-sm text-surface-500 mt-1;
  }

  /* 定義リスト */
  .dl-row {
    @apply grid grid-cols-3 gap-4 py-3 border-b border-surface-100;
  }

  .dl-label {
    @apply text-sm font-medium text-surface-500;
  }

  .dl-value {
    @apply col-span-2 text-sm text-surface-900;
  }

  /* 空状態 */
  .empty-state {
    @apply text-center py-12 text-surface-500;
  }

  /* ページヘッダー */
  .page-header {
    @apply mb-6;
  }

  .page-title {
    @apply text-2xl font-semibold text-surface-900;
  }

  .page-description {
    @apply text-sm text-surface-500 mt-1;
  }
}

/* ============================================
   MovBot利用不可時の表示スタイル - 既存のcard系スタイルと統一
   ============================================ */
.unavailable-status-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.3s ease-out;
}

.status-icon-section {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 3rem;
  line-height: 1;
}

.status-message-section {
  text-align: center;
  margin-bottom: 1.5rem;
}

.status-message-section .status-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.status-message-section .status-description {
  color: var(--color-text-secondary);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.wait-time-info {
  background-color: rgba(var(--color-success-rgb), 0.08);
  border: 1px solid rgba(var(--color-success-rgb), 0.2);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.wait-time-text {
  color: var(--color-primary);
  font-weight: 500;
  font-size: 1.125rem;
}

.action-buttons-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-btn {
  width: 100%;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 1rem;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.action-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

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

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

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

.action-btn.secondary {
  background-color: var(--color-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.action-btn.secondary:hover {
  background-color: var(--color-secondary-hover);
  border-color: var(--color-primary);
}

.action-btn.emergency {
  background-color: rgba(var(--color-error-rgb), 0.1);
  color: var(--color-error);
  border: 1px solid rgba(var(--color-error-rgb), 0.3);
}

.action-btn.emergency:hover {
  background-color: rgba(var(--color-error-rgb), 0.15);
  border-color: var(--color-error);
}

.action-btn:active {
  transform: translateY(1px);
}

/* アニメーション */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* レスポンシブ対応 */
@media (max-width: 640px) {
  .unavailable-status-card {
    margin: 0 1rem 1.5rem 1rem;
    padding: 1rem;
  }
  
  .status-icon-section {
    font-size: 2.5rem;
  }
  
  .status-message-section .status-title {
    font-size: 1.125rem;
  }
  
  .action-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
}

/* Pagy pagination styles */
.pagy {
    display: flex;
    margin-left: 0.25rem;
    margin-right: 0.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: rgb(107 114 128);
}

.pagy > :not([hidden]) ~ :not([hidden]) {
    margin-left: 0.25rem;
}

.pagy a:not(.gap) {
    display: block;
    border-radius: 0.5rem;
    padding: 0.25rem 0.75rem;
    background-color: rgb(229 231 235);
}

.pagy a:not(.gap):hover {
    background-color: rgb(209 213 219);
}

.pagy a:not(.gap):not([href]) {
    color: rgb(209 213 219);
    background-color: rgb(243 244 246);
    cursor: default;
}

.pagy a:not(.gap).current {
    color: rgb(255 255 255);
    background-color: rgb(37 99 235);
}

.pagy .gap {
    padding: 0.25rem 0.375rem;
}

.pagy label {
    display: inline-block;
    white-space: nowrap;
    background-color: rgb(229 231 235);
    border-radius: 0.5rem;
    padding: 0.125rem 0.75rem;
}

.pagy label input {
    background-color: rgb(243 244 246);
    border: none;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
}

/* 共通ダイアログスタイル */
.dialog-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;
}

.dialog-container.dialog-container--visible {
  display: block;
}

.dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.dialog--visible {
  opacity: 1;
}

.dialog--closing {
  opacity: 0;
}

.dialog__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dialog__content {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 28rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.dialog--visible .dialog__content {
  transform: scale(1);
}

.dialog__header {
  display: flex;
  align-items: center;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.dialog__icon {
  font-size: 1.5rem;
  margin-right: 0.75rem;
}

.dialog__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.dialog__body {
  padding: 1rem 1.5rem;
}

.dialog__message {
  color: #374151;
  line-height: 1.6;
  margin: 0;
}

.dialog__content-custom {
  /* カスタムコンテンツ用のスタイル */
}

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.dialog__button {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 4rem;
}

.dialog__button--primary {
  background-color: #2563eb;
  color: white;
}

.dialog__button--primary:hover {
  background-color: #1d4ed8;
}

.dialog__button--secondary {
  background-color: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.dialog__button--secondary:hover {
  background-color: #e5e7eb;
}

/* 緊急連絡ダイアログ専用スタイル */
.emergency-contact-content .emergency-message {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #374151;
  font-size: 1rem;
}


.emergency-contact-info {
  text-align: center;
  padding: 1.5rem;
  background-color: #f8fafc;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.emergency-contact-info .contact-label {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.emergency-contact-info .contact-number-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.emergency-contact-info .facility-name {
  font-size: 0.875rem;
  color: #64748b;
}

/* 位置選択ダイアログ専用スタイル */
.location-dialog-content .recent-section {
  margin-bottom: 1.5rem;
}

.location-dialog-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
}

.recent-location-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.recent-location-tag {
  background-color: #dbeafe;
  color: #1d4ed8;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.875rem;
}

.recent-location-tag:hover {
  background-color: #bfdbfe;
}

.location-list {
  max-height: 20rem;
  overflow-y: auto;
}

.location-category-header {
  font-weight: 600;
  color: #374151;
  margin: 1rem 0 0.5rem 0;
  font-size: 0.875rem;
}

.floor-group {
  margin-bottom: 1rem;
}

.floor-header {
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  padding-left: 0.5rem;
}

.location-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-bottom: 0.25rem;
}

.location-item:hover {
  background-color: #f3f4f6;
}

.location-name {
  font-weight: 500;
  color: #111827;
}

.location-identifier {
  font-size: 0.75rem;
  color: #6b7280;
  background-color: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.location-divider {
  height: 1px;
  background-color: #e5e7eb;
  margin: 1rem 0;
}

/* 即座に呼び出すダイアログ専用スタイル */
.quick-call-content {
  text-align: center;
}

.route-display {
  margin-bottom: 1.5rem;
}

.route-point {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background-color: #f8fafc;
  border-radius: 0.5rem;
}

.route-icon {
  font-size: 1.25rem;
  margin-right: 0.75rem;
}

.route-text {
  font-weight: 500;
  color: #111827;
}

.route-arrow {
  font-size: 1.5rem;
  color: #6b7280;
  margin: 0.5rem 0;
}

.confirmation-message {
  color: #374151;
  margin: 0;
  font-size: 1rem;
}