/* style.css - Cosmic Gradient & Y3K Theme */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Orbitron:wght@500;700;900&family=Outfit:wght@300;400;600;700&display=swap');

:root {
  --space-bg: #06040e;
  --nebula-purple: #13072b;
  --neon-cyan: #00f3ff;
  --neon-pink: #ff007f;
  --cyber-orange: #ff5e00;
  --cyber-orange-glow: rgba(255, 94, 0, 0.4);
  --neon-red: #ff3366;
  --text-white: #ffffff;
  --text-muted: #9fa1c7;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-card-bg: rgba(18, 12, 38, 0.5);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glow-cyan: 0 0 15px rgba(0, 243, 255, 0.4);
  --glow-pink: 0 0 15px rgba(255, 0, 127, 0.4);
  --glow-orange: 0 0 20px rgba(255, 94, 0, 0.5);
  --glow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  background-color: var(--space-bg);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(19, 7, 43, 0.8) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 243, 255, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(255, 0, 127, 0.06) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text-white);
  font-family: 'Outfit', 'Kanit', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  position: relative;
}

/* Background animated mesh particles */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 80% 20%, rgba(255, 94, 0, 0.05) 0%, transparent 35%);
  pointer-events: none;
  z-index: -1;
  animation: cosmicPulse 10s ease-in-out infinite alternate;
}

@keyframes cosmicPulse {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.1) translate(-2%, 2%); }
}

/* Container */
.app-container {
  width: 100%;
  max-width: 480px; /* Target mobile display */
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--glass-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--glow-glass);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.glass-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--glow-glass), 0 0 20px rgba(255, 255, 255, 0.02);
}

/* Header Component */
.header-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 10px;
}

.logo-wrapper {
  position: relative;
  width: 140px; /* Increased from 90px */
  height: 140px; /* Increased from 90px */
  margin-bottom: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px; /* Reduced padding to make image larger */
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 25px rgba(0, 243, 255, 0.2);
  border: 1px solid rgba(0, 243, 255, 0.25);
  overflow: hidden; /* Clip image corners to circle */
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Cover wrapper area to be full and large */
  border-radius: 50%;
}

.app-title {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ff8c00, #ff007f, #00f3ff);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shineText 6s linear infinite;
  margin-bottom: 4px;
}

@keyframes shineText {
  to { background-position: 200% center; }
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 1px;
  margin-bottom: 16px;
  text-transform: uppercase;
}

/* Clock & Calendar Badge */
.clock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 94, 0, 0.08);
  border: 1px solid rgba(255, 94, 0, 0.2);
  border-radius: 50px;
  padding: 6px 14px; /* Optimized padding for mobile screens */
  color: #ff9d63;
  font-size: 0.8rem; /* Optimized font size for mobile screens */
  font-weight: 500;
  box-shadow: 0 0 10px rgba(255, 94, 0, 0.05);
  margin-top: 5px;
  max-width: 100%;
}

.clock-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

#thai-date-str {
  white-space: nowrap; /* Prevent year or text from breaking */
  text-overflow: ellipsis;
  overflow: hidden;
}

.clock-time {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Budget Cards Layout */
.budgets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.budget-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  background: rgba(10, 6, 26, 0.6);
}

.budget-card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 2px;
  border-radius: 2px;
}

.budget-card.daily::before {
  background: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

.budget-card.monthly::before {
  background: var(--neon-pink);
  box-shadow: var(--glow-pink);
}

.budget-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.budget-label svg {
  width: 14px;
  height: 14px;
}

.daily .budget-label svg { fill: var(--neon-cyan); }
.monthly .budget-label svg { fill: var(--neon-pink); }

.budget-value-container {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: 8px;
}

.budget-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.8rem;
  font-weight: 900;
}

.daily .budget-value {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.monthly .budget-value {
  color: var(--neon-pink);
  text-shadow: 0 0 10px rgba(255, 0, 127, 0.2);
}

.decimal-part {
  font-size: 0.55em;
  font-weight: 700;
  opacity: 0.85;
}

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

/* Circular progress bar styles */
.progress-ring-container {
  position: relative;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
}

.progress-ring-circle {
  transition: stroke-dashoffset 0.35s;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/* Form inputs */
.form-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-white);
  margin-bottom: 12px;
}

.form-title svg {
  width: 18px;
  height: 18px;
  fill: var(--cyber-orange);
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.amount-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px 60px 16px 20px;
  font-family: 'Outfit', 'Kanit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-white);
  outline: none;
  transition: var(--transition-smooth);
}

.amount-input:focus {
  border-color: var(--cyber-orange);
  box-shadow: 0 0 15px rgba(255, 94, 0, 0.25), inset 0 0 10px rgba(255, 94, 0, 0.1);
}

