/* ============================================================
   OKUMA GENOS CONVERTER — DARK INDUSTRIAL THEME (CYAN)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Barlow+Condensed:wght@300;400;600;700;900&display=swap');

:root {
  --bg:      #0a0c0f;
  --panel:   #111418;
  --panel2:  #161b22;
  --border:  #1e2530;
  --accent:  #00c8ff;
  --accent2: #33d4ff;
  --green:   #00e676;
  --orange:  #ff6b00;
  --red:     #ff3b3b;
  --yellow:  #ffd600;
  --text:    #cdd6e0;
  --dim:     #4a5568;
  --mono:    'Share Tech Mono', monospace;
  --sans:    'Barlow Condensed', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0,200,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,200,255,0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none; z-index: 0;
}

/* ── WRAPPER ── */
.wrapper {
  position: relative; z-index: 1;
  max-width: 1440px; margin: 0 auto;
  padding: 0 28px 100px;
}

/* ── HEADER ── */
header {
  padding: 28px 0 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand-name {
  font-family: var(--sans);
  font-size: 34px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; color: #fff; line-height: 1;
}
.brand-name span { color: var(--accent); }
.brand-sub {
  font-family: var(--mono); font-size: 11px;
  color: var(--dim); letter-spacing: 1px;
}
.status-pill {
  font-family: var(--mono); font-size: 11px;
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid var(--accent); color: var(--accent);
  letter-spacing: 1px; animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ── LAYOUT ── */
.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px; align-items: start;
}
@media(max-width:900px) { .main-grid { grid-template-columns: 1fr; } }

.left-col  { display: flex; flex-direction: column; gap: 20px; }
.right-col { display: flex; flex-direction: column; gap: 24px; }

/* ── PANELS ── */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; }
.panel-head {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: 3px;
  text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: 8px;
}
.panel-head .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.panel-head-count {
  color: var(--dim); font-size: 10px; margin-left: auto;
}
.panel-body { padding: 18px; }

/* ── DROP ZONE ── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: 4px;
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s; position: relative;
}
.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--accent); background: rgba(0,200,255,0.04); }
.drop-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0;
  cursor: pointer; width: 100%; height: 100%;
}
.drop-icon  { font-size: 32px; margin-bottom: 10px; }
.drop-label { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.drop-sub   { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 6px; }

.file-loaded { background: rgba(0,230,118,0.06); border-color: var(--green); padding: 16px 20px; }
.file-name   { font-family: var(--mono); font-size: 13px; color: var(--green); word-break: break-all; }
.file-meta   { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 4px; }
.file-change { font-family: var(--mono); font-size: 11px; color: var(--accent); margin-top: 6px; }

/* ── SETTINGS ── */
.setting-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; font-weight: 600; letter-spacing: .5px; }
.setting-desc  { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 2px; }

.num-input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--accent); font-family: var(--mono); font-size: 18px;
  width: 64px; text-align: center; padding: 6px 4px;
  border-radius: 3px; outline: none; transition: border-color .15s;
}
.num-input:focus { border-color: var(--accent); }

