/* ─── Global Styles ────────────────────────────────────────────────────────── */

/* ─── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --accent: #c8f060;
  /* electric lime */
  --text: #e8e8e8;
  --muted: #666;
  --danger: #ff4d4d;
  --radius: 6px;
  --font-mono: "DM Mono", "Fira Mono", "Consolas", monospace;
  --font-sans: "DM Sans", "Helvetica Neue", sans-serif;
  --primary: #c8f060;
  /* lime, same as accent */
  --transition: 140ms ease;
}

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

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100dvh;
  padding: 0 0 env(safe-area-inset-bottom) 0;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ─── Header & Menu Button ────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.logo span {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  color: var(--text);
}

.btn-icon:hover {
  opacity: 0.7;
  transform: scale(1.1);
}

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

#btn-sync-global .cloud-icon {
  font-size: 1.4rem;
  color: #666;
  transition: color 0.3s;
}

#btn-sync-global .cloud-icon.logged-in {
  color: #d6ff70;
}

#menu-toggle .bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: opacity 0.3s;
}

body.menu-open #menu-toggle {
  display: none;
}

/* ─── Status badge ─────────────────────────────────────────────────────────── */
#sync-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  min-height: 1.2em;
  transition: color var(--transition);
  flex-shrink: 0;
  max-width: 200px;
}

#sync-status.active {
  color: var(--accent);
}

#sync-status.error {
  color: var(--danger);
}

/* ─── Meta bar (Status Pills) ─────────────────────────────────────────────── */
.meta-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

#last-sync-text,
.offline-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.offline-badge {
  color: var(--danger);
  border-color: rgba(255, 77, 77, 0.2);
  background: rgba(255, 77, 77, 0.05);
  display: none;
}

body.offline .offline-badge {
  display: flex;
}

#last-sync-text {
  color: var(--accent);
  border-color: rgba(200, 240, 96, 0.2);
  background: rgba(200, 240, 96, 0.05);
}

/* ─── Generic Button Styles ────────────────────────────────────────────────── */
button {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 9px 18px;
  transition: background var(--transition), opacity var(--transition), transform 80ms ease;
  white-space: nowrap;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #0f0f0f;
}

.btn-primary:hover:not(:disabled) {
  background: #d6ff70;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Side Navigation ─────────────────────────────────────────────────── */

.side-nav {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(25px);
  z-index: 3000;
  transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
}

.side-nav.open {
  left: 0;
}

.nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
}

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

.nav-item {
  padding: 14px 18px;
  border-radius: 12px;
  color: #aaa;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: rgba(200, 240, 96, 0.1);
  color: var(--accent);
}

.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.nav-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Notification prompt ──────────────────────────────────────────────────── */
#notif-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
}

#notif-banner[hidden] {
  display: none;
}

/* ─── App Switching & Layout ────────────────────────────────────────── */

.app-section {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

[hidden] {
  display: none !important;
}

.app-shell {
  padding-bottom: 2rem;
}

/* ─── Modal Glassmorphism ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content h3 {
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.modal-content p {
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

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

.modal-actions button {
  flex: 1;
  padding: 12px !important;
}

/* ─── Splash Screen ─────────────────────────────────────────────────────── */

#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
}

#splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.splash-logo {
  font-family: var(--font-sans);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  animation: logoPulse 2s ease-in-out infinite;
}

.splash-logo span {
  color: var(--accent);
}

.splash-loader {
  width: 160px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.loader-bar {
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 10px;
  animation: loaderProgress 1.5s ease-in-out infinite;
}

.splash-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@keyframes logoPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

@keyframes loaderProgress {
  0% {
    transform: translateX(-100%);
  }

  50% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(-100%);
  }
}

/* ─── Update Prompt & Errors ────────────────────────────────────────────── */

.update-prompt {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 480px;
  background: rgba(200, 240, 96, 0.95);
  color: #0f0f0f;
  padding: 16px 20px;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
  animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.update-prompt p {
  font-weight: 600;
  font-size: 0.9rem;
}

#btn-update-now {
  background: #0f0f0f;
  color: #fff;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 0.8rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.error-state {
  text-align: center;
  padding: 40px 20px;
  background: rgba(255, 77, 77, 0.05);
  border: 1px dashed var(--danger);
  border-radius: 24px;
  margin-top: 2rem;
}

.error-state h3 {
  color: var(--danger);
  margin-bottom: 8px;
}

.error-state p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 20px;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 100px);
    opacity: 0;
  }

  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* ─── Settings Module ────────────────────────────────────────────────────── */

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
}

.settings-card h3 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.settings-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.settings-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-group label {
  font-size: 0.9rem;
  font-weight: 500;
}

.settings-group input[type="time"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--font-mono);
}

.settings-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.danger-zone {
  border-color: rgba(255, 77, 77, 0.3);
}

.danger-zone h3 {
  color: var(--danger);
}

/* ─── Force Login Overlay ────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 20px;
}

.login-card h1 {
  margin-bottom: 12px;
  font-size: 1.8rem;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 30px;
  line-height: 1.6;
}

.login-status {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--accent);
  min-height: 1.2em;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
}

.settings-actions button {
  flex: 1;
  min-width: 150px;
  margin: 0 !important;
}