/* ============================================================
   Spellcraft Calculator — Thème sombre DAoC
   ============================================================ */
:root {
  --bg0:      #0d1117;
  --bg1:      #161b22;
  --bg2:      #21262d;
  --bg3:      #2d333b;
  --border:   #30363d;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --gold:     #d4a017;
  --gold-l:   #f0c040;
  --green:    #3fb950;
  --yellow:   #d29922;
  --red:      #f85149;
  --blue:     #58a6ff;
  --radius:   6px;
  --shadow:   0 4px 16px rgba(0,0,0,.5);
}
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; padding: 0;
  background: var(--bg0);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
}

/* ---- TOP BAR ---- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.app-title {
  font-size: 18px; font-weight: 700; color: var(--gold);
  white-space: nowrap; margin-right: 8px;
}
#build-name {
  flex: 1; max-width: 280px;
  padding: 5px 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14px;
}
.build-controls { display: flex; gap: 8px; align-items: center; }

/* ---- LAYOUT ---- */
#main-layout {
  display: grid;
  grid-template-columns: 200px 1fr 380px;
  grid-template-rows: 1fr;
  height: calc(100vh - 50px);
  overflow: hidden;
}

/* ---- SIDE PANELS ---- */
#char-panel, #item-editor {
  overflow-y: auto;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  padding: 16px;
}
#item-editor { border-right: none; border-left: 1px solid var(--border); }
#item-editor.hidden { display: none; }

#char-panel h3, #item-editor h3, #char-panel h4, #item-editor h4 {
  color: var(--gold); margin: 0 0 12px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
}

/* ---- FORM ELEMENTS ---- */
.form-group { margin-bottom: 10px; }
.form-group label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }

select, input[type=text], input[type=number] {
  width: 100%;
  padding: 5px 8px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px;
  transition: border-color .15s;
}
select:focus, input:focus { outline: none; border-color: var(--gold); }
select:disabled, input:disabled { opacity: .5; cursor: not-allowed; }

