/* =====================================================
   ZAGORA GPS - Professional Mobile App Theme
   Modern, clean design optimized for mobile devices
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ====== CSS VARIABLES ====== */
:root {
  --primary: #1A237E;
  --primary-light: #283593;
  --primary-dark: #0D143F;
  --accent: #1565C0;
  --accent-light: #1976D2;
  --success: #2E7D32;
  --warning: #F57F17;
  --danger: #C62828;
  --info: #0277BD;
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --text: #1A202C;
  --text-secondary: #718096;
  --text-muted: #A0AEC0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --nav-height: 56px;
  --tab-height: 64px;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ====== BASE ====== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 0 !important;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }
b, strong { font-weight: 600; }

/* ====== TOP NAVBAR ====== */
.navbar.navbar-default.navbar-fixed-top {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%) !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: 0 2px 8px rgba(26,35,126,0.3) !important;
  height: var(--nav-height);
  min-height: var(--nav-height);
  padding: 0;
  z-index: 1040;
}

.navbar.navbar-default.navbar-fixed-top .container-fluid {
  padding: 0 8px;
  height: var(--nav-height);
  display: flex;
  align-items: center;
}

.navbar-default .navbar-brand,
.navbar-default .navbar-brand:hover {
  color: #fff !important;
  font-weight: 600;
  font-size: 16px;
  padding: 0 12px;
  line-height: var(--nav-height);
  letter-spacing: 0.3px;
}

#page_title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.3px;
}

/* hamburger icon */
.show-menu.icon-only {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.15) !important;
  color: #fff !important;
  transition: var(--transition);
}
.show-menu.icon-only:hover { background: rgba(255,255,255,0.25) !important; }
.show-menu.icon-only i { color: #fff !important; font-size: 20px; margin: 0; }

/* navbar selects */
.navbar-btn.form-control {
  background: rgba(255,255,255,0.15) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.25) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 12px;
  height: 36px;
  min-height: 36px;
  padding: 4px 8px;
  box-shadow: none !important;
  margin: 0 4px;
}
.navbar-btn.form-control option { background: var(--primary); color: #fff; }
.navbar-btn.form-control:focus { outline: none; border-color: rgba(255,255,255,0.5) !important; }

/* ====== PAGE LAYOUT ====== */
.page-map {
  position: fixed !important;
  top: var(--nav-height) !important;
  bottom: var(--tab-height) !important;
  left: 0 !important;
  right: 0 !important;
  padding: 0 !important;
}

.page {
  display: none;
  position: fixed;
  top: var(--nav-height);
  bottom: var(--tab-height);
  left: 0;
  right: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

/* ====== BOTTOM TAB BAR ====== */
#bottom-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  display: flex;
  align-items: stretch;
  z-index: 1050;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 2px;
  position: relative;
  color: var(--text-muted);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.tab-item:hover, .tab-item:active { background: var(--bg); }

.tab-item.active {
  color: var(--accent);
}

.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}

.tab-item i {
  font-size: 18px;
  line-height: 1;
  margin: 0;
}

.tab-item .tab-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* More menu */
#tab-more-menu {
  position: fixed;
  bottom: var(--tab-height);
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 1049;
  display: none;
  padding: 8px 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#tab-more-menu.open { display: block; }

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.more-menu-item:hover { background: var(--bg); }
.more-menu-item i {
  width: 24px;
  text-align: center;
  font-size: 18px;
  color: var(--accent);
}
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1048;
  display: none;
}
.more-menu-overlay.open { display: block; }

/* ====== LOADING PANEL ====== */
#loading_panel {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#loading_data_panel {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

/* modern spinner */
.loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
  display: block;
}

.loader span { display: none; }

#loading_panel .loader {
  border-color: rgba(255,255,255,0.3);
  border-top-color: #fff;
  width: 56px;
  height: 56px;
}

#loading_data_panel .loader {
  border-color: rgba(26,35,126,0.2);
  border-top-color: var(--accent);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* loading text */
.loading-text {
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 500;
  margin-top: 16px;
  letter-spacing: 0.5px;
}

/* ====== MAP ====== */
#map {
  position: absolute !important;
  top: 0 !important; bottom: 0 !important;
  left: 0 !important; right: 0 !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 18px !important;
  color: var(--text) !important;
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.leaflet-left .leaflet-control { margin-top: 12px; margin-left: 12px; }

