/* code-converter.css - 文字コード変換ツール専用スタイル */

/* Web font for GJ/PUP/IVS characters */
@font-face {
  font-family: 'ACGJMincho';
  src: local('ACGJMincho'), url('../fonts/acgjm.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* =================================================================
   コンテナ・レイアウト
   ================================================================= */

.converter-container {
  min-height: 500px;
}

/* Responsive grid system */
@media (max-width: 991px) {
  .converter-container {
    min-height: auto;
  }
  
  .converter-container .row {
    margin: 0;
  }
  
  .converter-container .col-lg-4,
  .converter-container .col-lg-8 {
    padding: 0;
  }
}

/* =================================================================
   入出力セクション
   ================================================================= */

.converter-input-section,
.converter-output-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1.5rem;
  min-height: 500px;
  transition: all 0.3s ease;
}

/* Mobile responsive adjustments */
@media (max-width: 991px) {
  .converter-input-section,
  .converter-output-section {
    min-height: auto;
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .converter-output-section {
    margin-bottom: 0;
  }
}

@media (max-width: 575px) {
  .converter-input-section,
  .converter-output-section {
    border-radius: 0;
    padding: 1rem;
  }
}

/* =================================================================
   ドロップゾーン
   ================================================================= */

.drop-zone {
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: white;
}

@media (max-width: 575px) {
  .drop-zone {
    padding: 2rem 1rem;
  }
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #0d6efd;
  background: #e7f1ff;
}

.drop-zone-icon {
  font-size: 3rem;
  color: #6c757d;
  display: block;
  margin-bottom: 1rem;
}

@media (max-width: 575px) {
  .drop-zone-icon {
    font-size: 2.5rem;
  }
}

.drop-zone-title {
  color: #495057;
  margin-bottom: 0.5rem;
}

.drop-zone-text {
  color: #6c757d;
  font-size: 0.875rem;
  margin: 0;
}

/* =================================================================
   コントロール・ボタン
   ================================================================= */

.converter-controls {
  margin-top: 1.5rem;
}

@media (max-width: 575px) {
  .converter-controls {
    margin-top: 1rem;
  }
}

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

@media (max-width: 575px) {
  .action-buttons {
    gap: 0.5rem;
  }
  
  .action-buttons .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }
}

/* =================================================================
   ファイル情報・バッジ
   ================================================================= */

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: white;
  border-radius: 6px;
  margin-bottom: 1rem;
}

@media (max-width: 575px) {
  .file-info {
    padding: 0.5rem;
    font-size: 0.875rem;
  }
}

.file-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.encoding-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.encoding-badges .badge {
  font-size: 0.75rem;
  padding: 0.35em 0.65em;
}

@media (max-width: 575px) {
  .encoding-badges .badge {
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
  }
}

.encoding-help {
  line-height: 1.4;
}

@media (max-width: 575px) {
  .encoding-help {
    font-size: 0.75rem;
  }
  
  .encoding-help .help-text {
    display: inline-block;
    margin-left: 0.25rem;
  }
}

/* =================================================================
   変換オプション
   ================================================================= */

.conversion-options {
  margin-bottom: 1.5rem;
}

@media (max-width: 575px) {
  .conversion-options {
    margin-bottom: 1rem;
  }
  
  .conversion-options .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
  }
}

/* =================================================================
   GJ文字用WebFont
   ================================================================= */

/* GJ文字を表示するためのWebFont設定 */
.gj-font {
  font-family: 'ACGJMincho', serif;
  font-size: 1.1em;
  line-height: 1.6;
}

/* 変換結果表示用のスタイル */
.converted-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'ACGJMincho', 'IPAmjMincho', 'Noto Serif JP', 'Noto Serif CJK JP', 'Hiragino Mincho ProN', 'Yu Mincho', 'MS Mincho', serif !important;
  max-height: 500px;
  overflow-y: auto;
}

/* Binary viewer font for GJ/PUP/IVS */
.cc-binary-view,
.cc-binary-container,
.cc-binary-hex,
.cc-byte-label,
.cc-binary-row,
.cc-byte,
.cc-byte-group,
.cc-text-char {
  font-family: 'ACGJMincho', 'IPAmjMincho', 'Noto Serif JP', 'Noto Serif CJK JP', 'Hiragino Mincho ProN', 'Yu Mincho', 'MS Mincho', serif !important;
}

