@import "../../water.min.css";

/* Base layout adjustments */
body {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

/* 4-card layout grid */
.calculator-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

@media (min-width: 768px) {
    .calculator-container {
        grid-template-columns: 1fr 1fr;
    }
    
    /* Left column – output remains at the top */
    .card-output {
        grid-column: 1 / 2;
        grid-row: 1;
        order: -1;
    }
    
    /* Underlying Data – top of right column */
    .card-underlying {
        grid-column: 2 / 3;
        grid-row: 1;
    }
    
    /* Original Inputs – bottom of right column */
    .card-inputs {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
    }
    
    /* Mathematical details – left column, automatically flows to row 2 */
    .card-math {
        grid-column: 1 / 2;
    }
}

/* Card Styling using Water.css variables */
.card {
    background-color: var(--background-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-sizing: border-box;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    font-size: 1.4em;
}

/* Card 1: Output Display (also used for the solve result card) */
.card-output {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;   /* content starts at the top */
    align-items: center;
    text-align: center;
}

.price-display {
    margin: 20px 0;
}

.price-value {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

/* Card 2: Inputs Form */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 4px;
}

.error-message {
    display: block;
    font-size: 0.85em;
    color: #ff4a4a;
    min-height: 1.2em;
    margin-top: 4px;
}

/* ---------- Radio buttons inside the solve card ---------- */
#solve-selector .radio-label {
    display: inline-flex;
    align-items: center;
    margin-right: 1em;
    margin-bottom: 0.5em;
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Card 3: Mathematical Details */
.formulas {
    background-color: var(--background);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.formula-block {
    margin-bottom: 10px;
    font-size: 0.9em;
}

.formula-block:last-child {
    margin-bottom: 0;
}

.formula-label {
    display: block;
    font-weight: bold;
    color: var(--text-muted);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.formula-expr {
    font-family: monospace;
    display: block;
    padding-left: 8px;
    color: var(--text-bright);
}

.intermediate-values h3 {
    font-size: 1.1em;
    margin-top: 0;
    margin-bottom: 12px;
}

.math-values-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 0;
}

.math-values-list dt {
    font-weight: bold;
    font-family: monospace;
}

.math-values-list dd {
    margin: 0;
    font-family: monospace;
    color: var(--text-bright);
}

/* Test styles – styled like cards with blue‑red contrast */
.summary {
  font-weight: bold;
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
}
.summary.success {
  background: #cce5ff;
  color: #004085;
  border: 1px solid #b8daff;
}
.summary.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.test-case {
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-left: 5px solid #ccc;
  border-radius: 8px;
  padding: 12px 15px;
  margin-bottom: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
}

.test-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.test-case.pass {
  border-left-color: #3578e5;  /* blue for pass */
}

.test-case.fail {
  border-left-color: #dc3545;  /* red for fail */
}

.test-name {
  word-break: break-word;
}

.status {
  font-weight: bold;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 10px;
  white-space: nowrap;
}

.status.pass {
  background: #e3f2fd;
  color: #1565c0;
}

.status.fail {
  background: #f8d7da;
  color: #721c24;
}

.error-msg {
  margin-top: 10px;
  font-family: monospace;
  color: #dc3545;
  font-size: 0.9rem;
  background: #fff3f3;
  padding: 8px;
  border-radius: 3px;
  border: 1px solid #f5c6cb;
}

/* Dividend rows: remove button styling */
.remove-row-btn {
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 6px;
    border: 1px solid var(--border);
    background: var(--background-alt);
    color: var(--text-muted);
    border-radius: 4px;
}

.remove-row-btn:hover {
    color: #dc3545;
    border-color: #dc3545;
}

/* Hide remove button on the phantom (auto‑expand) row */
.phantom-row .remove-row-btn {
    display: none !important;
}

#dividends-table {
    width: 100%;
    margin-bottom: 8px;
}

/* Make inputs inside the dividends table fill their cells without overlapping */
#dividends-table td input {
    width: 100%;
    box-sizing: border-box;
    min-width: 80px;             /* prevent collapsing too small */
}

/* Prevent the remove‑button column from expanding unnecessarily */
#dividends-table th:last-child,
#dividends-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

/* Dark mode overrides for test */
@media (prefers-color-scheme: dark) {
  .summary.success {
    background: #2a4a7f;
    color: #c1d9ff;
    border-color: #3c6eaf;
  }
  .summary.error {
    background: #4a2e2e;
    color: #f5c6cb;
    border-color: #6e3c3c;
  }
  .test-case {
    background: #2a2a2a;
    border-left-color: #666;
    box-shadow: 0 1px 3px rgba(255,255,255,0.05);
  }
  .test-case.pass {
    border-left-color: #5b9af4;
  }
  .test-case.fail {
    border-left-color: #dc3545;
  }
  .status.pass {
    background: #1a3a5e;
    color: #b3d4fc;
  }
  .status.fail {
    background: #4a2e2e;
    color: #f5c6cb;
  }
  .error-msg {
    background: #3a2a2a;
    color: #f5a6a6;
    border-color: #f5c6cb;
  }
}