/* ====== BOTTOM PANEL (datalist) ====== */
#bottom_panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 500;
  max-height: 220px;
}

.datalist-object-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.datalist-object-name-close-icon {
  float: none;
  width: 28px;
  height: 28px;
  background-color: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.datalist-item-list {
  height: 110px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  padding: 8px;
  font-size: 11px;
}

.datalist-item {
  width: 220px;
  min-width: 220px;
  margin-right: 12px;
  padding: 2px 6px;
  line-height: 22px;
  background: var(--surface-2);
  border-radius: 6px;
  margin-bottom: 2px;
}

/* ====== GRAPH PANEL ====== */
.graph-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 500;
  max-height: 220px;
  display: none;
}

.graph-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.graph-controls select.form-control {
  height: 34px;
  min-height: 34px;
  font-size: 13px;
  border-radius: var(--radius-sm) !important;
}

.graph-controls-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.graph-controls-right a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.graph-panel-plot {
  padding: 4px 12px;
}

/* ====== HISTORY NAVBAR (bottom) ====== */
#history_navbar {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface) !important;
  border-top: 1px solid var(--border) !important;
  border: none;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

#history_navbar .container-fluid {
  padding: 6px 8px;
}

#history_navbar .btn {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 12px;
  padding: 8px 4px;
  width: 100%;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
}

#history_navbar .btn:hover, #history_navbar .btn:active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

#history_navbar .btn i { margin: 0; font-size: 14px; }

/* ====== HISTORY PLAYBACK ====== */
#history_playback {
  bottom: 56px !important;
  left: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px 12px;
  font-size: 13px;
}

#history_playback a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--accent) !important;
  margin: 0 2px;
}

#history_playback a:hover { background: var(--accent); color: #fff !important; }
#history_playback select { height: 32px !important; min-height: 32px; padding: 0 6px; border-radius: var(--radius-sm) !important; }

/* ====== DETAILS PANEL ====== */
.details-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  z-index: 100;
  display: none;
  padding: 8px;
}

.details-panel .panel {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  border: 1px solid var(--border) !important;
  overflow: hidden;
  margin-bottom: 8px;
}

.details-panel .list-group-item {
  border-color: var(--border) !important;
  font-size: 12px;
  padding: 8px 12px;
}

/* ====== MENU PAGE ====== */
#page_menu.page-menu {
  position: fixed;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 2000;
  display: none;
  background: rgba(26,35,126,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.page-menu .menu-block {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: var(--surface);
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

#page_menu.page-menu.open .menu-block {
  transform: translateX(0);
}

.page-menu .title-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--nav-height);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  flex-shrink: 0;
}

.page-menu .page-title {
  color: #fff !important;
  font-size: 17px;
  font-weight: 700;
  background: transparent !important;
  letter-spacing: 0.3px;
}

.page-menu .title-block a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.page-menu ul.menu {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
}

.page-menu ul.menu li a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.page-menu ul.menu li a:hover,
.page-menu ul.menu li a.active {
  background: rgba(21,101,192,0.07);
  color: var(--accent);
  border-left-color: var(--accent);
}

.page-menu ul.menu li a i {
  width: 24px;
  text-align: center;
  font-size: 18px;
  color: var(--accent);
  margin: 0;
}

.page-menu .button-block {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: #FFF5F5;
  border: 1px solid #FED7D7;
  border-radius: var(--radius);
  color: var(--danger) !important;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}
.logout-btn:hover { background: var(--danger); color: #fff !important; }
.logout-btn i { margin: 0; font-size: 16px; }

/* ====== OBJECTS PAGE ====== */
#page_objects, #page_object_details {
  padding: 0;
}

.page-search-bar {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 12px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

#page_objects .form-group.btn-group {
  margin: 0;
  width: 100%;
}

#page_objects .input-group.form-group.btn-group {
  margin: 12px 12px 0;
  width: calc(100% - 24px);
  display: flex;
}

#page_object_search {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
  border-right: none !important;
  font-size: 14px !important;
  height: 44px;
}

#page_object_search_clear {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-left: none !important;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  cursor: pointer;
  padding: 0 12px;
  display: flex;
  align-items: center;
}

