/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --background: hsl(200, 20%, 92%);
  --foreground: hsl(200, 50%, 15%);
  --card: hsl(0, 0%, 100%);
  --border: hsl(200, 20%, 85%);
  --muted: hsl(200, 20%, 40%);
  --lime: hsl(61, 64%, 52%);
  --lime-light: hsl(61, 64%, 90%);
  --results-bg: hsl(200, 50%, 15%);
  --results-dark: hsl(200, 50%, 20%);
  --error: hsl(0, 72%, 51%);
  --error-light: hsl(0, 72%, 95%);
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.container {
  width: 100%;
  max-width: 900px;
  height: auto;
}

.calculator {
  background-color: var(--card);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: row;
  margin-bottom: -50px;
  margin-top: -30px;
}

/* Form Panel */
.form-panel {
  flex: 1;
  padding: 1.5rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--foreground);
}

.clear-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: dotted underline;
  text-underline-offset: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s;
}

.clear-link:hover {
  color: var(--foreground);
}

/* Form Groups */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Input Wrapper */
.input-wrapper {
  display: flex;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
  transition: all 0.2s;
}

.input-wrapper:hover {
  border-color: var(--results-dark);
}

.input-wrapper:focus-within {
  border-color: var(--lime);
  box-shadow: 0 0 0 1px var(--lime);
}

.input-wrapper.error {
  border-color: var(--error);
}

.input-wrapper.error:focus-within {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.input-prefix,
.input-suffix {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  background-color: hsl(200, 20%, 96%);
  color: var(--muted);
  font-weight: 400;
  border: none;
}

.input-prefix {
  border-right: 1px solid var(--border);
}

.input-suffix {
  border-left: 1px solid var(--border);
}

.input-wrapper.error .input-prefix,
.input-wrapper.error .input-suffix {
  background-color: var(--error);
  color: white;
  border-color: var(--error);
}

.input-field {
  flex: 1;
  padding: 0 1rem;
  border: none;
  outline: none;
  font-size: 1.125rem;
  font-weight: 400;
  font-family: inherit;
  color: var(--foreground);
  background: transparent;
}

.error-message {
  display: none;
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.form-group.has-error .error-message {
  display: block;
}

/* Radio Group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s;
}

.radio-option:hover {
  border-color: var(--lime);
}

.radio-option.selected {
  background-color: var(--lime-light);
  border-color: var(--lime);
}

.radio-option span {
  font-weight: 700;
  color: var(--foreground);
}

.radio-circle {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.radio-option.selected .radio-circle {
  border-color: var(--lime);
}

.radio-circle-inner {
  width: 0.625rem;
  height: 0.625rem;
  background-color: var(--lime);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 0.2s;
}

.radio-option.selected .radio-circle-inner {
  transform: scale(1);
}

/* Calculate Button */
.calculate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 2rem;
  background-color: var(--lime);
  color: var(--foreground);
  border: none;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.calculate-btn:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.calculate-btn:active {
  transform: scale(0.98);
}

/* Results Panel */
.results-panel {
  flex: 1;
  background-color: var(--results-bg);
  color: white;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid var(--border);
  border-bottom-left-radius: 70px;
}

/* Empty State */
.empty-state {
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.empty-state .illustration {
  width: 12rem;
  height: 8rem;
  margin: 0 auto 1.5rem;
}

.empty-state h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.empty-state p {
  color: hsl(200, 20%, 70%);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Results Content */
.results-content {
  animation: fadeIn 0.3s ease-out;
}

.results-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.results-description {
  color: hsl(200, 20%, 70%);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.results-box {
  background-color: hsla(200, 50%, 20%, 0.5);
  padding: 1.5rem;
  border-radius: 0.5rem;
  border-top: 4px solid var(--lime);
}

.results-label {
  color: hsl(200, 20%, 70%);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.monthly-payment {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--lime);
  margin-bottom: 1.5rem;
}

.results-divider {
  border-top: 1px solid hsla(200, 20%, 70%, 0.3);
  padding-top: 1rem;
}

.total-repayment {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive Styles */
@media (max-width: 768px) {
  .calculator {
    flex-direction: column;
    margin-top: 350px;
    margin-bottom: 20px;
  }

    .form-panel, .results-panel {
      width: 100%;
    }

  .results-panel {
    order: 1;
    border-top: 1px solid var(--border);
    border-left: none;
    border-bottom-left-radius: 0;
  }
}

@media (max-width: 480px) {
  .calculator {
    margin-top: 400px;
    margin-bottom: 20px;
  }

    .header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-group {
    margin-bottom: 1rem;
    }

  .input-wrapper {
    height: 2.5rem;
    width: 100%;
  }

  .input-field {
    font-size: 1rem;
  }

  .calculate-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
  }

  .monthly-payment {
    font-size: 2rem;
  }

  .results-panel {
    padding: 1.5rem;
    border-bottom-left-radius: 0;
  }
}