:root {
  --primary: #1e293b; /* Darker more neutral slate */
  --primary-light: #3b82f6;
  --primary-dark: #0f172a;
  --accent: #f59e0b;
  --background: #f1f5f9; /* Lighter slightly cooler gray for background */
  --surface: #ffffff;
  --text-main: #334155;
  --text-muted: #64748b;
  --success: #22c55e;
  --danger: #ef4444;
  --border: #e2e8f0;
  --radius: 8px; /* Sharper corners as in reference */
  --shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg:
    0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --gradient-primary: linear-gradient(135deg, #1e293b 0%, #3b82f6 100%);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  min-height: 100vh;
}

.app-wrapper {
  max-width: 1200px;
  width: 100%;
}

.header {
  text-align: center;
  margin-bottom: 3.5rem;
  animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-icon {
  font-size: 3rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 6px rgba(59, 130, 246, 0.2));
}

.title-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 0;
}

.header h1 span {
  display: block;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.02em;
}

.header p {
  color: var(--primary-light);
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.5rem;
  opacity: 0.8;
}

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

.calculator-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 850px) {
  .calculator-container {
    grid-template-columns: 1.65fr 1fr;
    align-items: flex-start;
    gap: 2rem;
  }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem; /* slightly less padding */
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* softer shadow */
  border: none; /* remove border or keep very light */
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.input-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.tooltip {
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: help;
}

input[type="number"], select {
    width: 100%;
    padding: 0 1rem;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--surface); /* match select background to surface */
    color: var(--text-main);
    line-height: 42px;
}

input[type="number"]:focus, select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    background-color: var(--surface);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748b%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
    padding-right: 2.5rem;
}

/* Custom Select Styles */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 100%;
}

.custom-select {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 42px;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-select-trigger:hover {
  border-color: var(--primary-light);
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.custom-options {
  position: absolute;
  display: block;
  top: 100%;
  left: 0;
  right: 0;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--surface);
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-5px);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: none;
  overflow-y: visible;
}

.custom-select-wrapper.open .custom-options {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0);
}

.custom-option {
  position: relative;
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-option:hover {
  background-color: rgba(59, 130, 246, 0.08);
  color: var(--primary-light);
}

.custom-option.selected {
  color: #fff;
  background-color: var(--primary-light);
}

.arrow {
  position: relative;
  height: 10px;
  width: 10px;
  transition: all 0.4s ease;
}

.arrow::before,
.arrow::after {
  content: "";
  position: absolute;
  bottom: 0px;
  width: 0.12rem;
  height: 0.55rem;
  background-color: var(--text-muted);
  transition: all 0.4s ease;
  border-radius: 10px;
}

.arrow::before {
  transform: rotate(-45deg);
  left: 1px;
}

.arrow::after {
  transform: rotate(45deg);
  left: 6px;
}

.custom-select-wrapper.open .arrow {
  transform: rotate(180deg);
}

/* Hide native select but keep it for logic */
select.hidden-select {
  display: none !important;
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

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

.input-with-icon span {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.input-with-icon input {
  padding-left: 2.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem 1rem;
  align-items: flex-end;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.section-divider {
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
}

/* Toggle Switch */
.toggle-group {
  display: flex;
  flex-direction: column;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  margin-top: 0.25rem;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--primary-light);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Results section */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.results-header h2 {
  font-size: 1.15rem;
  color: var(--text-main);
  font-weight: 600;
}

.btn-congelar {
  background-color: #fef3c7;
  color: #d97706;
  border: 1px solid #fde68a;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.btn-congelar:hover {
  background-color: #fde68a;
}

.result-card {
  background: var(--success);
  color: white;
  text-align: center;
  border: none;
  padding: 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2), 0 2px 4px -1px rgba(16, 185, 129, 0.1);
  margin-bottom: 20px;
}

.result-card h2 {
  display: none; /* removed if it exists inside card */
}

.net-salary {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  text-shadow: none;
}

/* Sub-cards for inputs like Férias and 13º */
.sub-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  height: 100%;
}

.sub-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.details-card h3 {
  display: none; /* Remove "Detalhamento" text to clear up space */
}

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

.detail-group h4 {
  display: none; /* Remove Proventos / Descontos headers */
}

.earnings h4 {
  color: var(--success);
}
.deductions h4 {
  color: var(--danger);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-size: 0.95rem;
  border-bottom: 1px dashed var(--border);
}

.detail-row:last-child:not(.total-row) {
  border-bottom: none;
}

.detail-row.highlight-green {
  background-color: #f2fcf5;
  margin: 0.45rem -0.5rem;
  padding: 0.55rem 0.5rem;
  border-radius: 6px;
  border-bottom: none;
  font-weight: 400;
}

.subtotal {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.total-vencimentos-row {
  background-color: var(--background);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  margin: 1rem -1rem 1.5rem -1rem; /* Negative margin to span full width of card */
  border: 1px solid var(--border);
}

.total-descontos-row {
  background-color: rgba(239, 68, 68, 0.05);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--danger);
  display: flex;
  justify-content: space-between;
  margin: 1rem -1rem; /* Negative margin to span full width of card */
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.total-row {
  font-weight: 700;
  font-size: 1.05rem;
  padding-top: 1rem;
  border-bottom: none;
}

.total-row span:last-child {
  color: var(--primary);
}

.details-card .negative {
  color: var(--danger);
}

.highlight-row {
  background-color: rgba(16, 185, 129, 0.05);
  padding: 0.5rem;
  border-radius: 6px;
  margin: 0.5rem 0;
  border: none;
}

footer {
  text-align: center;
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Tooltip Moderno em Balão */
.tooltip {
  position: relative;
  cursor: help;
  color: var(--text-muted);
  display: inline-block;
  margin-left: 0.35rem;
  transition: color 0.2s ease;
}

.tooltip:hover {
  color: var(--primary);
}

.tooltip::before,
.tooltip::after {
  position: absolute;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
  pointer-events: none;
}

/* O Balão */
.tooltip::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background-color: var(--text-main);
  color: #fff;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.6rem;
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  text-align: center;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* A Setinha (Triângulo) */
.tooltip::after {
  content: '';
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  border: 6px solid transparent;
  border-top-color: var(--text-main);
}

/* Hover Effect */
.tooltip:hover::before,
.tooltip:hover::after {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