#page_object_list_header {
  padding: 8px 12px 0;
  margin-bottom: 0;
}

#page_object_list_header .object-group {
  border-radius: var(--radius-sm) !important;
  margin-bottom: 6px;
  height: 40px;
  font-size: 13px;
}

#page_object_list_header .list-group-item {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
  background: var(--surface);
  padding: 8px 12px;
}

#page_object_list {
  padding: 8px 12px 80px;
}

#page_object_list .list-group-item {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface);
  margin-bottom: 6px;
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
  transition: var(--transition);
}

#page_object_list .list-group-item:hover,
#page_object_list .list-group-item:active {
  box-shadow: var(--shadow);
  border-color: var(--accent) !important;
}

.object-list-item {
  height: 44px;
}

.object-list-item .left {
  width: 140px;
}

.object-list-item .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.object-list-item .status {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.object-list-item .visible,
.object-list-item .follow {
  font-size: 18px;
  color: var(--text-muted) !important;
  padding: 0 6px;
}

.object-list-item .checked { color: var(--accent) !important; }
.object-list-item .details { color: var(--accent) !important; font-size: 18px; }

/* ====== EVENTS PAGE ====== */
#page_events { padding: 0; }

#page_events .input-group.form-group.btn-group {
  margin: 12px 12px 0;
  width: calc(100% - 24px);
}

#page_event_search {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
  border-right: none !important;
  height: 44px; font-size: 14px !important;
}

#page_event_search_clear {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-left: none !important;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  cursor: pointer; padding: 0 12px;
}

#page_event_list {
  padding: 8px 12px 80px;
}

#page_event_list .list-group-item {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface);
  margin-bottom: 6px;
  box-shadow: var(--shadow-sm);
  padding: 12px;
  font-size: 13px;
}

/* ====== PLACES PAGE ====== */
#page_places { padding: 0; padding-bottom: calc(var(--tab-height) + 56px); }

.markers-panel, .routes-panel, .zones-panel {
  display: none;
  padding: 8px 12px;
}

#page_markers_panel_search, #page_routes_panel_search, #page_zones_panel_search {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
  border-right: none !important;
  height: 44px; font-size: 14px !important;
}

#page_markers_panel_search_clear, #page_routes_panel_search_clear, #page_zones_panel_search_clear {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-left: none !important;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  cursor: pointer; padding: 0 12px;
}

#page_markers_panel_list .list-group-item,
#page_routes_panel_list .list-group-item,
#page_zones_panel_list .list-group-item {
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface);
  margin-bottom: 6px;
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  padding: 12px;
}

/* places bottom nav */
#places_navbar {
  position: fixed !important;
  bottom: var(--tab-height) !important;
  left: 0; right: 0;
  background: var(--surface) !important;
  border: none !important;
  border-top: 1px solid var(--border) !important;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  z-index: 1030;
}

#places_navbar .container-fluid { padding: 6px 8px; }

#places_navbar .btn {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 12px;
  padding: 8px 4px;
  width: 100%;
  font-weight: 500;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#places_navbar .btn.active,
#places_navbar .btn:hover {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
#places_navbar .btn i { margin: 0; font-size: 14px; }

/* ====== HISTORY PAGE ====== */
#page_history { padding: 12px 12px 80px; }

#page_history .form-group {
  margin-bottom: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

#page_history .row.vertical-align {
  align-items: center;
}

#page_history .col-xs-6:first-child {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}

#page_history select.form-control,
#page_history input.form-control {
  border-radius: var(--radius-sm) !important;
  font-size: 13px;
  height: 40px;
  min-height: 40px;
}

#page_history .input-group .input-group-addon {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  background: var(--bg) !important;
  border-color: var(--border) !important;
  cursor: pointer;
}

#page_history button.btn {
  border-radius: var(--radius-sm) !important;
  font-size: 13px;
  padding: 10px 16px;
  min-height: 40px;
  font-weight: 500;
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
#page_history button.btn:last-child {
  background: var(--bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* ====== COMMANDS PAGE ====== */
#page_cmd { padding: 12px 12px 80px; }

#page_cmd .form-group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

#page_cmd .col-xs-6:first-child {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}

#page_cmd select.form-control,
#page_cmd input.form-control {
  border-radius: var(--radius-sm) !important;
  font-size: 13px;
  height: 40px;
  min-height: 40px;
}

