/* calculators.css — Calculator Drawer and Forms */

/* Calculator drawer */
.calc-drawer {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: var(--drawer-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calc-drawer.open {
  transform: translateX(0);
}

/* Drawer header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.drawer-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.drawer-title svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.drawer-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drawer-close:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.drawer-close svg {
  width: 20px;
  height: 20px;
}

/* Drawer content */
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
}

/* Calculator accordion */
.calc-accordion {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.calc-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
  width: 100%;
  text-align: left;
  border: none;
  font-family: inherit;
}

.calc-header:hover {
  background: var(--bg-tertiary);
}

.calc-header.active {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}

.calc-header-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: 600;
  font-size: var(--font-size-md);
  color: var(--text);
}

.calc-header-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.calc-header-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.calc-header.active .calc-header-icon {
  transform: rotate(180deg);
}

.calc-body {
  display: none;
  padding: var(--spacing-md);
  background: var(--bg);
}

.calc-item.open .calc-body {
  display: block;
  animation: slideDown 0.2s ease;
}

/* Form elements */
.calc-row {
  margin-bottom: var(--spacing-md);
}

.calc-row:last-child {
  margin-bottom: 0;
}

.calc-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.calc-input,
.calc-select {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition-fast);
}

.calc-input:focus,
.calc-select:focus {
  border-color: var(--accent);
}

.calc-input::placeholder {
  color: var(--text-muted);
}

.calc-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Input with unit */
.calc-input-group {
  display: flex;
  align-items: stretch;
}

.calc-input-group .calc-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.calc-input-unit {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Range slider */
.calc-range {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  appearance: none;
  cursor: pointer;
}

.calc-range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.calc-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.calc-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

/* Checkbox/Radio */
.calc-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
}

.calc-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.calc-checkbox span {
  font-size: var(--font-size-sm);
  color: var(--text);
}

/* Button */
.calc-btn {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-top: var(--spacing-md);
}

.calc-btn:hover {
  background: var(--accent-hover);
}

.calc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.calc-btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

.calc-btn-secondary:hover {
  background: var(--bg-tertiary);
}

/* Result block */
.calc-result {
  display: none;
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.calc-result.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

.calc-result-title {
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.calc-result-title svg {
  width: 18px;
  height: 18px;
  color: var(--success);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--border-light);
}

.result-row:last-child {
  border-bottom: none;
}

.result-row span {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.result-row strong {
  font-weight: 600;
  color: var(--text);
}

.result-row.highlight {
  background: var(--accent-light);
  margin: var(--spacing-xs) calc(var(--spacing-md) * -1);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
}

.result-row.highlight strong {
  color: var(--accent);
  font-size: var(--font-size-lg);
}

/* Send to chat button */
.calc-send-btn {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--success);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: var(--spacing-md);
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.calc-send-btn.show {
  display: flex;
}

.calc-send-btn:hover {
  background: #059669;
}

.calc-send-btn svg {
  width: 16px;
  height: 16px;
}

/* Error message */
.calc-error {
  display: none;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-sm);
}

.calc-error.show {
  display: block;
}

/* Hint text */
.calc-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

/* Segmented control */
.calc-segmented {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.calc-segmented button {
  flex: 1;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calc-segmented button.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Quick presets */
.calc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-sm);
}

.calc-preset {
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calc-preset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Summary table in result */
.calc-summary {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--spacing-sm);
  font-size: var(--font-size-sm);
}

.calc-summary th,
.calc-summary td {
  padding: var(--spacing-xs) var(--spacing-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.calc-summary th {
  color: var(--text-secondary);
  font-weight: 500;
}

.calc-summary td {
  font-weight: 600;
}

.calc-summary tr:last-child td,
.calc-summary tr:last-child th {
  border-bottom: none;
}

/* Estimate calculator specific */
.estimate-section {
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.estimate-section-title {
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border);
}

.estimate-total {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  padding: var(--spacing-md);
}

/* Mobile modal styles (for calculators) */
.calc-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  flex-direction: column;
}

.calc-modal.open {
  display: flex;
}

.calc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.calc-modal-title {
  font-weight: 700;
  font-size: var(--font-size-lg);
}

.calc-modal-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.calc-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
}

/* Fix all oversized icons in calculators */
.estimate-section-title svg,
.calc-body svg,
.calc-result svg,
.calc-error svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