/* ---- BUTTONS ---- */
.btn {
  padding: 6px 14px; border-radius: var(--radius); border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: var(--gold); color: #000; }
.btn-secondary{ background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-danger   { background: var(--red);  color: #fff; }

/* ---- TOTALS (char panel bottom) ---- */
#build-totals { margin-top: 20px; }
#build-totals .stat-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; border-bottom: 1px solid var(--bg3);
  font-size: 13px;
}
#build-totals .stat-row span:last-child { color: var(--gold); font-weight: 600; }

/* ---- EQUIPMENT GRID ---- */
#equipment-grid {
  overflow-y: auto; padding: 16px;
  background: var(--bg0);
}
.eq-section { margin-bottom: 20px; }
.eq-section h4 {
  color: var(--gold-l); font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px;
}
.slot-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

/* ---- SLOT CARD ---- */
.slot-card {
  background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 70px;
  position: relative;
}
.slot-card:hover { background: var(--bg2); border-color: var(--gold); }
.slot-card .slot-add {
  display: flex; align-items: center; justify-content: center;
  height: 36px; color: var(--muted); font-size: 12px; gap: 5px;
  border: 1px dashed var(--bg3); border-radius: var(--radius);
  margin-top: 4px; transition: color .15s, border-color .15s;
}
.slot-card:hover .slot-add { color: var(--gold-l); border-color: var(--gold); }
.slot-card.active { border-color: var(--gold); background: var(--bg2); }
.slot-card.oc-ok     { border-left: 3px solid var(--green); }
.slot-card.oc-risky  { border-left: 3px solid var(--yellow); }
.slot-card.oc-impossible { border-left: 3px solid var(--red); }

.slot-card .slot-name {
  font-size: 12px; font-weight: 700; color: var(--gold); margin-bottom: 4px;
}
.slot-card .slot-summary {
  font-size: 11px; color: var(--muted); line-height: 1.6;
}
.slot-card .slot-imbue {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; color: var(--blue); font-weight: 600;
}

/* ---- ITEM EDITOR ---- */
#editor-header { margin-bottom: 14px; }
.editor-header-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.editor-header-top h3 {
  margin: 0; border-bottom: none !important; padding-bottom: 0 !important;
}
#state-toggle { display: flex; gap: 6px; }
.state-btn { padding: 3px 10px; font-size: 12px; font-weight: 700; }
.state-btn.drop-active { background: var(--blue); color: #000; }
.state-btn.sc-active   { background: var(--gold); color: #000; }
.item-meta { display: grid; grid-template-columns: 1fr 70px 80px; gap: 6px; margin-top: 8px; }
.item-meta label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.item-meta input, .item-meta select { width: 100%; }

/* Rows de gemmes */
#gem-slots { margin-bottom: 14px; }
.slot-row {
  display: grid;
  grid-template-columns: 18px 90px 1fr 70px 38px;
  gap: 4px; align-items: center;
  margin-bottom: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--bg3);
}
.slot-row:last-child { border-bottom: none; }
.slot-row.is-drop { grid-template-columns: 18px 90px 1fr 70px; }
.slot-num { font-size: 11px; color: var(--muted); text-align: center; font-weight: 700; }
.slot-row select { font-size: 12px; padding: 3px 4px; }
.slot-row input[type=number] { font-size: 12px; padding: 3px 4px; width: 38px; }

/* Gem result tags (below the row) */
.gem-result {
  grid-column: 1 / -1;
  display: flex; gap: 6px; align-items: center;
  padding: 2px 0 2px 22px;
  font-size: 11px;
}
.gem-result .gem-name  { color: var(--blue); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag {
  padding: 1px 6px; border-radius: 10px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.tag-imbue { background: rgba(88,166,255,.15); color: var(--blue); }
.tag-cost  { background: rgba(212,160,23,.15);  color: var(--gold); }
.tag-util  { background: rgba(63,185,80,.15);   color: var(--green); }

/* Item summary */
#item-summary {
  background: var(--bg2); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 14px;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; border-bottom: 1px solid var(--bg3);
  font-size: 13px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .label { color: var(--muted); }
.imbue-val  { color: var(--blue); font-weight: 700; }
.cost-val   { color: var(--gold); font-weight: 700; }
.util-val   { color: var(--green); font-weight: 700; }
.oc-sure    { color: var(--green); font-weight: 700; }
.oc-risky   { color: var(--yellow); font-weight: 700; }
.oc-hard    { color: var(--red); font-weight: 700; }
.oc-none    { color: var(--muted); }

/* Materials */
#materials-list h4 { margin-top: 0; }
#materials-content {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.mat-section { margin-bottom: 8px; }
.mat-section h5 {
  font-size: 11px; text-transform: uppercase; color: var(--muted);
  margin: 0 0 4px; letter-spacing: .06em;
}
.mat-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 2px 0; border-bottom: 1px solid var(--bg3);
}
.mat-row span:last-child { color: var(--gold); font-weight: 600; }

/* ---- MODAL ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; min-width: 320px; max-width: 500px; width: 90%;
  box-shadow: var(--shadow);
}
.modal-box h3 { margin: 0 0 14px; color: var(--gold); }
.modal-close { float: right; cursor: pointer; color: var(--muted); font-size: 18px; }
.build-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px; margin-bottom: 6px;
  background: var(--bg2); border-radius: var(--radius); cursor: pointer;
  border: 1px solid transparent; transition: border-color .15s;
}
.build-list-item:hover { border-color: var(--gold); }
.build-list-item .bi-name { font-weight: 600; }
.build-list-item .bi-meta { font-size: 12px; color: var(--muted); }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg0); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }

/* ---- RESPONSIVE (mobile) ---- */
@media (max-width: 900px) {
  #main-layout { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; }
  #item-editor { border-left: none; border-top: 1px solid var(--border); }
  #item-editor.hidden { display: none; }
  .slot-cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