#page_cmd button.btn {
  border-radius: var(--radius-sm) !important;
  font-size: 14px;
  padding: 12px 20px;
  min-height: 44px;
  font-weight: 600;
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  width: 100%;
}
#page_cmd button.btn:hover { background: var(--primary) !important; border-color: var(--primary) !important; }

/* ====== SETTINGS PAGE ====== */
#page_settings { padding: 12px 12px 80px; }

#page_settings h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin: 16px 0 8px;
  padding: 0 4px;
}

#page_settings h4:first-child { margin-top: 4px; }

#page_settings .form-group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

#page_settings .row.vertical-align {
  min-height: 40px;
}

#page_settings .col-xs-6:first-child {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

#page_settings select.form-control,
#page_settings input.form-control {
  border-radius: var(--radius-sm) !important;
  font-size: 13px;
  height: 40px;
  min-height: 40px;
  border-color: var(--border) !important;
}

#page_settings button.btn {
  border-radius: var(--radius-sm) !important;
  font-size: 14px;
  padding: 12px 24px;
  min-height: 44px;
  font-weight: 600;
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  transition: var(--transition);
}
#page_settings button.btn:hover { background: var(--primary) !important; }

/* ====== BACK BUTTON ====== */
.back-btn {
  display: none !important; /* replaced by tab bar */
}

/* ====== FORM CONTROLS (global) ====== */
.form-control {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
  font-size: 14px;
  height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(21,101,192,0.12) !important;
  outline: none;
}

.input-group-addon {
  border-color: var(--border) !important;
  background: var(--bg) !important;
  border-radius: 0 !important;
  color: var(--text-secondary);
}

