/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f7fa;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  color: #2c3e50;
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

header p {
  color: #7f8c8d;
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 30px;
}

.tab-btn {
  padding: 12px 24px;
  background: white;
  color: #7f8c8d;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  border-color: #3498db;
  color: #3498db;
}

.tab-btn.active {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

/* Layout */
.calculator-layout {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  max-width: 1000px;
  margin: 0 auto;
}

/* Form styles */
.input-section {
  background: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  margin-bottom: 30px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 0;
}

.form-group:not(.form-row .form-group) {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2c3e50;
  font-size: 0.95rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  background-color: white;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input:disabled {
  background-color: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
}

.sales-group input[type='number'] {
  margin-top: 8px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.checkbox-group.inline-checkbox {
  font-size: 0.9rem;
}

.checkbox-group input[type='checkbox'] {
  width: auto;
  margin: 0;
  transform: scale(1.1);
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.button-group {
  display: flex;
  gap: 12px;
  flex-direction: column;
}

.calculate-btn {
  flex: 1;
  padding: 16px 24px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calculate-btn:hover {
  background: linear-gradient(135deg, #2980b9, #21618c);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3);
}

.calculate-btn:active {
  transform: translateY(0);
}

.clear-btn {
  flex: 0 0 auto;
  padding: 16px 20px;
  background: transparent;
  color: #7f8c8d;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background: #f8f9fa;
  border-color: #bdc3c7;
  color: #2c3e50;
}

.error-message {
  background-color: #fee;
  color: #c53030;
  padding: 12px 16px;
  border-radius: 6px;
  border-left: 4px solid #e53e3e;
  margin-bottom: 20px;
  font-weight: 500;
}

/* Results section */
.results-section {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
  overflow: hidden;
  min-height: 250px;
}

.results {
  padding: 25px;
  height: 100%;
}

.results h3 {
  color: #2c3e50;
  font-size: 1.5rem;
  margin-bottom: 25px;
  text-align: center;
  font-weight: 700;
}

.placeholder-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
}

.placeholder-text {
  color: #7f8c8d;
  font-size: 1.1rem;
  max-width: 300px;
}

.results-content {
  animation: fadeIn 0.3s ease-in;
}

.earnings-summary {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: white;
  padding: 25px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 20px;
}

.main-result {
  margin-bottom: 10px;
}

.earnings-label {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.9;
  margin-bottom: 5px;
}

.earnings-value {
  display: block;
  font-size: 2.2rem;
  font-weight: 700;
}

.fee-info {
  font-size: 0.9rem;
  opacity: 0.8;
}

.breakdown-details {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 18px;
}

.breakdown-section {
  margin-bottom: 16px;
}

.breakdown-section:last-child {
  margin-bottom: 0;
}

.breakdown-section h4 {
  color: #2c3e50;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 6px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.breakdown-row span:first-child {
  color: #6c757d;
  font-weight: 500;
}

.breakdown-row span:last-child {
  color: #2c3e50;
  font-weight: 600;
}

.breakdown-row .negative {
  color: #e74c3c;
}

.breakdown-row .positive {
  color: #27ae60;
}

/* Slider */
.slider-container {
  margin-top: 15px;
  position: relative;
}

.sales-slider {
  width: 100%;
  height: 8px;
  padding: 12px 4px !important;
  border-radius: 4px;
  background: linear-gradient(to right, #e74c3c 0%, #f39c12 25%, #f1c40f 50%, #2ecc71 75%, #27ae60 100%);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
}

.sales-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  border: 3px solid #3498db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.sales-slider::-webkit-slider-thumb:hover {
  border-color: #2980b9;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sales-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  border: 3px solid #3498db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.sales-slider::-moz-range-thumb:hover {
  border-color: #2980b9;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sales-slider::-webkit-slider-track {
  width: 100%;
  height: 8px;
  cursor: pointer;
  background: transparent;
  border-radius: 4px;
}

.sales-slider::-moz-range-track {
  width: 100%;
  height: 8px;
  cursor: pointer;
  background: transparent;
  border-radius: 4px;
  border: none;
}

.slider-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding: 8px 0;
}

.current-fee-rate {
  font-size: 0.9rem;
  color: #7f8c8d;
}

.current-fee-rate strong {
  color: #2c3e50;
  font-size: 1rem;
}

#total-sales-group.disabled .sales-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

#total-sales-group.disabled .sales-slider::-webkit-slider-thumb {
  cursor: not-allowed;
  border-color: #bdc3c7;
}

#total-sales-group.disabled .sales-slider::-moz-range-thumb {
  cursor: not-allowed;
  border-color: #bdc3c7;
}

.tracker-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 25px;
}

.tracker-stat {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.tracker-stat.highlight {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: white;
}

.tracker-stat.highlight-red {
  background: linear-gradient(135deg, #e74c3c, #ec7063);
  color: white;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 5px;
  opacity: 0.8;
}

.tracker-stat.highlight .stat-label {
  opacity: 0.9;
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.3;
}

.percent-sup {
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.8;
}

.tracker-stat.highlight .stat-value {
  color: white;
}

.tracker-stat.highlight-red .stat-label {
  opacity: 0.9;
}

.tracker-stat.highlight-red .stat-value {
  color: white;
}

.stat-value.negative {
  color: #e74c3c;
}

.sales-list h3 {
  color: #2c3e50;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.sale-item {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.sale-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sale-number {
  font-weight: 700;
  color: #2c3e50;
  font-size: 0.9rem;
  flex: 1;
}

.drag-handle {
  cursor: grab;
  color: #bdc3c7;
  font-size: 1.2rem;
  user-select: none;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.2s ease;
}

.sale-header:hover .drag-handle {
  width: 20px;
  opacity: 1;
}

.sale-item.dragging {
  opacity: 0.5;
}

.sale-item[draggable='true'] {
  cursor: move;
}

.remove-sale {
  background: transparent;
  border: none;
  color: #e74c3c;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.remove-sale:hover {
  transform: scale(1.2);
}

.sale-details {
  font-size: 0.85rem;
}

.sale-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: #6c757d;
}

.sale-row span:last-child {
  font-weight: 600;
  color: #2c3e50;
}

.sale-row .positive {
  color: #27ae60;
}

.sale-breakdown {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e1e8ed;
}

.sale-breakdown summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: #3498db;
  font-weight: 600;
  padding: 4px 0;
}

.sale-breakdown summary:hover {
  color: #2980b9;
}

.sale-breakdown .breakdown-details {
  margin-top: 8px;
  padding: 8px;
  background: white;
  border-radius: 4px;
}

.sale-breakdown .breakdown-row {
  font-size: 0.8rem;
  padding: 3px 0;
}

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

.category-dropdown {
  transition: opacity 0.3s ease;
}

#results {
  transition: opacity 0.3s ease;
}

