/* ─────────────────────────────────────────
   FleetCtrl — style.css
   ───────────────────────────────────────── */

:root {
  --bg:        #0d0f14;
  --bg2:       #13161e;
  --bg3:       #1a1e29;
  --border:    #252b3a;
  --accent:    #00e5ff;
  --accent2:   #00b3cc;
  --text:      #e8eaf0;
  --text2:     #8892a4;
  --danger:    #e05c5c;
  --success:   #4ecb71;
  --card:      #1a1d24;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --radius:    12px;
  --font-head: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Space Mono', monospace;
  --sidebar-w: 220px;
}

[data-theme="light"] {
  --bg:     #f0f2f7;
  --bg2:    #ffffff;
  --bg3:    #e8ebf2;
  --border: #d0d5e0;
  --accent: #2563eb;
  --accent2:#0891b2;
  --text:   #1a1e29;
  --text2:  #5a6275;
  --card:   #ffffff;
  --shadow: 0 4px 24px rgba(0,0,0,.10);
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { touch-action: manipulation; word-break: break-word; overflow-wrap: break-word; }
html, body { height: 100%; font-family: var(--font-head); background: var(--bg); color: var(--text); transition: background .3s, color .3s; }
button  { cursor: pointer; font-family: var(--font-head); border: none; outline: none; }
input, select, textarea { font-family: var(--font-head); outline: none; border: none; }
a { text-decoration: none; color: inherit; }

/* ─── ANIMATIONS ─── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── LOADING ─── */
#loading-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}

/* ─── LOGIN ─── */
#login-page {
  position: fixed; inset: 0; background: var(--bg-color, var(--bg));
  display: flex; align-items: center; justify-content: center; z-index: 900;
}
#login-page.active { display: flex; }

.login-card {
  background: var(--surface-color, var(--card)); border: 1px solid var(--border); border-radius: 20px;
  padding: 48px 40px; width: 100%; max-width: 400px;
  text-align: center; box-shadow: var(--shadow); animation: fadeUp .5s ease;
}
.login-logo { font-size: 32px; font-weight: 700; color: var(--text-primary, var(--accent)); letter-spacing: -1px; margin-bottom: 8px; }
.login-logo span { color: var(--primary-accent, var(--accent2)); }
.login-sub { color: var(--text-secondary, var(--text2)); font-size: 15px; margin-bottom: 36px; }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 16px 40px; background: var(--primary-accent, var(--accent)); border: none; color: #000; border-radius: 50px;
  font-size: 1.2rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; transition: all 0.3s; animation: pulse-glow 3s infinite;
  margin-top: 20px;
}
.btn-google:hover {
  background-color: #ffffff;
  box-shadow: 0 0 25px var(--primary-accent, var(--accent));
  animation: none;
  transform: scale(1.05);
  color: #0f1115;
  border: none;
}
.btn-google svg  { width: 24px; height: 24px; }

/* ─── APP LAYOUT ─── */
#app { display: none; height: 100vh; overflow: hidden; }
#app.active { display: flex; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; transition: transform .3s;
}
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.logo { font-size: 20px; font-weight: 800; color: var(--accent); letter-spacing: -0.5px; }
.logo span { color: var(--accent2); }

.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }
.user-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px;
}

.nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px;
  font-size: 13px; font-weight: 600; color: var(--text2);
  cursor: pointer; transition: all .2s; border-left: 3px solid transparent;
}
.nav-item:hover  { color: var(--text); background: var(--bg3); }
.nav-item.active { color: var(--accent); background: var(--bg3); border-left-color: var(--accent); }
.nav-item svg    { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.btn-theme {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text2); font-size: 12px; font-weight: 600; transition: all .2s; width: 100%;
}
.btn-theme:hover { color: var(--accent); border-color: var(--accent); }
.btn-logout {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text2); font-size: 12px; font-weight: 600; transition: all .2s; width: 100%;
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }

/* ─── MAIN ─── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.topbar {
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); flex-shrink: 0;
}
.menu-toggle { display: none; background: none; padding: 4px; color: var(--text2); }
.menu-toggle svg { width: 22px; height: 22px; }
.page-title { font-size: 20px; font-weight: 800; color: var(--text); flex: 1; }
.content { padding: 28px; flex: 1; }

/* ─── STAT CARDS ─── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--accent); font-family: var(--font-mono); }
.stat-sub   { font-size: 11px; color: var(--text2); margin-top: 4px; }
.stat-remaining { font-size: 18px; margin-top: 8px; font-weight: 800; font-family: var(--font-mono); }

/* ─── SECTION HEADER & BUTTONS ─── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.section-title { font-size: 15px; font-weight: 700; color: var(--text); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px;
  background: var(--accent); color: #000; border-radius: 8px;
  font-size: 13px; font-weight: 700; transition: all .2s;
}
.btn-primary:hover { background: #ffffff; box-shadow: 0 0 15px var(--accent); transform: translateY(-1px); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px;
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  border-radius: 8px; font-size: 13px; font-weight: 600; transition: all .2s;
}
.btn-secondary:hover { border-color: var(--accent2); color: var(--accent2); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: transparent; border: 1px solid var(--danger); color: var(--danger);
  border-radius: 6px; font-size: 12px; font-weight: 600; transition: all .2s;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-edit {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  border-radius: 6px; font-size: 12px; font-weight: 600; transition: all .2s;
}
.btn-edit:hover { border-color: var(--accent2); color: var(--accent2); }

/* ─── TABLE ─── */
.table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 12px 16px; text-align: left; color: var(--text2);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 12px 16px; color: var(--text); white-space: nowrap; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge-fuel { background: rgba(245,166,35,.15); color: var(--accent); }
.badge-oil  { background: rgba(62,207,207,.15);  color: var(--accent2); }
.badge-ok   { background: rgba(78,203,113,.15);  color: var(--success); }
.badge-warn { background: rgba(224,92,92,.15);   color: var(--danger); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 800;
  display: none; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 100%; max-width: 480px;
  animation: fadeUp .3s ease; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 24px; color: var(--text); }

