@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #060913 0%, #0c1122 50%, #151b30 100%);
  --bg-color: #080c18;
  --glass-bg: rgba(13, 20, 38, 0.45);
  --glass-bg-hover: rgba(18, 28, 54, 0.6);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-border-focus: rgba(99, 102, 241, 0.35);
  
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.25);
  --shadow-indigo-glow: 0 0 20px rgba(99, 102, 241, 0.25);

  --font-display: 'Outfit', sans-serif;
  --font-sans: 'Plus Jakarta Sans', sans-serif;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  padding-bottom: 30px;
}

.app-container {
  width: 100%;
  max-width: 540px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header & Status */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 5px;
}

h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(to right, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 svg {
  width: 32px;
  height: 32px;
  fill: url(#piggyGrad);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 50px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-badge .indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

/* Badge States */
.status-badge.online .indicator {
  background-color: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.status-badge.offline .indicator {
  background-color: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}
.status-badge.syncing {
  background: var(--glass-bg);
  border-color: var(--accent);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Glassmorphic Panel Base */
.panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.09);
}

/* Dashboard Summary Card */
.dashboard-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(13, 20, 38, 0.7) 0%, rgba(18, 28, 54, 0.4) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -100px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0) 70%);
  pointer-events: none;
}

.dashboard-card::after {
  content: '';
  position: absolute;
  bottom: -100px;
  left: -100px;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0) 70%);
  pointer-events: none;
}

.summary-label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
}

.total-amount {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 24px;
  animation: countUpAnimation 0.5s ease-out;
}

.currency-symbol {
  font-size: 2.2rem;
  color: var(--accent);
  font-weight: 500;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-value.accent {
  color: var(--accent);
}

.stat-value.streak {
  color: #ff9f43;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Quick Presets Section */
.presets-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 5px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.presets-container {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 10px 2px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE/Edge */
}

.presets-container::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.preset-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 50px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.preset-btn:hover {
  background: var(--glass-bg-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.preset-btn:active {
  transform: scale(0.95);
}

.preset-btn .preset-val {
  color: var(--accent);
}

.edit-presets-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: all 0.2s;
}

.edit-presets-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
  transform: rotate(45deg);
}

.edit-presets-btn svg {
  width: 16px;
  height: 16px;
}

/* Main Input Panel */
.add-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.input-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

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

.amount-input-wrapper .currency-symbol {
  position: absolute;
  left: 20px;
  pointer-events: none;
  font-size: 1.8rem;
  font-weight: 500;
}

.input-field {
  width: 100%;
  background: rgba(8, 12, 24, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-field.amount {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 600;
  padding: 12px 20px 12px 50px;
}

.input-field.text {
  font-size: 1rem;
  padding: 16px 20px;
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  background: rgba(8, 12, 24, 0.8);
}

.submit-btn {
  width: 100%;
  background: var(--accent-gradient);
  border: none;
  border-radius: 16px;
  padding: 16px;
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.submit-btn:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.submit-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Chart Panel */
.chart-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-container {
  width: 100%;
  height: 200px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-line {
  fill: none;
  stroke: url(#lineGradient);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0px 8px 12px rgba(99, 102, 241, 0.3));
}

.chart-area {
  fill: url(#areaGradient);
  opacity: 0.15;
}

.chart-grid {
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-sans);
  font-weight: 500;
}

.chart-point {
  fill: var(--accent);
  stroke: var(--bg-color);
  stroke-width: 3;
  r: 6;
  transition: all 0.2s;
  cursor: pointer;
}

.chart-point:hover {
  r: 8;
  filter: drop-shadow(0 0 6px var(--accent));
}

.chart-empty {
  position: absolute;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* History Log Panel */
.history-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 400px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}

.history-list::-webkit-scrollbar {
  width: 5px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 5px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  transition: all 0.2s;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(2px);
}

.item-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-amount {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  opacity: 0; /* Hidden by default on desktop, visible on hover */
}

@media (hover: none) {
  /* On touch devices, show delete buttons */
  .delete-btn {
    opacity: 0.6;
  }
}

.history-item:hover .delete-btn {
  opacity: 0.7;
}

.history-item .delete-btn:hover {
  opacity: 1;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.history-item .delete-btn svg {
  width: 16px;
  height: 16px;
}

.history-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 30px 0;
  font-size: 0.9rem;
}

/* Modals / Custom Sheets */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  max-width: 500px;
  background: var(--bg-color);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 30px 30px 0 0;
  padding: 24px;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 16px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: all 0.2s;
}

.close-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.close-btn svg {
  width: 16px;
  height: 16px;
}

/* Edit Presets Form Layout */
.edit-presets-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 5px;
}

.edit-preset-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.edit-preset-row .input-field.title {
  flex: 2;
  padding: 12px 14px;
  font-size: 0.9rem;
}

.edit-preset-row .input-field.val {
  flex: 1;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}

.delete-row-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 10px;
  transition: all 0.2s;
}

.delete-row-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.delete-row-btn svg {
  width: 18px;
  height: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-secondary {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--glass-bg-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  flex: 2;
  background: var(--primary-gradient);
  border: none;
  border-radius: 14px;
  padding: 14px;
  color: white;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.btn-primary:hover {
  box-shadow: var(--shadow-indigo-glow);
}

/* Tooltip overlay styling */
.chart-tooltip {
  position: absolute;
  background: rgba(8, 12, 24, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  font-weight: 600;
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.1);
    opacity: 1;
  }
}

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

@keyframes countUpAnimation {
  from {
    transform: translateY(5px);
    opacity: 0.7;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Small UI micro-animations */
.button-pulse {
  animation: submitPulse 2s infinite;
}

@keyframes submitPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}
