/**
 * Text Tools - ベーススタイル
 * ID セレクタアプローチで CSS 特異性による dark mode 対応
 */

/* ========================================
   全体スタイル
   ======================================== */

:root {
  color-scheme: light;
}

#text-tools-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
  color: #333;
  line-height: 1.6;
  background-color: white;
}

/* ========================================
   TextInputArea コンポーネント
   ======================================== */

#text-tools-container .text-input-area {
  margin-bottom: 2rem;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.5rem 8px;
  color: #333;
}

#text-tools-container .text-input-area__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
}

#text-tools-container .text-input-area__label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #000;
  margin: 0;
}

#text-tools-container .text-input-area__char-count {
  font-size: 0.85rem;
  color: #333;
}

#text-tools-container .text-input-area__drop-zone {
  border: 2px dashed #3b82f6;
  border-radius: 0.5rem;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background-color: #f0f9ff;
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

#text-tools-container .text-input-area__drop-zone:hover {
  border-color: #1e40af;
  background-color: #e0f2fe;
}

#text-tools-container .text-input-area__drop-zone--active {
  border-color: #1e40af;
  background-color: #dbeafe;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

#text-tools-container .text-input-area__drop-zone-content {
  pointer-events: none;
}

#text-tools-container .text-input-area__drop-zone-text {
  color: #333;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

#text-tools-container .text-input-area__file-label {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #3b82f6;
  color: white;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
  user-select: none;
  pointer-events: auto;
}

#text-tools-container .text-input-area__file-label:hover {
  background-color: #2563eb;
}

#text-tools-container .text-input-area__file-label:active {
  background-color: #1d4ed8;
}

#text-tools-container .text-input-area__drop-zone-hint {
  font-size: 0.8rem;
  color: #333;
  margin-top: 0.5rem;
}

#text-tools-container .text-input-area__textarea {
  width: 100%;
  height: 250px;
  padding: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: white;
  color: #000;
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
}

#text-tools-container .text-input-area__textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ========================================
   FileLoader コンポーネント
   ======================================== */

#text-tools-container .file-loader {
  margin-bottom: 2rem;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.5rem;
  color: #333;
}

#text-tools-container .file-loader__drop-zone {
  border: 2px dashed #3b82f6;
  border-radius: 0.5rem;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background-color: #f0f9ff;
  transition: all 0.3s ease;
}

#text-tools-container .file-loader__drop-zone:hover {
  border-color: #1e40af;
  background-color: #e0f2fe;
}

#text-tools-container .file-loader__drop-zone--active {
  border-color: #1e40af;
  background-color: #dbeafe;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

#text-tools-container .file-loader__content {
  pointer-events: none;
}

#text-tools-container .file-loader__icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

#text-tools-container .file-loader__text {
  color: #4b5563;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

#text-tools-container .file-loader__button {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background-color: #3b82f6;
  color: white;
  border-radius: 0.375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  user-select: none;
  pointer-events: auto;
}

#text-tools-container .file-loader__button:hover {
  background-color: #2563eb;
}

#text-tools-container .file-loader__button:active {
  background-color: #1d4ed8;
}

#text-tools-container .file-loader__hint {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.75rem;
}

/* ========================================
   OptionsList コンポーネント
   ======================================== */

#text-tools-container .options-list {
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  color: #333;
}

#text-tools-container .options-list__item {
  margin-bottom: 1rem;
}

#text-tools-container .options-list__item:last-child {
  margin-bottom: 0;
}

#text-tools-container .options-list__label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

#text-tools-container .options-list__text {
  font-size: 0.9rem;
  color: #000;
  margin-left: 0.5rem;
}

#text-tools-container .options-list__input-checkbox,
#text-tools-container .options-list__input-radio {
  width: 1.125rem;
  height: 1.125rem;
  cursor: pointer;
  accent-color: #3b82f6;
}

#text-tools-container .options-list__input-select {
  margin-left: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  cursor: pointer;
  background-color: #ffffff;
  color: #000000;
  color-scheme: light;
}

