/**
 * EB-006: Percentage & Discount Calculator Stylesheet
 * Responsive, accessible layout adhering strictly to tokens.css
 */

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-12);
}

/* Tool Header */
.tool-header {
  text-align: center;
  max-width: 760px;
  margin: 0 auto var(--space-8);
}

.tool-badge-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-1) var(--space-3);
  background-color: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.tool-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-success);
}

.tool-title {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  line-height: 1.2;
}

.tool-description {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Global Preferences Bar (Currency & Precision) */
.preferences-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pref-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.pref-select {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  background-color: var(--surface-base);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.pref-select:focus {
  border-color: var(--brand-blue);
}

/* Navigation Tabs */
.tool-tabs-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.tool-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}

.tool-tab-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
}

.tool-tab-btn.active {
  color: var(--brand-blue);
  background-color: var(--brand-blue-subtle);
  border-color: var(--brand-blue);
}

/* Panels */
.mode-panel {
  display: none;
  animation: fadeIn var(--duration-fast) ease;
}

.mode-panel.active {
  display: block;
}

/* Everyday Percentage Cards Grid */
.everyday-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

@media (max-width: 768px) {
  .everyday-grid {
    grid-template-columns: 1fr;
  }
}

.calc-card {
  background-color: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.calc-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sentence-inputs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.num-input {
  width: 95px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  background-color: var(--surface-base);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
}

.num-input:focus {
  border-color: var(--brand-blue);
}

.result-box {
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-blue);
  font-feature-settings: "tnum";
}

.result-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Shopping Discount Layout */
.shopping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

@media (max-width: 860px) {
  .shopping-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.input-with-symbol {
  position: relative;
  display: flex;
  align-items: center;
}

.input-symbol {
  position: absolute;
  left: 12px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-symbol input {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) 28px;
  font-size: var(--text-sm);
  font-weight: 500;
  background-color: var(--surface-base);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
}

.input-with-symbol input:focus {
  border-color: var(--brand-blue);
}

/* Discount Result Highlight Card */
.highlight-result-card {
  background-color: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.highlight-price-row {
  margin-bottom: var(--space-5);
}

.highlight-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.highlight-price {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--color-success);
  line-height: 1.1;
}

.savings-banner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background-color: var(--brand-blue-subtle);
  color: var(--brand-blue);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-xs);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.breakdown-row strong {
  color: var(--text-primary);
}

/* Preset Chips */
.preset-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

.preset-chip {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.preset-chip:hover, .preset-chip.active {
  background-color: var(--brand-blue-subtle);
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

/* Step-by-Step Mathematical Explanation Drawer */
.steps-card {
  background-color: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-top: var(--space-6);
  font-size: var(--text-xs);
}

.steps-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.steps-content {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  line-height: 1.7;
}

.steps-content ol {
  padding-left: var(--space-4);
  margin: 0;
}

/* Calculation History Box */
.history-section {
  background-color: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-8);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.history-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 200px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background-color: var(--surface-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
}

.history-item span:first-child {
  color: var(--text-secondary);
}

.history-item strong {
  color: var(--brand-blue);
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-default);
  pointer-events: none;
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
