/* styleCalculator.css */

/* ─── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

/* margin:0 is critical for iframe fit — WordPress adds its own page padding */
html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  color: #222;
  background: #fff;
  padding: 10px 12px 20px;
}

h2 {
  margin: 16px 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: #111;
}

/* ─── Toolbar ───────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ctrl-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.ctrl-text {
  white-space: nowrap;
  color: #555;
}

.ctrl-autototal {
  margin-left: 2px;
}

.toolbar-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  line-height: 1.6;
}

/* ─── Inputs ────────────────────────────────────────────────── */
input[type="number"],
input[type="text"] {
  padding: 5px 7px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

input[type="number"] {
  width: 60px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Buttons ───────────────────────────────────────────────── */
button {
  padding: 6px 11px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  transition: background .15s;
}

button:hover:not(:disabled) {
  background: #f3f3f3;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#btnCreate {
  background: #1a7f37;
  color: #fff;
  border-color: #1a7f37;
  font-weight: 600;
}

#btnCreate:hover:not(:disabled) {
  background: #176931;
}

#btnAddCategory {
  background: #0969da;
  color: #fff;
  border-color: #0969da;
}

#btnAddCategory:hover:not(:disabled) {
  background: #0758c2;
}

/* ─── Pills ─────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid #ccc;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill--auto {
  border-color: #0969da;
  color: #0969da;
  background: #f0f6ff;
}

.pill--fix {
  border-color: #8250df;
  color: #6e40c9;
  background: #fbf0ff;
}

.pill--out {
  border-color: #9a9a9a;
  color: #666;
  background: #f5f5f5;
}

/* ─── Status & utility text ─────────────────────────────────── */
.small {
  font-size: 12px;
  color: #666;
}

.warn {
  color: #8a5a00;
}

.err {
  color: #b00020;
}

.ok {
  color: #1a7f37;
}

.muted {
  opacity: .55;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ─── Table scroll wrapper ───────────────────────────────────── */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
}

/* ─── Tables ────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
}

th, td {
  border: 1px solid #eaeaea;
  padding: 5px 6px;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f7f7f7;
  font-size: 12px;
  font-weight: 600;
  color: #444;
}

.row-error td {
  background: #fff5f5;
}

/* ─── Person name input in header ──────────────────────────── */
.name-input {
  width: 76px;
  font-size: 12px;
  padding: 3px 5px;
}

/* ─── Cell: mode button + fixed input ──────────────────────── */
.cell {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 2px;
}

/* ─── Mode & preset buttons ─────────────────────────────────── */
.mode-btn {
  width: 52px;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}

.mode-btn[data-value="auto"] {
  border-color: #0969da;
  color: #0969da;
  background: #f0f6ff;
}

.mode-btn[data-value="fix"] {
  border-color: #8250df;
  color: #6e40c9;
  background: #fbf0ff;
}

.mode-btn[data-value="out"] {
  border-color: #9a9a9a;
  color: #666;
  background: #f5f5f5;
}

.preset-btn {
  width: 130px;
  padding: 4px 7px;
  font-size: 12px;
  text-align: left;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Fixed-amount inputs in cells ──────────────────────────── */
.cell input[type="number"] {
  width: 76px;
  font-size: 12px;
  padding: 3px 5px;
}

/* ─── Width classes for main table ──────────────────────────── */
.w-desc {
  width: 140px;
}

.w-total {
  width: 100px;
}

/* ─── Width classes for category table ──────────────────────── */
.w-cat {
  width: 130px;
}

.w-amt {
  width: 95px;
}

.w-note {
  width: 140px;
}

.w-paid {
  width: 80px;
}

/* ─── Overview / summary tables ─────────────────────────────── */
[data-role="overview-wrap"] table,
[data-role="summary-wrap"] table {
  width: 100%;
}

/* ─── Mobile ≤ 600px ─────────────────────────────────────────── */
@media (max-width: 600px) {
  body {
    padding: 8px 8px 24px;
    font-size: 13px;
  }

  h2 {
    font-size: 14px;
    margin: 12px 0 5px;
  }

  .toolbar-legend {
    font-size: 11px;
  }

  /* Compact table cells */
  th, td {
    padding: 4px 4px;
  }

  /* Smaller person name input */
  .name-input {
    width: 60px;
    font-size: 11px;
  }

  /* Narrower main inputs */
  .w-desc {
    width: 100px;
  }

  .w-total {
    width: 82px;
  }

  .w-cat {
    width: 90px;
  }

  .w-amt {
    width: 78px;
  }

  .w-paid {
    width: 64px;
  }

  /* Smaller mode & fixed */
  .mode-btn {
    width: 44px;
    font-size: 10px;
    padding: 3px 0;
  }

  .cell input[type="number"] {
    width: 62px;
    font-size: 11px;
    padding: 3px 4px;
  }

  /* Smaller preset button */
  .preset-btn {
    width: 100px;
    font-size: 11px;
    padding: 3px 5px;
  }

  /* Hide Note column — not critical on mobile */
  .col-note {
    display: none;
  }
}

/* ─── Very small screens ≤ 380px ─────────────────────────────── */
@media (max-width: 380px) {
  .w-cat {
    width: 72px;
  }

  .w-amt {
    width: 66px;
  }

  .cell input[type="number"] {
    width: 54px;
  }

  .preset-btn {
    width: 86px;
    font-size: 10px;
  }

  /* Hide delete button text, keep compact */
  [data-role="cat-del"] {
    padding: 3px 6px;
    font-size: 14px;
  }
}
