/* ============================================
   cipher.css - 暗号化・復号関連スタイル
   ============================================ */

/* 平文・暗号文テキストエリアの統一フォント */
#enc-plain, #dec-cipher, #enc-cipher, #dec-plain {
  font-size: 1.1rem;
  line-height: 1.6;
  word-break: break-all;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans JP", Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* マトリクス制御 */
.matrix-control {
  margin: 20px 0;
  text-align: center;
}

/* キー表示 */
.key-visual {
  margin: 12px 0;
  padding: 12px;
  background: rgba(106, 166, 255, 0.05);
  border: 1px solid rgba(106, 166, 255, 0.2);
  border-radius: 8px;
  font-size: 0.95rem;
}

.key-badge {
  display: inline-block;
  padding: 4px 8px;
  margin: 0 2px;
  background: var(--accent);
  color: #071018;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.9rem;
}

:root[data-theme="light"] .key-badge {
  color: #ffffff;
}

/* マトリクス凡例 */
.matrix-legend {
  display: flex;
  gap: 20px;
  margin: 12px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-sample {
  display: inline-block;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  border-radius: 4px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono", monospace;
}

.legend-sample.plaintext {
  background: rgba(106, 166, 255, 0.1);
  color: var(--fg);
  border: 1px solid rgba(106, 166, 255, 0.3);
}

.legend-sample.pad {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.legend-sample.empty {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
}

/* グリッド表示 */
.gridwrap {
  overflow-x: auto;
  margin: 16px 0;
}

.table {
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono", monospace;
  font-size: 1.1rem;
  width: auto;
  margin: 0 auto;
}

.table th, .table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: center;
  min-width: 40px;
}

.table thead th {
  background: rgba(106, 166, 255, 0.05);
  color: var(--accent);
  font-weight: 700;
}

:root[data-theme="light"] .table thead th {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
}

.table tbody th {
  background: rgba(148, 163, 184, 0.05);
  color: var(--muted);
  font-weight: 600;
}

.table th.highlight { 
  background: var(--accent); 
  color: #071018; 
}

/* マトリクスセルの色分け */
.table td.plaintext {
  background: rgba(106, 166, 255, 0.05);
  color: var(--fg);
}

.table td.pad {
  background: rgba(255, 107, 107, 0.05);
  color: var(--danger);
  font-style: italic;
}

.table td.empty {
  background: transparent;
  color: var(--muted);
  opacity: 0.5;
}

.table td.column-highlight { 
  background: rgba(106, 166, 255, 0.35) !important;
  color: var(--fg);
  font-weight: 700;
}

.table th.column-highlight { 
  background: rgba(106, 166, 255, 0.5) !important;
  color: var(--fg);
  font-weight: 700;
}

.table td.highlight { 
  background: var(--accent);
  color: #071018;
  font-weight: 700;
}

/* 暗号文ハイライト表示 */
.cipher-display {
  padding: 16px;
  background: #0f1420;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono", monospace;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  line-height: 1.8;
  word-break: break-all;
}

:root[data-theme="light"] .cipher-display {
  background: #f8fafc;
}

.cipher-char {
  display: inline-block;
  padding: 2px 4px;
  margin: 1px;
  border-radius: 3px;
  transition: all 0.2s;
  cursor: pointer;
}

.cipher-char:hover {
  background: rgba(106, 166, 255, 0.2);
}

.cipher-char.highlighted {
  background: rgba(106, 166, 255, 0.25);
  color: var(--fg);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

/* 復号結果ハイライト表示 */
.plain-char {
  display: inline-block;
  padding: 2px 4px;
  margin: 1px;
  border-radius: 3px;
  transition: all 0.2s;
  cursor: default;
}