/* ====== BUTTONS (global) ====== */
.btn {
  border-radius: var(--radius-sm) !important;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  min-height: 44px;
  border-color: var(--border) !important;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn i { margin: 0; }

.btn.btn-blue, .btn-primary {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.btn.btn-blue:hover, .btn-primary:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}

.btn.btn-default {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.btn.btn-default:hover {
  background: var(--bg) !important;
}

/* ====== PANELS ====== */
.panel {
  border-radius: var(--radius) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

.panel .list-group-item {
  border-color: var(--border) !important;
  font-size: 12px;
  padding: 8px 12px;
}

/* ====== LIST GROUPS ====== */
.list-group-item {
  border-color: var(--border) !important;
}
.list-group-item:first-child { border-radius: 0 !important; }
.list-group-item:last-child { border-radius: 0 !important; }

/* ====== MODALS ====== */
.modal-content {
  border-radius: var(--radius-lg) !important;
  border: none !important;
  box-shadow: var(--shadow-lg) !important;
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  border: none;
  padding: 16px 20px;
}

.modal-title { color: #fff; font-weight: 600; }
.modal-header .close { color: #fff; opacity: 0.8; font-size: 24px; margin-top: -2px; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; }
.modal-backdrop { background-color: rgba(26,35,126,0.5); }

/* ====== VERTICAL ALIGN HELPER ====== */
.vertical-align { display: flex; align-items: center; }

/* ====== TABLE HELPERS ====== */
.table-helper { display: flex; height: 100%; width: 100%; align-items: center; justify-content: center; }

/* ====== DATEPICKER ====== */
.dtpicker-content { background: var(--surface); border-radius: var(--radius); }
.dtpicker-components .dtpicker-comp { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dtpicker-components .dtpicker-compValue { border-color: var(--border); }
.dtpicker-buttonCont { margin: 10px 0; }
.dtpicker-components .dtpicker-compButton,
.dtpicker-components .dtpicker-compButton:hover { background: var(--bg); color: var(--text); }

/* ====== NAVBAR LOGIN PAGE ====== */
.login-page .navbar { display: none; }

/* ====== LOADER (Loading screen) table helper ====== */
#loading_panel .table, #loading_data_panel .table { display: flex; height: 100%; }
#loading_panel .table-cell, #loading_data_panel .table-cell { display: flex; align-items: center; justify-content: center; flex: 1; flex-direction: column; }

/* ====== SCROLLBARS ====== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ====== RESPONSIVE ====== */
@media (max-width: 400px) {
  .tab-item .tab-label { display: none; }
  :root { --tab-height: 52px; }
  .tab-item i { font-size: 22px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root { --nav-height: 46px; --tab-height: 50px; }
  .tab-item .tab-label { display: none; }
  .tab-item i { font-size: 20px; }
}

/* ====== SAFE AREA (notch support) ====== */
@supports (padding: env(safe-area-inset-top)) {
  .navbar.navbar-default.navbar-fixed-top {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--nav-height) + env(safe-area-inset-top));
  }
  .page-map, .page {
    top: calc(var(--nav-height) + env(safe-area-inset-top)) !important;
  }
  #bottom-tab-bar {
    height: calc(var(--tab-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .page, .page-map {
    bottom: calc(var(--tab-height) + env(safe-area-inset-bottom)) !important;
  }
}

/* ====== PULSE ANIMATION FOR ALERTS ====== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.alert-pulse { animation: pulse 2s ease-in-out infinite; }

/* =====================================================
   IMPROVEMENTS v2 — Enhanced UX & Visual Polish
   ===================================================== */

/* ====== PAGE TRANSITIONS ====== */
.page, .page-map {
  opacity: 1;
  transition: opacity 0.2s ease;
}
.page-enter {
  animation: pageSlideIn 0.25s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes pageSlideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ====== BRANDED LOADING SCREEN ====== */
.loading-brand-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  background: rgba(255,255,255,0.15);
  padding: 8px;
}
.loading-app-name {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}
.loading-app-sub {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 28px;
}
#loading_panel .loader {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ====== OBJECT STATUS COLOR DOTS ====== */
.object-list-item .name::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
/* JS adds these classes to the list-group-item */
#page_object_list .list-group-item.status-moving .name::before { background: #22C55E; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
#page_object_list .list-group-item.status-stopped .name::before { background: #F59E0B; }
#page_object_list .list-group-item.status-offline .name::before { background: #94A3B8; }
#page_object_list .list-group-item.status-moving { border-left: 3px solid #22C55E !important; }
#page_object_list .list-group-item.status-stopped { border-left: 3px solid #F59E0B !important; }
#page_object_list .list-group-item.status-offline { border-left: 3px solid #94A3B8 !important; }

/* ====== EVENTS BADGE ====== */
#tab-events {
  position: relative;
}
#events-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  background: #EF4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(239,68,68,0.4);
}
#events-badge.visible { display: flex; }

/* ====== TOUCH RIPPLE ====== */
.list-group-item {
  position: relative;
  overflow: hidden;
}
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(21,101,192,0.12);
  transform: scale(0);
  animation: ripple 0.5s linear;
  pointer-events: none;
}
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ====== IMPROVED SETTINGS — iOS STYLE ====== */
#page_settings {
  padding: 0 0 80px;
  background: var(--bg);
}
#page_settings h4 {
  padding: 20px 16px 6px;
  margin: 0;
}
#page_settings .form-group {
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  margin-bottom: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: none !important;
  background: var(--surface);
}
#page_settings .form-group:first-of-type {
  border-top: 1px solid var(--border) !important;
}
/* group the first item with rounded top, last with rounded bottom */
.settings-group {
  border-radius: var(--radius) !important;
  overflow: hidden;
  margin: 0 12px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.settings-group .form-group {
  border-radius: 0 !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: none !important;
  padding: 13px 16px;
}
.settings-group .form-group:last-child {
  border-bottom: none !important;
}
.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  padding: 20px 16px 8px;
}

/* ====== IMPROVED HISTORY FORM ====== */
#page_history {
  padding: 0 0 80px;
  background: var(--bg);
}
.history-card {
  margin: 12px 12px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.history-card .form-group {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 !important;
  box-shadow: none !important;
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
}
.history-card .form-group:last-child { border-bottom: none; }
.history-actions {
  margin: 12px 12px 0;
  display: flex;
  gap: 8px;
}
.history-actions button {
  flex: 1;
  min-height: 46px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  border-radius: var(--radius) !important;
}

/* ====== IMPROVED COMMANDS FORM ====== */
#page_cmd {
  padding: 0 0 80px;
  background: var(--bg);
}
.cmd-card {
  margin: 12px 12px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.cmd-card .form-group {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 !important;
  box-shadow: none !important;
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
}
.cmd-card .form-group:last-child { border-bottom: none; }
.cmd-send-btn {
  margin: 12px 12px 0;
}
.cmd-send-btn button {
  width: 100%;
  min-height: 50px !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  border-radius: var(--radius) !important;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%) !important;
  border: none !important;
  letter-spacing: 0.3px;
}