/* ── BUTTONS ── */
.btn-convert {
  width: 100%; padding: 16px;
  background: var(--accent); color: #000; border: none;
  border-radius: 3px; font-family: var(--sans); font-size: 20px;
  font-weight: 900; letter-spacing: 3px; text-transform: uppercase;
  cursor: pointer; transition: background .15s, transform .1s;
}
.btn-convert:hover   { background: var(--accent2); }
.btn-convert:active  { transform: scale(.98); }
.btn-convert:disabled { background: var(--dim); color: #333; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-sm {
  flex: 1; padding: 8px 10px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text); font-family: var(--sans); font-size: 13px;
  font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
  border-radius: 3px; cursor: pointer;
  transition: border-color .15s, color .15s; text-align: center;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.btn-add-confirm {
  padding: 8px 18px; background: var(--green); color: #000;
  border: none; border-radius: 3px; font-family: var(--sans);
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; align-self: flex-end; transition: background .15s;
}
.btn-add-confirm:hover { background: #33ffb0; }

/* ── TOOL TABLE ── */
.tool-search {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; color: var(--text); font-family: var(--mono);
  font-size: 13px; padding: 8px 12px; outline: none;
  margin-bottom: 12px; transition: border-color .15s;
}
.tool-search:focus { border-color: var(--accent); }

.tool-table-wrap { max-height: 280px; overflow-y: auto; }
.tool-table-wrap::-webkit-scrollbar { width: 4px; }
.tool-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

table { width: 100%; border-collapse: collapse; }
th {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: #000; padding: 6px 10px; text-align: left;
  border-bottom: 2px solid rgba(0,0,0,0.3);
  position: sticky; top: 0; z-index: 1;
  background: #00c8ff;
  cursor: pointer; user-select: none;
}
td {
  font-family: var(--mono); font-size: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(30,37,48,.6);
  vertical-align: middle;
}
tr:hover td { background: rgba(0,200,255,0.04); }
td.serial    { color: var(--orange); }
td.okuma-num { color: var(--accent); font-weight: bold; }
td.desc {
  color: var(--dim); font-size: 11px;
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 140px;
}
.btn-remove {
  background: none; border: none; color: var(--dim);
  cursor: pointer; font-size: 14px; padding: 0;
  transition: color .15s;
}
.btn-remove:hover { color: var(--red); }

/* ── ADD TOOL FORM ── */
.add-tool-form {
  display: none; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 14px; margin-top: 12px;
  gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.add-tool-form.open { display: flex; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 100px; }
.form-group label {
  font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--dim);
}
.form-group input {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 13px;
  padding: 7px 10px; border-radius: 3px; outline: none; width: 100%;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }

/* ── DOWNLOAD BAR ── */
.download-bar {
  display: none; align-items: center; justify-content: space-between;
  background: rgba(0,230,118,0.08); border: 1px solid var(--green);
  border-radius: 4px; padding: 14px 20px; gap: 16px; flex-wrap: wrap;
}
.download-bar.show { display: flex; }
.dl-info { font-size: 16px; font-weight: 700; color: var(--green); letter-spacing: 1px; }
.dl-info span { font-family: var(--mono); font-size: 12px; color: var(--dim); display: block; margin-top: 2px; }
.btn-download {
  padding: 12px 28px; background: var(--green); color: #000;
  border: none; border-radius: 3px; font-family: var(--sans);
  font-size: 18px; font-weight: 900; letter-spacing: 2px;
  text-transform: uppercase; cursor: pointer; text-decoration: none;
  display: inline-block; transition: background .15s;
}
.btn-download:hover { background: #33ffb0; }

/* ── STATS ── */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box {
  flex: 1; min-width: 100px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 12px 16px; text-align: center;
}
.stat-val { font-family: var(--mono); font-size: 28px; font-weight: bold; color: var(--accent); }
.stat-val.warn { color: var(--yellow); }
.stat-val.ok   { color: var(--green); }
.stat-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); margin-top: 4px; }