.form-grid { display: grid; gap: 16px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.field input,
.field select,
.field textarea {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text);
  font-size: 14px; transition: border-color .2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); }
.field select option { background: var(--bg2); }

.modal-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }
.btn-cancel {
  padding: 10px 20px; background: transparent; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text2); font-size: 13px; font-weight: 600; transition: all .2s;
}
.btn-cancel:hover { border-color: var(--danger); color: var(--danger); }
.btn-save {
  padding: 10px 24px; background: var(--accent); color: #000;
  border-radius: 8px; font-size: 13px; font-weight: 700; transition: all .2s;
}
.btn-save:hover { background: #e09510; }

/* ─── SHARE LIST ─── */
.share-list  { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.share-item  {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg3); border-radius: 8px; border: 1px solid var(--border);
}
.share-item span { font-size: 13px; color: var(--text); }

/* ─── DASHBOARD CHARTS ─── */
.chart-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px;
}
.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.chart-title {
  font-size: 13px; font-weight: 700; color: var(--text2);
  margin-bottom: 16px; text-transform: uppercase; letter-spacing: .05em;
}
.bar-chart  { display: flex; flex-direction: column; gap: 10px; }
.bar-row    { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bar-label  { width: 90px; color: var(--text2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track  { flex: 1; background: var(--bg3); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill   { height: 100%; border-radius: 4px; background: var(--accent); transition: width .8s cubic-bezier(.4,0,.2,1); }
.bar-fill.teal { background: var(--accent2); }
.bar-val    { width: 60px; color: var(--text); font-family: var(--font-mono); font-size: 11px; }

.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--bg3); border-radius: 8px; border: 1px solid var(--border);
}
.recent-item-left { display: flex; flex-direction: column; gap: 2px; }
.recent-item-name { font-size: 13px; font-weight: 600; color: var(--text); }
.recent-item-sub  { font-size: 11px; color: var(--text2); }
.recent-item-val  { font-size: 13px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); }

/* ─── EXPORT ─── */
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.export-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; gap: 12px; transition: all .2s;
}
.export-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.export-card h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.export-card p  { font-size: 12px; color: var(--text2); line-height: 1.5; }
.export-card button { align-self: flex-start; }

/* ─── TOAST ─── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast-msg {
  padding: 12px 18px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); animation: slideIn .3s ease; pointer-events: all;
}
.toast-msg.success { border-color: var(--success); color: var(--success); }
.toast-msg.error   { border-color: var(--danger);  color: var(--danger); }

/* ─── MOBILE OVERLAY ─── */
.overlay-mobile { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 699; }
.overlay-mobile.active { display: block; }

/* ─── FILTER BAR ─── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input,
.filter-bar select {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; color: var(--text); font-size: 13px; transition: border-color .2s;
}
.filter-bar input:focus,
.filter-bar select:focus  { border-color: var(--accent); }
.filter-bar select option { background: var(--bg2); }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 700;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle  { display: flex; }
  .form-row     { grid-template-columns: 1fr; }
  .content      { padding: 16px; }
  .topbar       { padding: 14px 16px; }
  .chart-grid   { grid-template-columns: 1fr; }
  .table-wrap { overflow: auto; }
  #toast { max-width: calc(100vw - 32px); right: 16px; bottom: 16px; }
}

@media (max-width: 480px) {
  :root { --sidebar-w: 180px; }
  .content { padding: 12px; }
  .topbar { padding: 12px; }
  .page-title { font-size: 17px; }
  .stat-value { font-size: 22px; }
  .stat-card { padding: 14px; }
  .modal { padding: 20px; }
  .modal-overlay { padding: 12px; }
  .bar-label { width: 70px; }
  .bar-val { width: 50px; }
}

@media (pointer: coarse) {
  .btn-primary, .btn-secondary, .btn-cancel, .btn-save { padding: 12px 20px; }
  .btn-danger, .btn-edit { padding: 10px 16px; }
  .nav-item { padding: 14px 20px; }
  .btn-theme, .btn-logout { padding: 12px 14px; }
}