/* ====== IMPROVED OBJECT DETAILS ====== */
#page_object_details {
  background: var(--bg);
}
#page_object_detail_list.panel {
  margin: 12px;
  border-radius: var(--radius) !important;
  overflow: hidden;
}
#page_object_detail_list .panel-heading {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 600;
  padding: 14px 16px;
}
#page_object_detail_list .list-group-item {
  padding: 11px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#page_object_detail_list .list-group-item .icon {
  width: 28px;
  height: 28px;
  background: var(--bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ====== EMPTY STATE ====== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state p {
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

/* ====== SPEED INDICATOR ====== */
.object-list-item .speed {
  font-size: 12px !important;
  font-weight: 600;
  color: var(--accent);
  background: rgba(21,101,192,0.08);
  border-radius: 6px;
  padding: 2px 6px;
  min-width: 52px;
  text-align: center;
}

/* ====== IMPROVED EVENTS LIST ====== */
#page_event_list .list-group-item {
  padding: 12px 14px;
  border-left: 3px solid var(--accent) !important;
  transition: var(--transition);
}
#page_event_list .list-group-item .icon {
  width: 32px;
  height: 32px;
  background: rgba(21,101,192,0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  float: left;
  margin-right: 10px;
  margin-top: 0;
}

/* ====== MAP LAYER PICKER BADGE ====== */
#map_layer {
  border-radius: var(--radius-sm) !important;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  height: 34px;
  min-height: 34px;
  max-width: 130px;
}

/* ====== PLACES PAGE — IMPROVED TABS ====== */
#places_navbar .row.vertical-align {
  gap: 0;
}
#places_navbar .btn.active,
#places_navbar .width33:first-child .btn-active {
  background: var(--accent) !important;
  color: #fff !important;
}

/* ====== IMPROVED SEARCH BARS ====== */
#page_object_search:focus,
#page_event_search:focus,
#page_markers_panel_search:focus,
#page_routes_panel_search:focus,
#page_zones_panel_search:focus {
  background: #fff;
}

/* ====== PULL-TO-REFRESH HINT ====== */
.page::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

/* ====== SKELETON LOADING ====== */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ====== STATUS BAR COLORED TOP LINE ====== */
.navbar.navbar-default.navbar-fixed-top::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.2);
}

/* ====== IMPROVED BOOTBOX/MODAL ====== */
.bootbox .modal-dialog {
  margin: 20px auto;
  max-width: calc(100% - 32px);
}
.bootbox .modal-footer .btn {
  min-height: 40px !important;
  font-size: 14px !important;
  border-radius: var(--radius-sm) !important;
}

/* ====== SMOOTH SCROLL ====== */
.page, #page_object_list, #page_event_list,
#page_markers_panel_list, #page_routes_panel_list, #page_zones_panel_list {
  scroll-behavior: smooth;
}

/* ====== DATALIST — SLIDE UP ANIMATION ====== */
#bottom_panel {
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
#bottom_panel.hidden {
  transform: translateY(100%);
}

/* ====== HISTORY NAVBAR IMPROVED ====== */
#history_navbar .row.vertical-align {
  gap: 4px;
  padding: 4px 0;
}
#history_navbar .width33 {
  padding: 0 2px;
}
#history_navbar .btn.active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* ====== INPUT CLEAR BUTTON ====== */
#page_object_search_clear,
#page_event_search_clear,
#page_markers_panel_search_clear,
#page_routes_panel_search_clear,
#page_zones_panel_search_clear {
  transition: var(--transition);
}
#page_object_search_clear:active,
#page_event_search_clear:active {
  background: var(--accent) !important;
  color: #fff;
}
#page_object_search_clear .glyphicon,
#page_event_search_clear .glyphicon {
  font-size: 12px;
  color: var(--text-muted);
}

/* ====== IMPROVED PANEL HEADINGS ====== */
.panel-heading {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
}
.panel-heading + .list-group .list-group-item:first-child {
  border-top: none;
}
