/* iOS-inspired, modern, mobile-first, dark-mode-friendly styles for Nutrient Counter */

:root {
  --primary: #e53935;
  --primary-dark: #b71c1c;
  --background: #f7f9fa;
  --surface: #fff;
  --surface-alt: #f1f3f6;
  --text: #222;
  --text-light: #666;
  --border: #e0e0e0;
  --radius: 22px;
  --transition: 0.25s cubic-bezier(.4,0,.2,1);
  --shadow: 0 2px 12px 0 rgba(0,0,0,0.07);
  --input-bg: #f7f9fa;
  --input-border: #e0e0e0;
  --input-focus: #e53935;
}

body {
  font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  background: var(--background);
  color: var(--text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), color var(--transition);
}

body.dark-mode {
  --background: #181a1b;
  --surface: #232526;
  --surface-alt: #222325;
  --text: #f7f9fa;
  --text-light: #b0b3b8;
  --border: #232526;
  --input-bg: #232526;
  --input-border: #333;
  --input-focus: #ff7961;
}

.top-bar {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.1rem 1.2rem 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background var(--transition);
}
.app-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--primary);
}

#wheels.wheels-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  margin: 1.2rem 0 0.5rem 0;
}

.nutrient-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 0.7rem 1.1rem 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background var(--transition), box-shadow var(--transition);
  position: relative;
  min-width: 0;
}
.nutrient-card.over-limit {
  box-shadow: 0 2px 16px 0 rgba(229,57,53,0.18);
  border: 2px solid var(--primary);
}
.progress-wheel {
  margin-bottom: 0.5rem;
}
.progress-label {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--text-light);
}
.nutrient-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.2em;
}
.nutrient-value.over-limit {
  color: var(--primary);
}
.nutrient-separator {
  color: var(--text-light);
  font-weight: 400;
}
.nutrient-controls {
  display: flex;
  gap: 0.7rem;
}
.nutrient-plus, .nutrient-minus {
  background: var(--surface-alt);
  border: none;
  border-radius: 50%;
  width: 2.3rem;
  height: 2.3rem;
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.04);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
.nutrient-plus:active, .nutrient-minus:active {
  background: var(--primary);
  color: #fff;
}

.dashboard-title {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 1.5rem 0 0.7rem 0;
  text-align: center;
  color: var(--primary);
  letter-spacing: 0.01em;
}
.streak-info {
  font-size: 1rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: 0.7rem;
}
.dashboard-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  align-items: center;
  margin: 1.1rem 0 0.7rem 0;
  flex-wrap: wrap;
}
.dashboard-actions button {
  width: auto;
  min-width: 120px;
  max-width: 180px;
  display: inline-block;
  margin: 0;
}
.settings-btn {
  margin: 0 0.5rem;
}

input, select, button {
  font-family: inherit;
  font-size: 1.1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--input-border);
  padding: 0.85em 1.1em;
  margin: 0.4em 0;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.03);
  width: 100%;
  box-sizing: border-box;
  appearance: none;
}
input:focus, select:focus {
  border-color: var(--input-focus);
  background: var(--surface);
  box-shadow: 0 2px 8px 0 rgba(229,57,53,0.08);
}
select {
  padding-right: 2.5em;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%23e53935" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 1em center;
  background-size: 1.2em;
}
button {
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 4px 0 rgba(229,57,53,0.08);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  margin: 0.4em 0;
}
button:active {
  background: var(--primary-dark);
}
button[aria-label="Toggle dark mode"] {
  width: 2.5em;
  height: 2.5em;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--primary);
  font-size: 1.3em;
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.04);
  border: none;
}
button[aria-label="Toggle dark mode"]:active {
  background: var(--primary);
  color: #fff;
}

h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 1.1rem 0 0.7rem 0;
  text-align: center;
  color: var(--primary);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}
.spinner {
  width: 2.5em;
  height: 2.5em;
  border: 4px solid var(--surface-alt);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.footer-credit {
  text-align: center;
  color: var(--text-light);
  font-size: 0.95rem;
  margin: 2.5rem 0 1.2rem 0;
  letter-spacing: 0.01em;
}

/* Log Table */
.log-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5em;
  background: none;
}
.log-table th, .log-table td {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.7em 0.5em;
  text-align: center;
  color: var(--text);
  font-size: 1rem;
  border: none;
  transition: background var(--transition), color var(--transition);
}
.log-table th {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.05rem;
}
.log-table td.over-limit {
  color: var(--primary);
  font-weight: 700;
}
.log-table td.under-limit {
  color: #4caf50;
  font-weight: 700;
}
.over-amount, .under-amount {
  font-size: 0.85em;
  margin-top: 0.2em;
  opacity: 0.8;
}