/* Accessibility and Print */
.calculate-btn:focus,
input:focus,
select:focus {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}

@media print {
  body {
    background: white;
  }
  .container {
    max-width: none;
    padding: 0;
  }
  .input-section {
    display: none;
  }
  .results-section {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* Media Queries */
@media (max-width: 767px) {
  .container {
    padding: 15px;
  }
  header h1 {
    font-size: 2rem;
  }
  .input-section,
  .results {
    padding: 20px;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 18px;
  }
  .form-group:not(.form-row .form-group) {
    margin-bottom: 18px;
  }
  .sales-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .checkbox-group.inline-checkbox {
    font-size: 0.85rem;
  }
  .form-group input,
  .form-group select {
    font-size: 16px;
  }
  .calculate-btn {
    min-height: 44px;
    font-size: 1rem;
  }
  .earnings-value {
    font-size: 1.8rem !important;
  }
  .earnings-summary {
    padding: 18px;
  }
  .breakdown-details {
    padding: 15px;
  }
  .breakdown-section {
    margin-bottom: 14px;
  }
  .results-section {
    min-height: 200px;
  }
  .tracker-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .tracker-stat:last-child {
    grid-column: 1 / -1;
  }
}

@media (min-width: 480px) {
  .button-group {
    flex-direction: row;
  }
}

@media (max-width: 479px) {
  .clear-btn {
    flex: 1;
  }
}
