/* assets/css/style.css */
/* Reset dasar */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: Arial, sans-serif;
}

/* Layout wrapper */
.layout-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Header navbar */
.navbar {
  height: 56px;
  background-color: #343a40;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 15px;
  z-index: 1000;
  width: 100%;
  position: absolute;
  top: 0; left: 0; right: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  margin-right: 15px;
}

.logo { font-size: 18px; font-weight: bold; }

/* Main container for content and sidebar
   Catatan: bottom akan di-set dinamis via JS agar tidak ada ruang putih */
.main-container {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 56px; /* nilai awal aman (akan ditimpa JS sesuai tinggi footer) */
  overflow: hidden;
  display: flex;
}

/* Sidebar */
.sidebar {
  position: absolute;
  top: 0;
  left: -250px;
  bottom: 0;
  width: 250px;
  background-color: #2c3e50;
  color: white;
  transition: left 0.3s ease;
  z-index: 900;
  overflow-y: auto;
}
.sidebar.open { left: 0; }

.sidebar-header {
  padding: 15px;
  font-size: 16px;
  background-color: #1a2530;
  text-align: center;
  border-bottom: 1px solid #465b70;
}

.sidebar-search { padding: 10px 15px; border-bottom: 1px solid #465b70; }
.search-input { position: relative; }
.search-input i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #7f8c8d;
}
.search-input input {
  width: 100%;
  padding: 8px 8px 8px 30px;
  background-color: #34495e;
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 14px;
}
.search-input input::placeholder { color: #95a5a6; }

.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li { border-bottom: 1px solid #465b70; }
.sidebar-menu a {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: white;
  text-decoration: none;
  transition: background-color 0.2s;
}
.sidebar-menu a:hover, .sidebar-menu a.active { background-color: #34495e; }
.sidebar-menu i { margin-right: 10px; width: 20px; text-align: center; }

.submenu-toggle { margin-left: auto; transition: transform 0.3s; }
.has-submenu.open .submenu-toggle { transform: rotate(180deg); }
.submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  background-color: #1a2530;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.submenu.open { max-height: 300px; }
.submenu a { padding-left: 45px; }

.device-lists-container { padding: 15px; }
.device-category h3 { font-size: 14px; margin-bottom: 10px; color: #ecf0f1; }
.device-list { max-height: 200px; overflow-y: auto; margin-bottom: 20px; }
.device-list a {
  display: block;
  padding: 8px 10px;
  color: white;
  text-decoration: none;
  background-color: #34495e;
  margin-bottom: 5px;
  border-radius: 3px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.2s;
}
.device-list a:hover { background-color: #465b70; }

/* Main content area */
.main-content {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  transition: padding-left 0.3s ease;
  overflow: hidden;
}

/* Push content saat sidebar terbuka (desktop) */
body.sidebar-open .main-content { padding-left: 250px; }

/* Mobile behavior */
@media (max-width: 768px) {
  body.sidebar-open .main-content { padding-left: 0; }
  .sidebar { width: 80%; max-width: 250px; }

  /* Izinkan konten utama scroll pada mobile agar tidak muncul ruang kosong */
  .main-content {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Map */
#map { width: 100%; height: 100%; position: relative; z-index: 1; }

/* Footer (adaptif + desktop dan mobile list) */
.app-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  min-height: 44px;
  background: rgba(47, 54, 64, 0.92);
  color: #ecf0f1;
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  z-index: 1000;
  border-top: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: saturate(120%) blur(4px);
}

/* Desktop layout */
.footer-content.footer-desktop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-left, .footer-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}
.footer-left .brand { font-weight: 600; letter-spacing: .3px; }
.footer-left .divider { opacity: .5; }
.conn-info {
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.3;
}
.version {
  background: rgba(255,255,255,0.08);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.25);
}
.hotspot-badge {
  background: rgba(0, 153, 255, 0.18);
  color: #9bd3ff;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1;
}
.footer-right .version:hover { background: rgba(255,255,255,0.15); }

/* Mobile list layout (default: hidden) */
.footer-content.footer-mobile-list { display: none; }

@media (max-width: 768px) {
  .footer-content.footer-desktop { display: none; }
  .footer-content.footer-mobile-list { display: block; width: 100%; }

  .footer-mobile-list .footer-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 3px 0;
    font-size: 14px;
    line-height: 1.35;
    border-bottom: 1px dashed rgba(255,255,255,0.08);
  }
  .footer-mobile-list .footer-row:last-child {
    border-bottom: none;
    margin-top: 4px;
  }
  .footer-mobile-list .label {
    color: #cfd8dc;
    min-width: 120px;
  }
  .footer-mobile-list .value {
    color: #ffffff;
    text-align: right;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .footer-mobile-list .footer-row.center { justify-content: center; }
  .footer-mobile-list .muted { color: #b0bec5; font-size: 13px; text-align: center; }
}

/* User dropdown */
.user-dropdown { position: relative; margin-left: auto; }
.user-trigger {
  display: flex; align-items: center; cursor: pointer;
  padding: 5px 10px; border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.1);
  transition: background-color 0.3s;
}
.user-trigger:hover { background-color: rgba(255, 255, 255, 0.2); }
.user-icon { margin-right: 8px; font-size: 16px; }
.user-name { margin-right: 8px; font-size: 14px; }
.dropdown-arrow { font-size: 10px; }
.user-dropdown-content {
  display: none; position: absolute; top: 40px; right: 0;
  background-color: #2c3e50; min-width: 200px; border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); z-index: 1002; padding: 10px;
}
.user-dropdown-content.show { display: block; }
.user-info-details {
  margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #465b70;
}
.user-info-details p { margin: 5px 0; color: #ecf0f1; font-size: 14px; }
.profile-btn, .logout-btn {
  display: block; padding: 8px 10px; border-radius: 4px;
  text-decoration: none; font-size: 14px; text-align: center; margin-bottom: 5px;
}
.profile-btn { background: #3498db; color: white; }
.logout-btn { background: #e74c3c; color: white; }
.profile-btn:hover { background: #2980b9; }
.logout-btn:hover { background: #c0392b; }

/* Utility */
.text-success { color: #2ecc71; }
.text-danger  { color: #e74c3c; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex; justify-content: center; align-items: center; z-index: 2000;
}
.modal-content {
  background-color: white; border-radius: 5px; padding: 20px;
  width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto;
}
.modal-content h2 { margin-top: 0; color: #333; }

/* Login page */
body.login-page {
  background-color: #2d3436;
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; height: 100vh; margin: 0; padding: 20px; box-sizing: border-box;
  color: white;
}
.login-container {
  background-color: #34495e; border-radius: 8px;
  width: 100%; max-width: 400px; padding: 30px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3); position: relative; margin: auto;
}
@media (max-width: 768px) { .login-container { max-width: 90%; padding: 20px; } }

/* Messages */
.success-message {
  background-color: rgba(46,204,113,0.2);
  color: #2ecc71; padding: 10px; border-radius: 4px; margin-bottom: 15px;
  border-left: 4px solid #2ecc71;
}
.error-message {
  background-color: rgba(231,76,60,0.2);
  color: #e74c3c; padding: 10px; border-radius: 4px; margin-bottom: 15px;
  border-left: 4px solid #e74c3c;
}

/* Leaflet controls: akan disetel ulang via JS sesuai tinggi footer */
.leaflet-top { top: 10px !important; }
.leaflet-bottom { bottom: 56px !important; }

/* iOS Safari fix */
@supports (-webkit-overflow-scrolling: touch) {
  html, body { height: -webkit-fill-available; }
  .layout-wrapper { height: -webkit-fill-available; }
  .sidebar, .main-content, #map { -webkit-overflow-scrolling: touch; }
}

/* Debug button (opsional) */
.debug-toggle-button {
  position: fixed;
  bottom: 70px; right: 20px;
  z-index: 9999;
  padding: 10px; background: #e74c3c; color: white;
  border: none; border-radius: 4px; cursor: pointer;
}

.marker-tooltip {
  background-color: rgba(255, 255, 255, 0.2);
  padding: 2px 5px;
  border: 1px solid #ccc;
  font-size: 10px;
  font-weight: bold;
  color: #0f0;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
  white-space: nowrap;
}