/* 変換種別バッジの色分け */
.badge.bg-pup { background-color: #ff9800 !important; } /* 橙色 */
.badge.bg-juki { background-color: #dc3545 !important; } /* 赤色 */
.badge.bg-gj { background-color: #28a745 !important; } /* 緑色 */
.badge.bg-ivs { background-color: #007bff !important; } /* 青色 */

/* エンコーディングバッジの追加スタイル */
.encoding-badges .badge {
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}

.encoding-badges .badge.bg-danger {
  font-weight: 600;
}

/* 信頼度バッジのスタイル */
.encoding-badges .badge[class*="信頼度"] {
  font-size: 0.7rem;
  opacity: 0.9;
}

/* =================================================================
   出力エリア
   ================================================================= */

.output-area {
  background: white;
  border-radius: 8px;
  min-height: 400px;
  overflow: auto;
  position: relative;
}

@media (max-width: 991px) {
  .output-area {
    min-height: 300px;
  }
}

@media (max-width: 575px) {
  .output-area {
    min-height: 250px;
    border-radius: 4px;
  }
}

.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: #6c757d;
}

@media (max-width: 991px) {
  .output-placeholder {
    height: 300px;
  }
}

@media (max-width: 575px) {
  .output-placeholder {
    height: 250px;
  }
}

.output-placeholder i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

@media (max-width: 575px) {
  .output-placeholder i {
    font-size: 2.5rem;
  }
}

/* =================================================================
   出力テーブル
   ================================================================= */

.output-table {
  width: 100%;
  font-size: 0.875rem;
}

.output-table th {
  background: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Mobile table adjustments */
@media (max-width: 767px) {
  .output-table {
    font-size: 0.75rem;
  }
  
  .output-table th,
  .output-table td {
    padding: 0.25rem;
  }
  
  .output-table th:nth-child(5),
  .output-table td:nth-child(5) {
    display: none; /* Hide conversion type on small screens */
  }
}

@media (max-width: 575px) {
  .table-responsive {
    margin: 0 -1rem;
    padding: 0 1rem;
  }
}

.original-char,
.converted-char {
  font-size: 1.25rem;
  font-weight: 500;
  font-family: 'ACGJMincho', serif;
}

@media (max-width: 575px) {
  .original-char,
  .converted-char {
    font-size: 1.1rem;
  }
}

.char-code {
  font-family: monospace;
  font-size: 0.75rem;
  color: #6c757d;
}

@media (max-width: 575px) {
  .char-code {
    font-size: 0.65rem;
  }
}

/* =================================================================
   プログレス・エラー表示
   ================================================================= */

.progress {
  margin-bottom: 1rem;
}

.converter-error {
  padding: 1rem;
  background: #f8d7da;
  border: 1px solid #f5c2c7;
  border-radius: 6px;
  color: #842029;
}

/* =================================================================
   モーダル固有のスタイル
   ================================================================= */

.close-converter {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 100;
}

/* Flexbox layout for better mobile handling */
@media (max-width: 991px) {
  #converter-ui .row {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  
  #converter-ui .col-lg-4,
  #converter-ui .col-lg-8 {
    width: 100%;
    max-width: 100%;
    flex: none;
  }
}

/* Fix gap between sections on mobile */
@media (max-width: 991px) {
  .converter-container .g-3 {
    --bs-gutter-x: 0;
    --bs-gutter-y: 0;
  }
}

/* Modal-specific responsive fixes */
@media (max-width: 991px) {
  .modal-body#converter-ui-container {
    padding: 0.5rem;
  }
}

@media (max-width: 575px) {
  .modal-body#converter-ui-container {
    padding: 0;
  }
  
  /* Remove all extra spacing in mobile modal */
  #converterModal .modal-content {
    border-radius: 0;
  }
  
  #converterModal .modal-body {
    padding: 0;
  }
}

