:root {
  --primary-color: #E4C1F9;
  --secondary-color: #F6DFEB;
  --accent-color: #D0F4DE;
  --warning-color: #FCF6BD;
  --danger-color: #FFB7C5;
  --text-dark: #2d2d2d;
  --text-light: #666;
  --bg-light: #ffffff;
  --bg-secondary: #f8f9fa;
  --border-color: #e0e0e0;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

[data-theme="dark"] {
  --text-dark: #ffffff;
  --text-light: #cccccc;
  --bg-light: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --border-color: #404040;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 80px;
  transition: var(--transition);
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  background: var(--bg-light);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
  font-weight: 700;
}

.app-logo {
  height: 40px;
  width: auto;
  vertical-align: middle;
  margin-right: 0.5rem;
  border-radius: 8px;
}

header p {
  color: var(--text-light);
  font-size: 0.9rem;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.section.active {
  display: block;
}

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

.calculator-container,
.history-container,
.faq-container,
.settings-container {
  background: var(--bg-light);
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.input-section h2 {
  margin-bottom: 1.5rem;
  color: var(--text-dark);
  font-size: 1.4rem;
  font-weight: 600;
}

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

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-dark);
}

.input-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: var(--bg-light);
  color: var(--text-dark);
  transition: var(--transition);
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(228, 193, 249, 0.2);
}

.input-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-light);
  font-size: 0.8rem;
}

.options {
  margin: 1.5rem 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.chip {
  border: 2px solid var(--border-color);
  background: var(--bg-light);
  color: var(--text-dark);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.chip:hover {
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.btn-primary,
.btn-secondary,
.btn-share,
.btn-save,
.btn-danger,
.btn-install {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  margin: 0.25rem;
}

.btn-primary {
  background: var(--primary-color);
  color: var(--text-dark);
}

.btn-primary:hover {
  background: #d4a5f7;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-dark);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-share {
  background: #4267B2;
  color: white;
}

.btn-share:hover {
  background: #365899;
}

.btn-save {
  background: linear-gradient(135deg, #66BB6A, #4CAF50);
  color: var(--text-dark);
}

.btn-save:hover {
  background: #b8e6c1;
}

.btn-danger {
  background: var(--danger-color);
  color: var(--text-dark);
}

.btn-danger:hover {
  background: #ff9fb0;
}

.btn-install {
  background: var(--warning-color);
  color: var(--text-dark);
}

.btn-install:hover {
  background: #faf0a4;
}

.results-section {
  margin-top: 2rem;
}

.results-section h2 {
  margin-bottom: 1.5rem;
  color: var(--text-dark);
  font-size: 1.4rem;
  font-weight: 600;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.result-card {
  padding: 1.5rem;
  border-radius: var(--border-radius);
  text-align: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.result-card.mdc {
  background: linear-gradient(135deg, #4FC3F7, #29B6F6);
  color: white;
}

.result-card.mmc {
  background: linear-gradient(135deg, #66BB6A, #4CAF50);
  color: white;
}

.result-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.result-value {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.explanation-section {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin: 2rem 0;
}

.explanation-section h3 {
  margin-bottom: 1rem;
  color: var(--text-dark);
}

.steps-container {
  line-height: 1.8;
}

.step {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg-light);
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
}

.actions {
  text-align: center;
  margin-top: 2rem;
}

.didactic-notes {
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.didactic-notes .note {
  background: var(--bg-light);
  border-left: 4px solid var(--primary-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

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

.section-header h2 {
  color: var(--text-dark);
  font-size: 1.4rem;
  font-weight: 600;
}

.history-list {
  display: grid;
  gap: 1rem;
}

.history-item {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  border-left: 4px solid var(--primary-color);
  transition: var(--transition);
}

.history-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.history-numbers {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 1.1rem;
}

.history-date {
  color: var(--text-light);
  font-size: 0.8rem;
}

.history-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.history-result {
  text-align: center;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--bg-light);
}

.history-result.mdc {
  border-top: 3px solid #29B6F6;
}

.history-result.mmc {
  border-top: 3px solid #4CAF50;
}

.history-result-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
}

.history-result-value {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-dark);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: var(--transition);
}

.faq-item:hover {
  box-shadow: var(--shadow);
}

.faq-question {
  width: 100%;
  background: var(--bg-secondary);
  border: none;
  padding: 1.25rem 1.5rem;
  text-align: left;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.faq-question:hover {
  background: var(--border-color);
}

.faq-question[aria-expanded="true"] {
  background: var(--primary-color);
  color: var(--text-dark);
}

.faq-icon {
  font-size: 1.2rem;
  font-weight: bold;
  transition: var(--transition);
}

.faq-question[aria-expanded="true"] .faq-icon {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 1.5rem;
  background: var(--bg-light);
  border-top: 1px solid var(--border-color);
  animation: slideDown 0.3s ease;
}

.faq-answer[hidden] {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    padding: 0 1.5rem;
  }
  to {
    opacity: 1;
    max-height: 200px;
    padding: 1.5rem;
  }
}

.setting-group {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.setting-group:last-child {
  border-bottom: none;
}

.setting-group h3 {
  margin-bottom: 1rem;
  color: var(--text-dark);
  font-size: 1.1rem;
}

.theme-options {
  display: grid;
  gap: 0.75rem;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.radio-label input[type="radio"]:checked + .radio-custom {
  border-color: var(--primary-color);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--primary-color);
  border-radius: 50%;
}

.select-input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: var(--bg-light);
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition);
}

.select-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(228, 193, 249, 0.2);
}

.app-info {
  margin-top: 1rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-light);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.5rem;
  text-decoration: none;
  color: var(--text-light);
  transition: var(--transition);
  font-size: 0.8rem;
  border-radius: 0;
}

.nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-dark);
}

.nav-item.active {
  color: var(--primary-color);
  background: var(--bg-secondary);
}

.nav-item i {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.nav-item span {
  font-size: 0.7rem;
  font-weight: 500;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: 0.8rem;
  background: var(--bg-light);
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
}

/* Monocromático para ícones (exceto a logo) */
i.fas,
i.far,
i.fa-solid,
.faq-icon {
  color: var(--text-dark);
}

/* Dentro dos cartões de resultado, ícones seguem a cor do cartão (branco) */
.result-card i {
  color: inherit !important;
}

.footer-legal {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-legal-link {
  color: var(--text-light);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-color);
  padding-bottom: 1px;
}

.footer-legal-link[aria-current="page"] {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark);
}

@media (max-width: 768px) {
  header {
    padding: 1.5rem 1rem 1rem;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  .app-logo {
    height: 32px;
    margin-right: 0.4rem;
  }
  
  .calculator-container,
  .history-container,
  .faq-container,
  .settings-container {
    padding: 1.5rem;
    margin-bottom: 1rem;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .result-value {
    font-size: 1.5rem;
  }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .section-header h2 {
    margin-bottom: 1rem;
  }
  
  .history-results {
    grid-template-columns: 1fr 1fr;
  }
  
  .nav-item span {
    display: none;
  }
  
  .nav-item {
    padding: 1rem 0.5rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 0 0.5rem;
  }
  
  .calculator-container,
  .history-container,
  .faq-container,
  .settings-container {
    padding: 1rem;
  }
  
  .btn-primary,
  .btn-secondary,
  .btn-share,
  .btn-save,
  .btn-danger,
  .btn-install {
    width: 100%;
    justify-content: center;
    margin: 0.25rem 0;
  }
  
  .actions {
    display: grid;
    gap: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