#text-tools-container .options-list__input-select:focus {
  outline: none;
  border-color: #3b82f6;
  background-color: #ffffff;
  color: #000000;
}

#text-tools-container .options-list__input-text {
  margin-left: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  background-color: #ffffff;
  color: #000000;
}

#text-tools-container .options-list__input-text:focus {
  outline: none;
  border-color: #3b82f6;
  background-color: #ffffff;
  color: #000000;
}

/* ========================================
   OutputBox コンポーネント
   ======================================== */

#text-tools-container .output-box {
  margin-bottom: 2rem;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.5rem 8px;
  color: #333;
}

#text-tools-container .output-box__header {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
}

#text-tools-container .output-box__label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #000;
  margin: 0;
}

#text-tools-container .output-box__text {
  width: 100%;
  min-height: 200px;
  padding: 1rem;
  background-color: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre;
  margin-bottom: 1rem;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 400px;
  color: #000;
}

#text-tools-container .output-box__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
}

#text-tools-container .output-box__button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

#text-tools-container .output-box__button--select {
  background-color: #6b7280;
  color: white;
}

#text-tools-container .output-box__button--select:hover {
  background-color: #4b5563;
}

#text-tools-container .output-box__button--select:active {
  background-color: #374151;
}

#text-tools-container .output-box__button--copy {
  background-color: #10b981;
  color: white;
}

#text-tools-container .output-box__button--copy:hover {
  background-color: #059669;
}

#text-tools-container .output-box__button--copy:active {
  background-color: #047857;
}

/* ========================================
   Toast コンポーネント
   ======================================== */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  padding: 1rem 1.5rem;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(1rem);
  transition: all 0.3s ease;
  pointer-events: auto;
  max-width: 400px;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  background-color: #10b981;
  color: white;
}

.toast--error {
  background-color: #ef4444;
  color: white;
}

.toast--info {
  background-color: #3b82f6;
  color: white;
}

.toast--warning {
  background-color: #f59e0b;
  color: white;
}

/* ========================================
   ボタンスタイル（共通）
   ======================================== */

.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn--primary {
  background-color: #3b82f6;
  color: white;
}

.btn--primary:hover {
  background-color: #2563eb;
}

.btn--primary:active {
  background-color: #1d4ed8;
}

.btn--secondary {
  background-color: #6b7280;
  color: white;
}

.btn--secondary:hover {
  background-color: #4b5563;
}

.btn--secondary:active {
  background-color: #374151;
}

.btn--success {
  background-color: #10b981;
  color: white;
}

.btn--success:hover {
  background-color: #059669;
}

.btn--success:active {
  background-color: #047857;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   レスポンシブ対応
   ======================================== */

@media (max-width: 768px) {
  #text-tools-container {
    padding: 0.5rem;
  }

  #text-tools-container .text-input-area {
    padding: 1rem 8px;
  }

  #text-tools-container .file-loader {
    padding: 1rem;
  }

  #text-tools-container .options-list {
    padding: 1rem;
  }

  #text-tools-container .output-box {
    padding: 1rem 8px;
  }

  .text-input-area__textarea {
    height: 200px;
    font-size: 16px; /* iPhoneのズーム防止 */
  }

  .text-input-area__drop-zone {
    padding: 1.5rem 1rem;
  }

  .file-loader__drop-zone {
    padding: 2rem 1rem;
  }

  .toast-container {
    bottom: 1rem;
    right: 0.5rem;
    left: 0.5rem;
  }

  .toast {
    max-width: none;
  }

  .output-box__actions {
    flex-wrap: wrap;
  }
}

/* ========================================
   グローバルカラースタイル（オレンジ系）
   ======================================== */

a.bg-orange-500 {
  background-color: #f97316;
}

a.bg-orange-500:visited {
  background-color: #f97316;
}

a.bg-orange-500:hover {
  background-color: #ea580c;
}
