:root {
  --bg: #f2f4f8;
  --bg-card: #ffffff;
  --text: #1c2130;
  --text-muted: #6b7280;
  --primary: #ffb703;
  --primary-dark: #e09400;
  --accent: #2563eb;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --border: #e2e5eb;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 14px;
  --sidebar-w: 210px;
}

[data-theme="dark"] {
  --bg: #12141c;
  --bg-card: #1b1e2a;
  --text: #eef0f5;
  --text-muted: #9aa0ad;
  --border: #2a2e3d;
  --shadow: 0 2px 10px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50;
}

.brand { font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.stat-strip, .topbar-right {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.topbar-right { margin-left: auto; }

.stat {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.85rem; font-weight: 600;
  background: var(--bg);
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.stat .ic { font-size: 1rem; }

.icon-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { background: var(--primary); color: #fff; }

/* LAYOUT */
.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 10px;
  gap: 4px;
  flex-shrink: 0;
}
.navbtn {
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
.navbtn:hover { background: var(--bg); }
.navbtn.active { background: var(--primary); color: #1c2130; }

.content { flex: 1; padding: 20px 26px; overflow-y: auto; }
.content h1 { margin-top: 0; font-size: 1.5rem; }
.content h2 { font-size: 1.15rem; margin-top: 26px; }

.tab { display: none; }
.tab.active { display: block; animation: fadein 0.25s ease; }

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

.muted { color: var(--text-muted); font-size: 0.88rem; }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h3 { margin-top: 0; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.active-ride-box { min-height: 60px; }
.ride-progress-bar {
  height: 10px; background: var(--border); border-radius: 6px; overflow: hidden; margin-top: 8px;
}
.ride-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 0.3s linear;
}

.event-feed { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.event-item { font-size: 0.85rem; padding: 6px 8px; border-radius: 8px; background: var(--bg); }
.event-item.pos { border-left: 3px solid var(--success); }
.event-item.neg { border-left: 3px solid var(--danger); }
.event-item.info { border-left: 3px solid var(--accent); }

.quick-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.quick-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.quick-list li:last-child { border-bottom: none; }

/* RIDES */
.ride-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 12px; }
.ride-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.ride-card.vip { border: 2px solid var(--primary); }
.ride-card h4 { margin: 0 0 6px; display:flex; justify-content: space-between; align-items:center;}
.ride-route { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.ride-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.78rem; margin-bottom: 10px; }
.ride-meta span { background: var(--bg); padding: 3px 8px; border-radius: 8px; }
.vip-badge { background: var(--primary); color:#1c2130; padding: 2px 8px; border-radius: 8px; font-size: 0.72rem; font-weight:800;}

/* FLEET */
.fleet-grid, .driver-grid, .upgrade-grid, .city-grid, .achievement-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 12px; margin-bottom: 10px;
}
.fleet-card, .driver-card, .upgrade-card, .city-card, .achievement-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); position: relative;
}
.fleet-card .emoji, .city-card .emoji { font-size: 2rem; }
.fleet-card h4, .driver-card h4, .upgrade-card h4, .city-card h4 { margin: 6px 0; }
.stat-bar-row { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; margin-bottom: 3px; }
.stat-bar { flex:1; height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--accent); }
.badge { display:inline-block; font-size: 0.7rem; padding: 2px 7px; border-radius: 8px; background: var(--bg); margin-right:4px;}
.badge.busy { background: var(--warn); color: #fff; }
.badge.idle { background: var(--success); color: #fff; }
.badge.locked { background: var(--danger); color: #fff; }

/* BUTTONS */
button { font-family: inherit; }
.btn-primary, .btn-secondary, .btn-danger {
  border: none; border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer; font-size: 0.85rem;
}
.btn-primary { background: var(--primary); color: #1c2130; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.small { padding: 5px 10px; font-size: 0.75rem; margin-bottom: 8px; }

.card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* MISSIONS */
.mission-list { display: flex; flex-direction: column; gap: 10px; }
.mission-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.mission-card.done { opacity: 0.55; }
.mission-progress { flex:1; min-width: 160px; }
.mission-bar { height: 8px; background: var(--border); border-radius: 5px; overflow: hidden; margin-top:5px;}
.mission-bar-fill { height: 100%; background: var(--success); }

/* ACHIEVEMENTS */
.achievement-card.locked { opacity: 0.4; filter: grayscale(1); }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 12px; }
.stat-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align:center; box-shadow: var(--shadow);}
.stat-box .val { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.stat-box .lbl { font-size: 0.78rem; color: var(--text-muted); }

/* FINANCE */
.finance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 14px; }
.loan-options { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.loan-option { display:flex; justify-content: space-between; align-items:center; background: var(--bg); padding: 8px 10px; border-radius: 10px; font-size: 0.85rem;}

/* SETTINGS */
.difficulty-options { display: flex; gap: 10px; flex-wrap: wrap; }
.difficulty-btn {
  padding: 8px 14px; border-radius: 10px; border: 2px solid var(--border); background: var(--bg-card); cursor: pointer; font-weight:700;
}
.difficulty-btn.active { border-color: var(--primary); background: var(--primary); color: #1c2130; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.save-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* OVERLAY / TUTORIAL */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.overlay.hidden { display: none; }
.tutorial-box {
  background: var(--bg-card); border-radius: var(--radius); padding: 26px; max-width: 420px; width: 90%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3); text-align: center;
}
.tutorial-actions { display: flex; justify-content: space-between; margin-top: 18px; gap: 10px; }

/* TUTORIAL: progresso */
.tut-progress {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px; text-align: left;
}
.tut-progress-bar { height: 5px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.tut-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.3s ease; }

/* TUTORIAL: spotlight (destaque de elemento real da interface) */
#tutSpotlight {
  position: fixed;
  border: 2px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.62), 0 0 0 5px rgba(255,183,3,0.25);
  pointer-events: none;
  z-index: 998;
  transition: top 0.35s ease, left 0.35s ease, width 0.35s ease, height 0.35s ease, opacity 0.2s ease;
}
#tutSpotlight.hidden { display: none; }

/* TUTORIAL: balão explicativo (coachmark) junto ao elemento destacado */
#tutTooltip {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  width: 300px;
  max-width: calc(100vw - 24px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  z-index: 1000;
  transition: top 0.3s ease, left 0.3s ease;
}
#tutTooltip.hidden { display: none; }
#tutTooltip::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
#tutTooltip.arrow-top::before { top: -7px; left: 26px; transform: rotate(45deg); }
#tutTooltip.arrow-bottom::before { bottom: -7px; left: 26px; transform: rotate(225deg); }
#tutTooltip.arrow-left::before { left: -7px; top: 22px; transform: rotate(315deg); }
#tutTooltip.arrow-right::before { right: -7px; top: 22px; transform: rotate(135deg); }

.tut-title { margin: 0 0 6px; font-size: 1.02rem; }
.tut-text { margin: 0 0 12px; font-size: 0.86rem; color: var(--text); line-height: 1.5; }
.tut-hint {
  font-size: 0.78rem; font-weight: 700; color: var(--primary-dark);
  background: rgba(255,183,3,0.15); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px;
  animation: tutPulse 1.6s infinite;
}
[data-theme="dark"] .tut-hint { color: var(--primary); }
.tut-hint.hidden { display: none; }
@keyframes tutPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.tut-actions-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tut-skip-link {
  background: none; border: none; color: var(--text-muted); font-size: 0.76rem;
  cursor: pointer; text-decoration: underline; padding: 4px; white-space: nowrap;
}
.tut-skip-link:hover { color: var(--text); }
#tutNext2.hidden, #tutSkip2.hidden { display: none; }

/* TOASTS */
.toast-container {
  position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: 320px;
}
.toast {
  background: var(--bg-card); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; box-shadow: var(--shadow); font-size: 0.85rem; animation: slidein 0.25s ease;
}
.toast.pos { border-left-color: var(--success); }
.toast.neg { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* SCROLLBARS */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* RESPONSIVE */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: -220px; top: 0; bottom: 0; z-index: 200; transition: left 0.25s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  .sidebar.open { left: 0; }
  .layout { position: relative; }
  .topbar-right, .stat-strip { gap: 8px; }
  .stat { font-size: 0.75rem; padding: 4px 7px; }
  .brand span { display: none; }
}
