/* 🌗 THEME VARIABLES */
:root {
  --bg: #f5f7fa;
  --text: #111;
  --card: #ffffff;
  --muted: #666;
  --primary: #007bff;
}

body.dark {
  --bg: #0b1220;
  --text: #e6edf3;
  --card: #121a2b;
  --muted: #8b949e;
  --primary: #3b82f6;
}

/* 🌍 Layout */
body {
  font-family: Arial, sans-serif;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  transition: all 0.3s ease;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 🧭 HEADER */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 30px 0 25px;
}

.header h1 {
  font-size: clamp(26px, 4vw, 42px); /* 🔥 responsive magic */
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;

  background: linear-gradient(90deg, var(--text), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

  animation: fadeInUp 0.5s ease;
}

#modeBadge {
  color: #ff4d4d;
  font-weight: bold;
  margin-top: 6px;
  font-size: 13px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 🔥 ACTION BAR */
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 25px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* 🧊 Dashboard */
#dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  background: var(--card);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 25px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

#dashboard p {
  background: rgba(0,0,0,0.03);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark #dashboard p {
  background: rgba(255,255,255,0.05);
}

#dashboard p:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}

#dashboard span {
  font-size: 18px;
  display: block;
  margin-top: 5px;
}

/* 📊 Charts */
.charts {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 30px;
}

.chart-container {
  width: 300px;
  height: 300px;
}

canvas {
  display: block;
  background: var(--card);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* 📜 History */
#historyList {
  background: var(--card);
  padding: 15px;
  border-radius: 10px;
  list-style: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

#historyList li {
  padding: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s;
}

#historyList li:hover {
  background: rgba(0,0,0,0.05);
  transform: translateX(3px);
}

/* 🔘 Buttons */
button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

/* Disabled */
button:disabled {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
  cursor: not-allowed;
}

body:not(.dark) button:disabled {
  background: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.4);
}

/* 📁 File Upload */
.file-upload {
  background: var(--primary);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.file-upload:hover {
  transform: translateY(-1px);
}

#fileName {
  font-size: 13px;
  color: var(--muted);
}

/* 📄 Output */
pre {
  background: var(--card);
  color: var(--text);
  border: 1px solid rgba(0,0,0,0.05);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 20px;
}

body.dark pre {
  background: #1e1e1e;
  color: #00ff9f;
  border: none;
}

/* 🔔 Toast */
.toast {
  position: fixed;

  bottom: 30px;              /* 👈 move to bottom */
  left: 50%;                 /* 👈 center horizontally */
  transform: translateX(-50%) translateY(20px); /* start slightly below */

  z-index: 3000;

  background: #111;
  color: #00ff9f;

  padding: 12px 18px;
  border-radius: 999px;      /* 🔥 pill shape = modern */

  opacity: 0;
  transition: all 0.3s ease;

  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 🌙 Toggle */
.theme-toggle {
  position: static; /* 🔥 no more floating chaos */
  margin-left: auto; /* pushes it to the right */
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);

  z-index: 2000; /* 🔥 THIS FIXES IT */

  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.2s ease;
}

.theme-toggle:hover {
  transform: rotate(20deg) scale(1.1);
}

/* ✨ Inputs */
input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #fff;
  color: #111;
}

body.dark input {
  background: #0f172a;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
}

/* 📱 MOBILE */
@media (max-width: 768px) {

    .auth {
    flex-wrap: wrap; /* 👈 allows wrapping instead of stacking */
    justify-content: flex-end;
    gap: 6px;
    padding: 8px 10px;
  }

  /* keep inputs inline but responsive */
  .auth input {
    width: 120px;
    font-size: 13px;
    padding: 6px 8px;
  }

  /* buttons smaller */
  .auth button {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* upgrade button tighter */
  #upgradeBtn {
    font-size: 11px;
    padding: 6px 10px;
  }

  /* prevent breaking weirdly */
  #email {
    min-width: 110px;
  }

  #password {
    min-width: 110px;
  }

  body {
    padding: 12px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .action-buttons {
    flex-direction: column;
  }

  #dashboard {
    grid-template-columns: 1fr 1fr;
  }

  .charts {
    flex-direction: column;
    align-items: center;
  }
}

/* 🧭 STICKY AUTH BAR */
.auth {
  display: flex;
  align-items: center;
  gap: 8px;

  position: sticky;
  top: 0;
  z-index: 1000;

  backdrop-filter: blur(12px);

  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.75),
    rgba(255,255,255,0.55)
  );

  border-bottom: 1px solid rgba(0,0,0,0.06);
  justify-content: space-between;
  padding: 10px 20px;
  margin-bottom: 20px;
}

body.dark .auth {
  background: linear-gradient(
    to bottom,
    rgba(11,18,32,0.8),
    rgba(11,18,32,0.6)
  );

  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* 🧊 SKELETON */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0,0,0,0.05) 25%,
    rgba(0,0,0,0.1) 50%,
    rgba(0,0,0,0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}

body.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.05) 25%,
    rgba(255,255,255,0.1) 50%,
    rgba(255,255,255,0.05) 75%
  );
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

body.dark .auth {
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* 🌫️ MODAL BACKDROP */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);

  z-index: 3500;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
}

/* Dark mode stronger */
body.dark .modal-backdrop {
  background: rgba(0,0,0,0.55);
}

.confirm-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);

  z-index: 4000;

  background: var(--card);
  color: var(--text);

  padding: 22px;
  border-radius: 14px;
  width: 280px;

  text-align: center;

  box-shadow: 0 20px 50px rgba(0,0,0,0.25);

  opacity: 0;
  transition: all 0.25s ease;
}

/* SHOW STATE */
.confirm-box.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Text */
.confirm-box p {
  margin-bottom: 16px;
  font-size: 14px;
}

/* Buttons */
.confirm-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.confirm-actions button {
  flex: 1;
  padding: 10px 0;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  text-align: center;
}

/* YES (primary danger) */
.confirm-actions button:first-child {
  background: #ff4d4d;
  color: white;
}

.confirm-actions button:first-child:hover {
  background: #ff2f2f;
}

/* CANCEL (secondary but still solid) */
.confirm-actions button:last-child {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}

body:not(.dark) .confirm-actions button:last-child {
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
}

.confirm-actions button:last-child:hover {
  background: rgba(255,255,255,0.15);
}

body:not(.dark) .confirm-actions button:last-child:hover {
  background: rgba(0,0,0,0.1);
}

.confirm-box {
  max-width: 320px;
}

button:active {
  transform: scale(0.97);
}

input::placeholder {
  color: var(--muted);
}