/* Misc */
.dark-mode-setting {
  display: flex;
  align-items: center;
  gap: 0.7em;
  margin: 1.2em 0 0.7em 0;
  justify-content: center;
}

/* Responsive: mobile first */
@media (max-width: 600px) {
  .top-bar {
    font-size: 1.1rem;
    padding: 0.8rem 0.7rem 0.7rem 0.7rem;
  }
  .app-title {
    font-size: 1.2rem;
  }
  #wheels.wheels-container {
    gap: 0.7rem;
  }
  .nutrient-card {
    padding: 0.7rem 0.3rem 0.7rem 0.3rem;
  }
  .dashboard-title {
    font-size: 1.5rem;
    margin: 1.1rem 0 0.5rem 0;
  }
  .dashboard-actions {
    gap: 0.4rem;
  }
  input, select, button {
    font-size: 1rem;
    padding: 0.7em 0.8em;
  }
}

::-webkit-input-placeholder { color: var(--text-light); opacity: 1; }
::-moz-placeholder { color: var(--text-light); opacity: 1; }
:-ms-input-placeholder { color: var(--text-light); opacity: 1; }
::placeholder { color: var(--text-light); opacity: 1; }

/* Smooth transitions for everything */
* {
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

/* Auth Tabs (Login/Register) */
.tabs {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 2.2rem 0 1.2rem 0;
  background: var(--surface-alt);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px 0 rgba(0,0,0,0.03);
  padding: 0.25rem;
  gap: 0.2rem;
}
.tab {
  flex: 1 1 0;
  text-align: center;
  padding: 0.7em 0.2em;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-light);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  user-select: none;
  -webkit-user-select: none;
}
.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px 0 rgba(229,57,53,0.10);
}
.tab:active {
  background: var(--primary-dark);
  color: #fff;
}

/* Animated Streak Counter */
.streak-info-animated {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.7rem;
  background: var(--surface-alt);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px 0 rgba(229,57,53,0.06);
  padding: 0.7em 1.1em;
  position: relative;
  overflow: hidden;
}
.streak-flame {
  font-size: 1.5em;
  margin-right: 0.1em;
  filter: drop-shadow(0 0 8px #ff9800cc);
  transition: filter 0.3s;
}
.flame-glow {
  animation: flameGlow 1.2s infinite alternate;
}
@keyframes flameGlow {
  0% { filter: drop-shadow(0 0 8px #ff9800cc) drop-shadow(0 0 0px #fff0); }
  100% { filter: drop-shadow(0 0 18px #ff9800ff) drop-shadow(0 0 6px #fff5); }
}
.streak-label {
  color: var(--primary-dark);
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.streak-number {
  font-size: 1.5em;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0.1em;
  display: inline-block;
  transition: transform 0.2s cubic-bezier(.4,0,.2,1);
}
.pop-animate {
  animation: popScale 0.4s cubic-bezier(.4,0,.2,1);
}
@keyframes popScale {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  60% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.streak-days {
  color: var(--text-light);
  font-size: 1em;
  margin-left: 0.1em;
}

body.dark-mode .streak-info-animated {
  background: #232526;
  color: #ffb74d;
}
body.dark-mode .streak-flame {
  filter: drop-shadow(0 0 12px #ffb300cc);
}
body.dark-mode .streak-label {
  color: #ffb74d;
}
body.dark-mode .streak-number {
  color: #ffb74d;
}

/* Modal styles */
#modalOverlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  cursor: pointer;
}
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem 1.5rem 1.5rem;
  z-index: 1;
  min-width: 300px;
  max-width: 90vw;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#modalOverlay .modal-content {
  opacity: 1;
}
@media (max-width: 500px) {
  .modal-content {
    min-width: 0;
    width: 95vw;
    padding: 1.2rem 0.7rem 1rem 0.7rem;
  }
}
