/* =========================================================================
   style.css — Custom styles for WebGIS Pemantauan Tutupan Lahan
   Works alongside Tailwind CSS (via CDN) and MapLibre GL JS
   ========================================================================= */

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

/* ── Root variables ── */
:root {
  --color-primary: #0f766e;
  --color-primary-light: #14b8a6;
  --color-primary-dark: #0d5c56;
  --color-accent: #f59e0b;
  --color-bg-dark: #0f172a;
  --color-bg-card: #1e293b;
  --color-bg-sidebar: #0f172aee;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --sidebar-width: 380px;
  --navbar-height: 60px;
  --footer-height: 40px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--color-bg-dark);
  color: var(--color-text);
  overflow: hidden;
}

/* ── Navbar ── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: linear-gradient(135deg, var(--color-bg-dark) 0%, #1a2744 100%);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar__logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(14, 165, 149, 0.3);
}

.navbar__title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.navbar__subtitle {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 400;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar__link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.navbar__link:hover {
  color: var(--color-primary-light);
  background: rgba(20, 184, 166, 0.08);
  border-color: rgba(20, 184, 166, 0.2);
}

.navbar__link--active {
  color: var(--color-primary-light);
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.25);
}

/* ── Layout ── */
.app-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--navbar-height);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-bg-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 500;
  transition: transform 0.3s ease;
}

.sidebar__section {
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar__section:last-child {
  border-bottom: none;
}

.sidebar__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Radio / Toggle Group ── */
.toggle-group {
  display: flex;
  background: var(--color-bg-dark);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--color-border);
}

.toggle-group__btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}

.toggle-group__btn.active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: #fff;
  box-shadow: 0 2px 8px rgba(14, 165, 149, 0.35);
}

.toggle-group__btn:hover:not(.active) {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Select / Dropdown ── */
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg-dark);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-select:focus {
  outline: none;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

/* ── Stats panel ── */
.stats-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 20px 0;
}

.stats-card {
  background: var(--color-bg-dark);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.stats-card:hover {
  border-color: var(--color-primary);
  background: rgba(14, 165, 149, 0.05);
}

.stats-card__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stats-card__value {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary-light);
  white-space: nowrap;
}

.stats-card__change {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.stats-card__change--positive {
  color: var(--color-success);
  background: rgba(34, 197, 94, 0.12);
}

.stats-card__change--negative {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.12);
}

.stats-total {
  background: linear-gradient(135deg, rgba(14, 165, 149, 0.1), rgba(14, 165, 149, 0.05));
  border-color: var(--color-primary);
  margin-top: 12px;
}

.stats-total .stats-card__value {
  font-size: 16px;
}

/* ── Loading spinner ── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Map Container ── */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* MapLibre popup overrides */
.maplibregl-popup-content {
  background: var(--color-bg-card) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 12px !important;
  padding: 16px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
  font-family: 'Inter', sans-serif !important;
  min-width: 200px;
}

.maplibregl-popup-close-button {
  color: var(--color-text-muted) !important;
  font-size: 18px !important;
  right: 8px !important;
  top: 8px !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--color-bg-card) !important;
}

.popup-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-primary-light);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.popup-row:last-child {
  border-bottom: none;
}

.popup-row__label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.popup-row__value {
  font-weight: 600;
}

/* ── Footer ── */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  background: var(--color-bg-dark);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 0 24px;
}

.footer__text {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 400;
}

/* ── Toast / Notification ── */
.toast {
  position: fixed;
  top: 80px;
  right: 24px;
  padding: 14px 20px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 360px;
}

.toast.show {
  transform: translateX(0);
}

.toast--success { border-left: 4px solid var(--color-success); }
.toast--error { border-left: 4px solid var(--color-danger); }
.toast--info { border-left: 4px solid var(--color-primary-light); }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state__text {
  font-size: 14px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.empty-state__hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
  opacity: 0.6;
}

/* ── Mobile sidebar toggle ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 56px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  z-index: 800;
  box-shadow: 0 4px 16px rgba(14, 165, 149, 0.4);
  transition: transform 0.2s;
}

.sidebar-toggle:hover {
  transform: scale(1.1);
}

/* ── Button base ── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: #fff;
  box-shadow: 0 2px 8px rgba(14, 165, 149, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(14, 165, 149, 0.45);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar__subtitle { display: none; }
  .navbar__title { font-size: 14px; }

  .sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: var(--footer-height);
    transform: translateX(-100%);
    z-index: 700;
    width: 85vw;
    max-width: 380px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .map-container {
    width: 100%;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}
