/* ============================================================
   계산기 — 우측 갤럭시 엣지 위젯 11번째 (panel.css)
   ============================================================
   톤: 갤럭시 단색 (Sky/Indigo)
   특징: 버튼식 + 단위 변환 탭 + 히스토리 localStorage
   ============================================================ */

.calcapp-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
  padding: 12px 12px 16px;
  box-sizing: border-box;
}

/* ─── 탭 ─── */
.calc-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 100px;
}
.calc-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 12px;
  background: transparent;
  color: #64748b;
  border: 0;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.calc-tab.is-active {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.calc-pane { display: none; flex-direction: column; gap: 10px; flex: 1 1 auto; }
.calc-pane.is-active { display: flex; }

/* ─── 디스플레이 ─── */
.calc-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0c4a6e 0%, #1e1b4b 100%);
  border-radius: 14px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);
}
.calc-expr {
  min-height: 16px;
  font-size: 12px;
  color: #c7d2fe;
  font-weight: 600;
  text-align: right;
  word-break: break-all;
  opacity: 0.85;
}
.calc-result {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  text-align: right;
  word-break: break-all;
  letter-spacing: 0.01em;
}

/* ─── 버튼 그리드 ─── */
.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.calc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
}
.calc-key:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}
.calc-key:active { transform: scale(0.96); }

.calc-key.op {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}
.calc-key.op:hover { background: #e0e7ff; }

.calc-key.func {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
  font-size: 13px;
}
.calc-key.func:hover { background: #e2e8f0; }

.calc-key.equals {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  border-color: #4f46e5;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
.calc-key.equals:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(79, 70, 229, 0.35); }

.calc-key.clear { color: #dc2626; }
.calc-key.span-2 { grid-column: span 2; }

/* ─── 히스토리 ─── */
.calc-history-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 110px;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.calc-history-wrap::-webkit-scrollbar { width: 6px; }
.calc-history-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.calc-hist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}
.calc-hist-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}
.calc-hist-clear {
  background: transparent;
  border: 0;
  font-size: 10px;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.calc-hist-clear:hover { color: #dc2626; background: rgba(239, 68, 68, 0.06); }

.calc-hist-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.calc-hist-row:hover { background: rgba(79, 70, 229, 0.04); border-color: #818cf8; }
.calc-hist-expr {
  font-size: 11px;
  color: #64748b;
  word-break: break-all;
}
.calc-hist-res {
  font-size: 13px;
  color: #0f172a;
  font-weight: 700;
  word-break: break-all;
}

.calc-empty {
  padding: 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
}

/* ─── 단위 변환 ─── */
.unit-cat-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 2px;
}
.unit-cat-btn {
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.unit-cat-btn:hover { border-color: #818cf8; }
.unit-cat-btn.is-active {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  border-color: #4f46e5;
}

.unit-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.unit-input {
  width: 100%;
  padding: 9px 10px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  box-sizing: border-box;
  font-family: inherit;
  text-align: right;
}
.unit-input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}
.unit-select {
  width: 100%;
  padding: 8px 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
}
.unit-divider {
  text-align: center;
  font-size: 16px;
  color: #94a3b8;
  font-weight: 700;
  padding: 2px 0;
}

.unit-tip {
  padding: 8px 10px;
  background: linear-gradient(135deg, #f0f9ff 0%, #eef2ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  font-size: 11px;
  color: #4338ca;
  line-height: 1.4;
}
.unit-tip strong { color: #0c4a6e; }

/* ─── 토스트 ─── */
.calc-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 100px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}
.calc-toast.is-visible { opacity: 1; }