/* Fix for modal-xl on smaller screens */
@media (max-width: 1199px) {
  #converterModal .modal-dialog.modal-xl {
    max-width: 95vw;
    margin: 0.5rem auto;
  }
}

@media (max-width: 575px) {
  #converterModal .modal-dialog {
    margin: 0;
    max-width: 100%;
  }
  
  #converterModal .modal-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
  }
  
  #converterModal .modal-body {
    flex: 1;
    overflow-y: auto;
  }
}

/* =================================================================
   アニメーション・トランジション
   ================================================================= */

/* Smooth transitions */
@media (prefers-reduced-motion: no-preference) {
  .converter-input-section,
  .converter-output-section,
  .drop-zone,
  .output-area {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* =================================================================
   Binary viewer (ported from JKV, scoped with cc- prefix)
   ================================================================= */
.cc-binary-wrapper {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 16px;
}

.cc-binary-view {
  display: block;
}

.cc-panel-binary {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.cc-binary-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #eef2f7;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
}

.cc-encoding-pill {
  background: #0d6efd;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.cc-binary-divider {
  display: none;
}

.cc-binary-container {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  overflow: auto;
  max-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.cc-binary-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid #f0f1f3;
  line-height: 1.5;
}

.cc-binary-row:last-child {
  border-bottom: none;
}

.cc-binary-row:hover {
  background-color: #f8f9fa;
}

.cc-binary-offset {
  flex: 0 0 80px;
  padding: 4px 8px;
  color: #6b7280;
  font-weight: 600;
  border-right: 1px solid #e5e7eb;
  background-color: #fafafa;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.cc-binary-hex {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 4px 12px;
  border-right: 1px solid #e5e7eb;
  gap: 4px;
}

.cc-byte {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 2em;
  height: 1.6em;
  padding: 0;
  margin: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  background: transparent;
  border: none;
  color: #4b5563;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cc-byte:hover,
.cc-byte.hover-sync {
  background: #e3f2fd;
  color: #0d6efd;
  font-weight: 600;
}

.cc-byte-divider {
  margin-right: 12px;
}

.cc-byte-newline,
.cc-newline {
  background-color: #f1f8ff;
  color: #0d6efd;
  border-radius: 2px;
}

.cc-byte-empty {
  visibility: hidden;
}

/* Removed cc-byte-group and cc-byte-label styles as they are no longer used */

.cc-binary-text {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px 12px;
  gap: 0;
  overflow: hidden;
}

.cc-text-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 1px;
  border-radius: 2px;
  cursor: pointer;
  min-width: 0.8em;
  height: 1.6em;
  line-height: 1.6;
}

.cc-text-char:hover,
.cc-text-char.hover-sync {
  background-color: #e3f2fd;
}

.cc-text-unknown {
  color: #9ca3af;
}

.cc-control-char {
  color: #9ca3af;
  font-size: 0.9em;
}

.cc-symbol {
  color: #0d6efd;
  font-weight: bold;
  opacity: 0.8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cc-control-code {
  color: #d1d5db;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cc-byte.highlight,
.cc-text-char.highlight {
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

.cc-binary-empty {
  padding: 10px;
  color: #6b7280;
}

/* Badge-style inline highlights for converted characters */
.converted-char.highlight-badge,
.original-char.highlight-badge {
  background: #fff3cd;
  border-radius: 4px;
  padding: 0 4px;
}

/* highlight colors per type */
.highlight-default {
  background: #6c757d !important; /* secondary */
  color: #fff !important;
  border-color: #6c757d !important;
}
.highlight-ivs {
  background: #0d6efd !important; /* primary (blue) */
  color: #fff !important;
  border-color: #0d6efd !important;
}
.highlight-juki {
  background: #dc3545 !important; /* danger (red) */
  color: #fff !important;
  border-color: #dc3545 !important;
}
.highlight-pup {
  background: #fd7e14 !important; /* warning (orange) */
  color: #212529 !important;
  border-color: #fd7e14 !important;
}
.highlight-gj {
  background: #198754 !important; /* success (green) */
  color: #fff !important;
  border-color: #198754 !important;
}

.converted-highlight {
  padding: 0 2px;
  border-radius: 3px;
}
