/* ============================================
   CashClock — Styles
   Mobile-first, fun/cheeky money theme
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-dark: #0d5a1e;
  --green-mid: #1a7a3a;
  --green-light: #2ecc71;
  --green-pale: #e8f8e8;
  --gold: #f9c846;
  --gold-dark: #d4a017;
  --copper: #b87333;
  --bg: #0a0f0a;
  --bg-card: #141f14;
  --bg-card-alt: #1a2b1a;
  --text: #e8f5e8;
  --text-muted: #8fad8f;
  --text-dim: #5a7a5a;
  --danger: #e74c3c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'SF Mono', 'Fira Code', monospace;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Header ---------- */
.header {
  text-align: center;
  padding: 20px 0 8px;
}

.logo {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold) 0%, var(--green-light) 50%, var(--gold) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-style: italic;
  margin-top: 2px;
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

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

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(46, 204, 113, 0.15);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Rate Card / Setup ---------- */
.rate-label {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 12px;
}

.rate-input-group {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 2px solid var(--green-mid);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  transition: border-color 0.2s;
}

.rate-input-group:focus-within {
  border-color: var(--gold);
}

.currency-symbol {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-light);
  margin-right: 4px;
}

#rate-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 8px 4px;
  width: 100%;
  -moz-appearance: textfield;
}

#rate-input::-webkit-inner-spin-button,
#rate-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

#rate-input::placeholder {
  color: var(--text-dim);
}

.rate-suffix {
  font-size: 1rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Label input */
.label-group {
  margin-top: 16px;
}

.label-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#session-label {
  width: 100%;
  background: var(--bg);
  border: 2px solid rgba(46, 204, 113, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#session-label:focus {
  border-color: var(--gold);
}

#session-label::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

/* ---------- Buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon {
  font-size: 1.3rem;
}

.btn-start {
  background: linear-gradient(135deg, var(--green-mid), var(--green-light));
  color: #fff;
  margin-top: 20px;
  box-shadow: 0 4px 16px rgba(46, 204, 113, 0.3);
}

.btn-start:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(46, 204, 113, 0.4);
}

.btn-start:active:not(:disabled) {
  transform: translateY(0);
}

.btn-start:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-stop {
  background: linear-gradient(135deg, #c0392b, var(--danger));
  color: #fff;
  margin-top: 24px;
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.3);
}

.btn-stop:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(231, 76, 60, 0.4);
}

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

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid rgba(143, 173, 143, 0.3);
  margin-top: 8px;
}

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

/* ---------- Session Display ---------- */
.session-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
}

.session-label-display {
  font-size: 1rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
  text-align: center;
  min-height: 1.4em;
}

.earnings-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  margin: 8px 0 16px;
}

.earnings-dollar {
  font-size: 3.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--green-light);
  text-shadow: 0 0 30px rgba(46, 204, 113, 0.3);
}

.earnings-cents {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--gold);
}

.session-meta {
  display: flex;
  gap: 32px;
  margin: 8px 0;
}

.meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.meta-value {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ---------- Jar Animation ---------- */
.jar-container {
  width: 140px;
  height: 180px;
  position: relative;
  margin-bottom: 8px;
}

.jar {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 140px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top: none;
  border-radius: 0 0 20px 20px;
  background: rgba(255,255,255,0.03);
  overflow: hidden;
}

.jar::before {
  content: '';
  position: absolute;
  top: -12px;
  left: -8px;
  right: -8px;
  height: 14px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px 4px 0 0;
  border: 3px solid rgba(255,255,255,0.15);
}

.jar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(
    to top,
    var(--gold-dark) 0%,
    var(--gold) 40%,
    var(--green-light) 100%
  );
  transition: height 0.5s ease;
  border-radius: 0 0 17px 17px;
  opacity: 0.7;
}

.coin-zone {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.coin {
  position: absolute;
  font-size: 1.2rem;
  animation: coinDrop 1s ease-in forwards;
  will-change: transform, opacity;
}

@keyframes coinDrop {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translateY(130px) rotate(360deg);
    opacity: 0.3;
  }
}

/* ---------- Summary ---------- */
.summary-card {
  text-align: center;
}

.summary-title {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.summary-amount {
  font-size: 3rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--green-light);
  margin-bottom: 20px;
  text-shadow: 0 0 30px rgba(46, 204, 113, 0.3);
}

.summary-details {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row span:first-child {
  color: var(--text-muted);
}

.summary-row span:last-child {
  font-weight: 600;
  font-family: var(--font-mono);
}

.summary-actions {
  display: flex;
  flex-direction: column;
}

/* ---------- Ledger ---------- */
.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ledger-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.ledger-actions {
  display: flex;
  gap: 8px;
}

.btn-icon-action {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon-action:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.2);
}

.ledger-total {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#ledger-total-amount {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--green-light);
}

.ledger-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ledger-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  animation: fadeIn 0.3s ease;
}

.ledger-entry-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.ledger-entry-label {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-entry-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.ledger-entry-amount {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--green-light);
  font-size: 1.05rem;
  margin-left: 12px;
  white-space: nowrap;
}

.ledger-entry-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 4px;
  border-radius: 6px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.ledger-entry-delete:hover {
  color: var(--danger);
  background: rgba(231, 76, 60, 0.1);
}

.ledger-empty {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 16px 0;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 20px 16px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* ---------- Toast / Notification ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--green-mid);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ---------- Confirm Dialog ---------- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
  padding: 16px;
}

.confirm-dialog {
  background: var(--bg-card);
  border: 1px solid rgba(46, 204, 113, 0.2);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.confirm-dialog p {
  margin-bottom: 20px;
  font-size: 1rem;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 12px;
}

.confirm-actions .btn {
  flex: 1;
  padding: 12px;
  font-size: 1rem;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (min-width: 480px) {
  .earnings-dollar {
    font-size: 4.5rem;
  }
  .earnings-cents {
    font-size: 2.5rem;
  }
  .jar-container {
    width: 160px;
    height: 200px;
  }
  .jar {
    width: 120px;
    height: 160px;
  }
}
