/* Tool Individual Styles */

.tool-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: start;
}

.tool-main-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.tool-side-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.input-area {
  width: 100%;
  background-color: rgba(156, 163, 175, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

textarea.input-area {
  min-height: 220px;
  resize: vertical;
}

.input-area:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--glow);
}

.input-row {
  display: flex;
  gap: 1rem;
}

.input-row .form-group {
  flex: 1;
}

/* Controls / Options */
.options-card {
  background: rgba(156, 163, 175, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
}

.options-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.option-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
}

.option-checkbox-label input[type="checkbox"],
.option-checkbox-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px var(--glow);
}

.btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover {
  background-color: rgba(156, 163, 175, 0.08);
}

.btn-group {
  display: flex;
  gap: 1rem;
}

/* Counter Metrics Dashboard */
.counter-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.metric-card {
  background: rgba(156, 163, 175, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Diff Checker Layout */
.diff-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.diff-output {
  grid-column: span 2;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: rgba(156, 163, 175, 0.02);
  min-height: 150px;
  padding: 1rem;
  font-family: monospace;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.diff-line {
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
}

.diff-added {
  background-color: rgba(16, 185, 129, 0.15);
  color: #065f46;
  text-decoration: none;
}

[data-theme="dark"] .diff-added {
  color: #34d399;
}

.diff-removed {
  background-color: rgba(239, 68, 68, 0.15);
  color: #991b1b;
  text-decoration: line-through;
}

[data-theme="dark"] .diff-removed {
  color: #f87171;
}

/* Google SERP Preview */
.serp-preview-box {
  background-color: white;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 16px;
  max-width: 600px;
  margin-top: 1rem;
  font-family: arial, sans-serif;
  color: #202124;
  text-align: left;
}

.serp-url-line {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #202124;
  margin-bottom: 4px;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.serp-title-line {
  font-size: 20px;
  color: #1a0dab;
  line-height: 1.3;
  margin-bottom: 4px;
  cursor: pointer;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.serp-title-line:hover {
  text-decoration: underline;
}

.serp-desc-line {
  font-size: 14px;
  color: #4d5156;
  line-height: 1.58;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.serp-mobile {
  max-width: 375px;
}

.serp-mobile .serp-title-line {
  font-size: 16px;
}

/* Google SERP Dark Mode Overrides */
[data-theme="dark"] .serp-preview-box {
  background-color: #202124;
  border-color: #3c4043;
  color: #bdc1c6;
}

[data-theme="dark"] .serp-url-line {
  color: #bdc1c6;
}

[data-theme="dark"] .serp-title-line {
  color: #8ab4f8;
}

[data-theme="dark"] .serp-desc-line {
  color: #bdc1c6;
}

/* History Box */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 250px;
  overflow-y: auto;
}

.history-item {
  background: rgba(156, 163, 175, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-time {
  color: var(--text-muted);
}

.history-action-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}

/* Prompt Assembler Grid */
.prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr;
    align-items: stretch !important;
    width: 100% !important;
  }
  .tool-side-panel, .tool-main-panel {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .diff-container {
    grid-template-columns: 1fr;
  }
  .diff-output {
    grid-column: span 1;
  }
  .prompt-grid {
    grid-template-columns: 1fr;
  }
  /* Bug 261: ビジネス計算機の2カラムグリッドをモバイルで1カラムにスタックし、最終結果を上に配置 */
  .calc-result-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }
  .calc-result-grid > div:last-child {
    order: -1 !important;
    margin-bottom: 1rem;
    width: 100% !important;
  }
  /* Bug 285: 請求書メーカーの集計2カラムグリッドをモバイルで1カラムにスタックし、合計金額を上に配置 */
  .invoice-calc-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }
  .invoice-calc-grid > div:last-child {
    order: -1 !important;
    margin-bottom: 1rem;
    width: 100% !important;
  }
  .input-row {
    flex-direction: column !important;
  }
}

/* Forms Validation States */
.input-area:user-invalid {
  border-color: var(--danger, #ef4444);
  background-color: rgba(239, 68, 68, 0.03);
}

[data-theme="dark"] .input-area:user-invalid {
  background-color: rgba(239, 68, 68, 0.08);
}

/* ==========================================================================
   Case Converter Premium UI Styles
   ========================================================================== */

/* Editor Grid for Twin Editor Layout */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.output-area {
  background-color: rgba(156, 163, 175, 0.02) !important;
  border-style: dashed;
}

@media (max-width: 900px) {
  .editor-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Control Panel Row & Modern Toggle Switch */
.control-panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(156, 163, 175, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 40px;
  height: 20px;
  background-color: rgba(156, 163, 175, 0.2);
  border-radius: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--glow);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Button Group Wrap and Mobile Adjustments */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
}

.btn-group .btn {
  flex: 1 1 auto;
  min-width: 120px;
}

@media (max-width: 600px) {
  .btn-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .btn-group .btn {
    width: 100% !important;
  }
}

/* Device Segmented Control Switcher */
.device-segmented-control {
  display: inline-flex;
  background: rgba(156, 163, 175, 0.08);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.device-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.device-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px var(--glow);
}

/* Mobile responsive card & history layout overrides */
@media (max-width: 768px) {
  .card {
    padding: 1.25rem !important;
  }
}

@media (max-width: 480px) {
  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .history-item > div:last-child {
    align-self: flex-end;
  }
}