/* ── LOG ── */
.log-box {
  background: var(--bg); border-radius: 3px;
  font-family: var(--mono); font-size: 12px;
  line-height: 1.7; padding: 14px 16px;
  min-height: 120px; max-height: 220px; overflow-y: auto;
}
.log-box::-webkit-scrollbar { width: 4px; }
.log-box::-webkit-scrollbar-thumb { background: var(--border); }
.log-info  { color: var(--dim); }
.log-ok    { color: var(--green); }
.log-warn  { color: var(--yellow); }
.log-same  { color: #7ec8e3; }  /* pale blue — already correct */
.log-error { color: var(--red); }
.log-map   { color: var(--orange); }

/* ── CODE PREVIEW ── */
.code-compare {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
@media(max-width:700px) { .code-compare { grid-template-columns: 1fr; } }

.code-pane { background: var(--bg); }
.code-pane-head {
  padding: 8px 14px; font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.code-pane-head.orig { color: var(--dim); }
.code-pane-head.conv { color: var(--accent); }
.code-scroll {
  overflow-y: auto; max-height: 400px;
  padding: 12px 14px; font-family: var(--mono);
  font-size: 11.5px; line-height: 1.8; white-space: pre;
}
.code-scroll::-webkit-scrollbar { width: 4px; }
.code-scroll::-webkit-scrollbar-thumb { background: var(--border); }
.line-changed { background: rgba(0,200,255,0.09); color: var(--accent); display: block; }
.line-same    { background: rgba(255,214,0,0.07); color: #b8a800; display: block; }  /* pale yellow — tool# already matched */
.line-normal  { display: block; color: var(--text); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--dim); }
.empty-state .big { font-size: 48px; margin-bottom: 12px; opacity: .25; }
.empty-state p { font-size: 14px; letter-spacing: 1px; }

/* ── FLOATING APP SWITCHER ── */
.app-switcher {
  position: fixed; bottom: 28px; right: 28px; z-index: 9998;
  display: flex; background: var(--panel); border: 1px solid var(--border);
  border-radius: 50px; padding: 5px; gap: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.switcher-btn {
  padding: 9px 18px; border-radius: 40px; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  transition: color .2s; white-space: nowrap;
}
.switcher-btn.current { background: var(--accent); color: #000; cursor: default; }
.switcher-btn.other   { background: transparent; color: var(--dim); }
.switcher-btn.other:hover { color: var(--green); }

/* ── MATCH TYPE TOGGLE ── */
.match-type-row {
  display: flex; gap: 8px; width: 100%; margin-bottom: 6px;
}
.match-type-btn {
  flex: 1; padding: 7px; border-radius: 3px;
  border: 1px solid var(--border); background: transparent;
  color: var(--dim); font-family: var(--sans); font-size: 12px;
  font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; transition: all .15s;
}
.match-type-btn.active {
  background: var(--orange); border-color: var(--orange); color: #000;
}
.match-type-btn:not(.active):hover { border-color: var(--text); color: var(--text); }

.match-type-hint {
  width: 100%; font-family: var(--mono); font-size: 10px;
  color: var(--orange); margin-bottom: 8px; line-height: 1.5;
}

/* ── CONVERTER SUB-TABS ── */
.conv-tab-bar {
  display: flex; gap: 4px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.conv-tab-btn {
  padding: 9px 20px; font-family: var(--sans); font-size: 13px;
  font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  border: none; background: transparent; color: var(--dim); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.conv-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.conv-tab-btn:hover:not(.active) { color: var(--text); }
.conv-tab-pane { display: none; }
.conv-tab-pane.active { display: block; }

/* ── PDF PREVIEW ── */
.pdf-preview-wrap {
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg);
  overflow: auto; max-height: 520px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.pdf-page-canvas {
  border: 1px solid var(--border); border-radius: 2px;
  max-width: 100%; display: block; margin: 0 auto;
}
@media(max-width:600px) {
  .wrapper { padding: 0 14px 80px; }
  .brand-name { font-size: 26px; }
  .app-switcher { bottom: 16px; right: 16px; }
  .switcher-btn { padding: 8px 12px; font-size: 11px; }
}

/* ── ROW HOVER ACTIONS — right side, fade in on hover ── */
.lib-row { position: relative; }
.lib-row-actions {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 2px;
  padding: 0 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  background: linear-gradient(to right, transparent, var(--panel) 30%);
}
.lib-row:hover .lib-row-actions,
.lib-row:focus-within .lib-row-actions {
  opacity: 1;
  pointer-events: all;
}
.lib-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 4px 6px; border-radius: 3px;
  transition: background .12s, color .12s; line-height: 1;
}
.lib-edit   { color: var(--accent); }
.lib-delete { color: var(--dim); }
.lib-edit:hover   { background: rgba(0,200,255,0.15); }
.lib-delete:hover { background: rgba(255,59,59,0.15); color: var(--red); }

/* ── MEDIUM SCREEN RESPONSIVE FIXES ── */
@media (max-width: 1400px) {
  .wrapper { padding: 0 16px 100px; }
  .main-grid { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 1280px) {
  .main-grid { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .tool-table-wrap { max-height: 200px; }
  .code-scroll { max-height: 280px; }
}
@media (max-width: 1000px) and (min-width: 901px) {
  .code-compare { grid-template-columns: 1fr; }
  .code-scroll  { max-height: 180px; }
  .btn-download { padding: 10px 16px; font-size: 15px; letter-spacing: 1px; }
  .dl-info      { font-size: 14px; }
}
@media (max-width: 900px) {
  .code-compare { grid-template-columns: 1fr; }
  .code-scroll  { max-height: 220px; }
}

/* ── CARD NAV ── */
.card-nav {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,200,255,0.05);
  border-bottom: 1px solid var(--accent);
  padding: 10px 14px;
}
.card-nav-btn {
  background: var(--accent); border: none;
  color: #000; font-size: 18px; font-weight: 700;
  padding: 6px 18px; border-radius: 3px;
  cursor: pointer; transition: opacity .1s;
  flex-shrink: 0; line-height: 1;
}
.card-nav-btn:hover:not([disabled]) { opacity: 0.8; }
.card-nav-btn[disabled] { opacity: 0.2; cursor: default; }
.card-nav-label {
  font-family: var(--mono); font-size: 12px;
  display: flex; align-items: center; flex: 1;
  justify-content: center; overflow: hidden;
  flex-direction: column; gap: 2px; text-align: center;
}
.card-nav-counter {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--dim);
}
.card-nav-filename {
  color: var(--text); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 300px;
}

/* ── DOWNLOAD ALL BUTTON ── */
.btn-download-all {
  padding: 7px 14px;
  background: var(--green); border: none; color: #000;
  font-family: var(--sans); font-size: 12px; font-weight: 700;
  letter-spacing: 1px; border-radius: 3px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: opacity .1s;
}
.btn-download-all:hover { opacity: 0.85; }

/* ── CARD NAV PER-FILE DOWNLOAD ── */
.card-nav-download {
  padding: 5px 10px;
  background: var(--green); border: none; color: #000;
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 1px; border-radius: 3px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0; text-decoration: none;
  transition: opacity .1s; display: inline-block;
}
.card-nav-download:hover { opacity: 0.85; }

@media (max-width: 1550px) {
  .code-compare  { grid-template-columns: 1fr 1fr; overflow: hidden; }
  .code-pane     { min-width: 0; overflow: hidden; }
  .code-scroll   { max-height: 310px; overflow-x: auto; overflow-y: auto; white-space: pre; }
  .download-bar  { flex-wrap: nowrap; }
  .dl-info       { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn-download  { padding: 10px 14px; font-size: 14px; letter-spacing: 1px; flex-shrink: 0; }
}
