:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --bg-gradient-start: #fdfbfb;
  --bg-gradient-end: #ebedee;
  --card-bg: rgba(255, 255, 255, 0.7);
  --text-main: #1f2937;
  --text-secondary: #6b7280;
  --border-color: rgba(255, 255, 255, 0.5);
  --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
  --font-family: 'Outfit', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f3f4f6;
    --text-secondary: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  }
}

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

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
}

#app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

header {
  text-align: center;
  margin-bottom: 10px;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--primary-color), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.calculator-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.currency-input span {
  position: absolute;
  left: 16px;
  font-size: 1.2rem;
  color: var(--text-main);
}

input[type="number"] {
  width: 100%;
  padding: 16px 16px 16px 32px;
  font-size: 1.5rem;
  border: 2px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  font-family: var(--font-family);
  transition: all 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  input[type="number"] {
    background: rgba(0, 0, 0, 0.2);
  }
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-color);
  background: rgba(255, 255, 255, 0.8);
}

@media (prefers-color-scheme: dark) {
  input[type="number"]:focus {
    background: rgba(0, 0, 0, 0.4);
  }
}

.tip-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tip-btn {
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .tip-btn {
    background: rgba(0, 0, 0, 0.2);
  }
}

.tip-btn.active {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.custom-tip {
  position: relative;
  display: flex;
  align-items: center;
}

.custom-tip input {
  padding: 12px;
  font-size: 1rem;
  padding-right: 24px;
  padding-left: 12px;
  text-align: center;
}

.custom-tip span {
  position: absolute;
  right: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.people-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.people-input button {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .people-input button {
    background: rgba(0, 0, 0, 0.2);
  }
}

.people-input button:active {
  transform: scale(0.95);
}

.people-input input {
  text-align: center;
  padding: 12px;
}

.results {
  background: rgba(99, 102, 241, 0.1);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-row span:first-child {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.result-row .amount {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-main);
}

.result-row.total .amount {
  font-size: 2rem;
  color: var(--primary-color);
}

.primary-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: var(--primary-color);
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

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

.history-section {
  margin-top: 20px;
}

.history-section h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--text-main);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: var(--card-bg);
  backdrop-filter: blur(5px);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.history-location {
  font-size: 0.8rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-amounts {
  text-align: right;
}

.history-total {
  font-weight: 700;
  color: var(--text-main);
}

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

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-style: italic;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 16px;
  width: 100%;
  cursor: pointer;
  text-decoration: underline;
}

.text-btn:hover {
  color: var(--text-main);
}

/* Auth Status */
.auth-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.auth-status span {
  font-size: 0.9rem;
  color: var(--primary-color);
  font-weight: 600;
}

.text-btn.small {
  font-size: 0.8rem;
  margin-top: 0;
  width: auto;
}

/* Modal */
.modal {
  display: flex;
  /* Hidden by default via class */
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  display: none;
  opacity: 0;
}

.modal-content {
  background: var(--bg-gradient-start);
  /* Use gradient start as base */
  background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
  padding: 30px;
  border-radius: 24px;
  width: 90%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (prefers-color-scheme: dark) {
  .modal-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  color: var(--text-secondary);
  cursor: pointer;
}

.close-modal:hover {
  color: var(--text-main);
}

.switch-auth {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.switch-auth button {
  display: inline;
  width: auto;
  margin-left: 5px;
}