/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: #e0e0e0; background: #1a1a2e; }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: #5dade2; text-decoration: none; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1e1e3a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ===== LOGIN SCREEN ===== */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
}
.login-box {
  background: #16213e; border: 1px solid #0f3460;
  border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo i { font-size: 48px; color: #e74c3c; display: block; margin-bottom: 12px; }
.login-logo h1 { font-size: 28px; color: #fff; letter-spacing: 2px; }
.login-logo p { color: #888; margin-top: 4px; }

/* ===== LAYOUT ===== */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#navbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; background: #0d1b2a; border-bottom: 1px solid #1e3a5f;
  padding: 0 12px; flex-shrink: 0; z-index: 1000; position: relative;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 8px; }
.nav-logo { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.nav-logo i { color: #e74c3c; margin-right: 6px; }
.nav-btn {
  background: transparent; border: 1px solid transparent; color: #aaa;
  padding: 6px 10px; border-radius: 8px; transition: all .2s;
}
.nav-btn:hover { color: #fff; background: #1e3a5f; border-color: #2d5a8f; }
.nav-user { color: #aaa; font-size: 13px; padding: 0 8px; }
.nav-user strong { color: #5dade2; }

.content-row { display: flex; flex: 1; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 300px; background: #0d1b2a; border-right: 1px solid #1e3a5f;
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .25s ease, min-width .25s ease;
  flex-shrink: 0;
}
.sidebar.collapsed { width: 0; min-width: 0; }
.sidebar-section { padding: 12px; border-bottom: 1px solid #1e3a5f; }
.section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #666; margin-bottom: 8px; }

.search-wrap { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #555; }
#searchInput {
  width: 100%; padding: 8px 36px; background: #112240; border: 1px solid #1e3a5f;
  border-radius: 8px; color: #e0e0e0; outline: none; transition: border-color .2s;
}
#searchInput:focus { border-color: #5dade2; }
.clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #666; padding: 2px 4px;
}
.clear-btn:hover { color: #aaa; }

/* ===== CATEGORY FILTERS ===== */
.category-filters { display: flex; flex-direction: column; gap: 4px; }
.cat-filter-item {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; transition: background .15s;
}
.cat-filter-item:hover { background: #112240; }
.cat-filter-item input { cursor: pointer; accent-color: #5dade2; }
.cat-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ===== LOCATION LIST ===== */
.location-list { overflow-y: auto; flex: 1; }
.loc-item {
  padding: 10px 12px; border-bottom: 1px solid #1e3a5f; cursor: pointer;
  transition: background .15s; display: flex; align-items: center; gap: 10px;
}
.loc-item:hover { background: #112240; }
.loc-item-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.loc-item-info { flex: 1; min-width: 0; }
.loc-item-title { font-weight: 500; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-item-cat { font-size: 12px; color: #666; }
.badge { background: #1e3a5f; color: #5dade2; font-size: 11px; padding: 2px 6px; border-radius: 10px; margin-left: 4px; }

/* ===== CONTENT ROW ===== */
.content-row { display: flex; flex: 1; overflow: hidden; }

/* ===== MAP ===== */
#map { flex: 1; }

/* ===== MAP CONTROLS ===== */
.map-controls {
  position: absolute; bottom: 32px; right: 16px;
  display: flex; flex-direction: column; gap: 8px; z-index: 900;
  pointer-events: all;
}
.map-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15);
  background: #0d1b2a; color: #ccc; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.5); transition: all .2s;
}
.map-btn:hover { background: #1e3a5f; color: #fff; border-color: #5dade2; }
.map-btn.active { background: #5dade2; color: #000; border-color: #5dade2; }
.map-btn.btn-primary { background: #e74c3c; color: #fff; border-color: #c0392b; }
.map-btn.btn-primary:hover { background: #c0392b; }
#layerBtn.active { background: #1a472a; color: #4ade80; border-color: #4ade80; }

.coords-display {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(13,27,42,.85); backdrop-filter: blur(4px);
  border: 1px solid #1e3a5f; border-radius: 20px;
  padding: 4px 14px; font-size: 12px; color: #aaa; z-index: 900;
  display: flex; align-items: center; gap: 6px;
}
.coords-display i { color: #e74c3c; }

/* ===== LEAFLET POPUP CUSTOM ===== */
.leaflet-popup-content-wrapper {
  background: #0d1b2a; border: 1px solid #1e3a5f;
  border-radius: 10px; color: #e0e0e0; box-shadow: 0 4px 16px rgba(0,0,0,.6);
}
.leaflet-popup-tip { background: #0d1b2a; }
.leaflet-popup-content { margin: 12px 16px; }
.popup-title { font-weight: 700; font-size: 15px; color: #fff; margin-bottom: 4px; }
.popup-cat { font-size: 12px; color: #888; margin-bottom: 6px; }
.popup-desc { font-size: 13px; color: #bbb; margin-bottom: 10px; max-height: 60px; overflow: hidden; }
.popup-btn {
  background: #5dade2; color: #000; border: none; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.popup-btn:hover { background: #85c1e9; }

/* Custom marker divIcon */
.map-marker { display: flex; align-items: center; justify-content: center; }
.map-marker svg { filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }

/* Cluster icon */
.cluster-icon {
  background: #0d1b2a;
  border: 2px solid #5dade2;
  border-radius: 50%;
  color: #5dade2;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.6);
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 16px;
}
.modal {
  background: #0d1b2a; border: 1px solid #1e3a5f; border-radius: 14px;
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.modal-wide { max-width: 720px; }
.modal-sm   { max-width: 380px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #1e3a5f; flex-shrink: 0;
}
.modal-header h2 { font-size: 18px; color: #fff; }
.modal-close {
  background: transparent; border: none; color: #666; font-size: 18px;
  width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #1e3a5f; color: #fff; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid #1e3a5f; display: flex;
  justify-content: flex-end; gap: 8px; flex-shrink: 0;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: #112240; border: 1px solid #1e3a5f;
  border-radius: 8px; padding: 9px 12px; color: #e0e0e0; outline: none;
  transition: border-color .2s; resize: vertical;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #5dade2; }
.form-group input[type="color"] { padding: 4px; height: 38px; cursor: pointer; }
.form-row { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: none; font-weight: 600;
  cursor: pointer; transition: all .2s; font-size: 14px;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-primary { background: #5dade2; color: #000; }
.btn-primary:hover { background: #85c1e9; }
.btn-secondary { background: #1e3a5f; color: #ccc; }
.btn-secondary:hover { background: #2d5a8f; color: #fff; }
.btn-ghost { background: transparent; color: #888; border: 1px solid #333; }
.btn-ghost:hover { background: #1e3a5f; color: #ccc; border-color: #2d5a8f; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }

.error-msg { background: rgba(231,76,60,.15); border: 1px solid #c0392b; border-radius: 8px; padding: 8px 12px; color: #e74c3c; font-size: 13px; margin-top: 8px; }

/* ===== IMAGE UPLOAD ===== */
.images-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.img-thumb {
  position: relative; width: 90px; height: 90px;
  border-radius: 8px; overflow: hidden; border: 2px solid #1e3a5f;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb-del {
  position: absolute; top: 2px; right: 2px; background: rgba(231,76,60,.9);
  color: #fff; border: none; border-radius: 4px; width: 20px; height: 20px;
  font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.upload-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #1e3a5f; color: #ccc; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; font-size: 13px; transition: background .2s;
}
.upload-btn:hover { background: #2d5a8f; color: #fff; }
.upload-progress { font-size: 12px; color: #888; padding: 4px 0; }

/* ===== DETAIL MODAL ===== */
.detail-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: #112240; border: 1px solid #1e3a5f;
  border-radius: 20px; padding: 4px 12px; font-size: 12px; color: #aaa;
}
.detail-tag .cat-dot { width: 8px; height: 8px; }
.detail-gallery {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.gallery-img {
  width: 140px; height: 100px; object-fit: cover;
  border-radius: 8px; cursor: pointer; border: 2px solid #1e3a5f;
  transition: border-color .2s, transform .2s;
}
.gallery-img:hover { border-color: #5dade2; transform: scale(1.03); }
.detail-desc { color: #bbb; line-height: 1.7; margin-bottom: 16px; white-space: pre-wrap; }
.detail-coords { color: #666; font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.detail-coords i { color: #e74c3c; }
.map-link {
  display: inline-flex; align-items: center;
  background: #112240; border: 1px solid #1e3a5f;
  color: #5dade2; font-size: 11px; padding: 2px 8px; border-radius: 10px;
  text-decoration: none; transition: background .15s;
}
.map-link:hover { background: #1e3a5f; color: #85c1e9; }

/* ===== ADMIN PANEL ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #1e3a5f; margin-bottom: 16px; }
.tab-btn {
  background: transparent; border: none; color: #888; padding: 8px 16px;
  border-bottom: 2px solid transparent; font-weight: 600; transition: all .2s;
}
.tab-btn.active { color: #5dade2; border-bottom-color: #5dade2; }
.tab-btn:hover { color: #ccc; }
.tab-content { }
.tab-toolbar { margin-bottom: 12px; }
.admin-list { border: 1px solid #1e3a5f; border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.admin-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid #1e3a5f; background: #112240;
}
.admin-row:last-child { border-bottom: none; }
.admin-row:hover { background: #162d4a; }
.admin-row-info { flex: 1; }
.admin-row-name { font-weight: 600; color: #ddd; }
.admin-row-meta { font-size: 12px; color: #666; }
.admin-row-actions { display: flex; gap: 6px; }
.role-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.role-admin  { background: rgba(231,76,60,.2);  color: #e74c3c; }
.role-user   { background: rgba(93,173,226,.2); color: #5dade2; }
.role-viewer { background: rgba(127,140,141,.2); color: #7f8c8d; }
.color-swatch { width: 20px; height: 20px; border-radius: 4px; border: 2px solid #1e3a5f; flex-shrink: 0; }
.inline-form {
  background: #112240; border: 1px solid #2d5a8f;
  border-radius: 10px; padding: 16px; margin-top: 8px;
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint { font-size: 11px; color: #666; font-weight: 400; }

/* ===== PICK OVERLAY ===== */
.pick-overlay {
  position: fixed; inset: 0; z-index: 1500;
  pointer-events: none; /* always passthrough so Leaflet receives clicks */
}
.pick-banner {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  background: #0d1b2a; border: 1px solid #5dade2; border-radius: 10px;
  padding: 10px 20px; display: flex; align-items: center; gap: 12px;
  color: #5dade2; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,.5);
  pointer-events: all; white-space: nowrap;
}
#map.pick-active { cursor: crosshair !important; }
#map.pick-active .leaflet-interactive { cursor: crosshair !important; }

/* ===== IMAGE LIGHTBOX ===== */
#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000; cursor: pointer;
}
#lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e3a5f; border: 1px solid #2d5a8f; color: #e0e0e0;
  padding: 10px 20px; border-radius: 20px; z-index: 4000;
  box-shadow: 0 4px 12px rgba(0,0,0,.5); font-size: 13px;
  animation: fadeIn .2s; white-space: nowrap;
}
.toast.success { background: rgba(46,204,113,.15); border-color: #2ecc71; color: #2ecc71; }
.toast.error   { background: rgba(231,76,60,.15);  border-color: #e74c3c; color: #e74c3c; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== GPS MARKER ===== */
.gps-pulse {
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(93,173,226,.3); border: 3px solid #5dade2;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(93,173,226,.5); }
  70%  { box-shadow: 0 0 0 14px rgba(93,173,226,0); }
  100% { box-shadow: 0 0 0 0 rgba(93,173,226,0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .sidebar { width: 100%; position: absolute; z-index: 800; top: 52px; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.mobile-open { transform: translateX(0); }
  .two-col { grid-template-columns: 1fr; }
  .modal { max-width: 100%; margin: 8px; }
}