.amount-input::placeholder {
  color: rgba(255, 255, 255, 0.15);
  font-weight: 400;
}

/* Suffix 'บาท' inside input */
.input-suffix {
  position: absolute;
  right: 20px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1rem;
  pointer-events: none;
}

/* Action Buttons Container */
.buttons-group {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}

/* Cyber Button Styles */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 16px;
  font-family: 'Outfit', 'Kanit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyber-orange), #ff2a00);
  border: none;
  color: var(--text-white);
  box-shadow: var(--glow-orange);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(255, 94, 0, 0.7);
}

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

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--cyber-orange);
  color: var(--cyber-orange);
  box-shadow: 0 0 10px rgba(255, 94, 0, 0.05);
}

/* Disabled/Inactive State for Save Button */
.btn-secondary:disabled {
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
  box-shadow: none;
  pointer-events: none;
}

.btn-secondary:not(:disabled):hover {
  background: rgba(255, 94, 0, 0.1);
  box-shadow: 0 0 20px rgba(255, 94, 0, 0.3);
  transform: translateY(-2px);
}

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

/* Calculation Result Box */
.result-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.result-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-label svg {
  width: 16px;
  height: 16px;
}

.result-row.gov .result-label svg { fill: var(--neon-cyan); }
.result-row.user .result-label svg { fill: var(--neon-pink); }

.result-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  font-weight: 700;
}

.result-row.gov .result-value {
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.2);
}

.result-row.user .result-value {
  color: var(--neon-pink);
  text-shadow: 0 0 8px rgba(255, 0, 127, 0.2);
}

.result-divider {
  border: none;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

/* History Component */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
}

.history-title svg {
  width: 18px;
  height: 18px;
  fill: var(--text-white);
}

.btn-clear-all {
  background: transparent;
  border: 1px solid var(--neon-red);
  color: var(--neon-red);
  border-radius: 30px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-smooth);
}

.btn-clear-all svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.btn-clear-all:hover {
  background: rgba(255, 51, 102, 0.1);
  box-shadow: 0 0 15px rgba(255, 51, 102, 0.25);
  transform: scale(1.02);
}

/* History table */
.history-table-container {
  width: 100%;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.history-table th {
  padding: 10px 6px;
  font-size: 0.78rem;
  color: #ffb788;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap; /* Force headers on single line */
}

.history-table td {
  padding: 12px 6px;
  font-size: 0.82rem;
  color: var(--text-white);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  white-space: nowrap; /* Force cell content on single line */
}

.history-table th:nth-child(1), .history-table td:nth-child(1) { width: 30%; }
.history-table th:nth-child(2), .history-table td:nth-child(2) { width: 22%; text-align: right; }
.history-table th:nth-child(3), .history-table td:nth-child(3) { width: 22%; text-align: right; }
.history-table th:nth-child(4), .history-table td:nth-child(4) { width: 21%; text-align: right; }
.history-table th:nth-child(5), .history-table td:nth-child(5) { width: 5%; text-align: center; }

.td-date {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  line-height: 1.2;
}

.td-amount {
  font-family: 'Orbitron', monospace;
  font-weight: 600;
}

.td-gov {
  font-family: 'Orbitron', monospace;
  color: var(--neon-cyan) !important;
  font-weight: 600;
}

.td-user {
  font-family: 'Orbitron', monospace;
  color: var(--neon-pink) !important;
  font-weight: 600;
}

/* Delete Row button */
.btn-delete-row {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.btn-delete-row:hover {
  color: var(--neon-red);
  background: rgba(255, 51, 102, 0.1);
  transform: scale(1.2);
}

/* Empty state */
.empty-history-text {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  font-weight: 300;
  animation: pulseOpacity 2s infinite ease-in-out;
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* Footer info */
.footer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
}

.dev-credit {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-credit a {
  color: var(--cyber-orange);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.dev-credit a:hover {
  text-shadow: 0 0 10px rgba(255, 94, 0, 0.5);
  color: #ff914d;
}

.social-links {
  display: flex;
  gap: 15px;
  margin-top: 4px;
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.social-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.social-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-white);
  transform: translateY(-3px);
}

.social-btn.facebook:hover {
  color: #1877f2;
  box-shadow: 0 0 12px rgba(24, 119, 242, 0.4);
}

.social-btn.youtube:hover {
  color: #ff0000;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.4);
}

/* Offline/Sync Status indicator */
.sync-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.6;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #33cc66;
  box-shadow: 0 0 8px #33cc66;
}

.sync-dot.offline {
  background: #ffcc00;
  box-shadow: 0 0 8px #ffcc00;
}
