@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Light Theme (Default) */
  --primary: #1A73E8;
  --primary-hover: #1557b0;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #10b981;
  --warning: #eab308;
  --bg-color: #f1f5f9;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.1);
  --text-main: #0f172a;
  --text-muted: #475569;
  --auth-bg: rgba(224, 231, 255, 0.25);
  --nav-hover: rgba(0, 0, 0, 0.05);
  --title-gradient: linear-gradient(135deg, #1A73E8, #4f46e5);
  --input-bg: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] {
  /* Dark Theme */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #facc15;
  --bg-color: #0f172a;
  --glass-bg: rgba(15, 23, 42, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --auth-bg: rgba(15, 23, 42, 0.45);
  --nav-hover: rgba(255, 255, 255, 0.1);
  --title-gradient: linear-gradient(135deg, #60a5fa, #a78bfa);
  --input-bg: rgba(15, 23, 42, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100%;
  transition: background-color 0.3s, color 0.3s;
}

/* Glassmorphism Auth Panels */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--auth-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  transition: background 0.3s;
  overflow-y: auto;
  padding: 20px 0;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.4s ease-out;
  transition: background 0.3s, border-color 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1.app-title {
  font-size: 28px;
  font-weight: 700;
  background: var(--title-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  margin-bottom: 24px;
}

.input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-main);
  transition: border-color 0.2s, background 0.3s, color 0.3s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
}

.input::placeholder {
  color: var(--text-muted);
}

.input-label {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 4px;
  margin-left: 2px;
}

.btn {
  width: 100%;
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.link {
  text-align: center;
  margin-top: 16px;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s;
}

.link:hover {
  color: var(--primary-hover);
}

.error {
  color: var(--danger);
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* Map & App Layout */
#appLayout {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Floating Sidebar */
.sidebar {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: 300px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s, border-color 0.3s;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.sidebar.collapsed {
  transform: translateX(-340px);
  /* Move offscreen */
}

/* Toggle Button */
.sidebar-toggle {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1001;
  /* Above map, below or equal to sidebar if we want it floating */
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  font-size: 24px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
  transition: opacity 0.3s, background 0.3s, color 0.3s;
}

.sidebar-toggle.hidden-toggle {
  opacity: 0;
  pointer-events: none;
}

/* Top Right Controls */
.top-right-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1001;
  /* Above map */
  display: flex;
  gap: 12px;
  align-items: center;
}

.control-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  height: 50px;
  width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  font-size: 22px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
  transition: opacity 0.3s, background 0.3s, color 0.3s, transform 0.2s;
}

.control-btn:hover {
  transform: translateY(-2px);
  background: var(--nav-hover);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 600;
  background: var(--title-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--text-main);
}

.user-info {
  margin-bottom: 24px;
}

.user-info h3 {
  font-size: 16px;
  color: var(--text-main);
  font-weight: 500;
}

.user-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border-radius: 12px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--nav-hover);
  border-color: var(--glass-border);
  transform: translateX(4px);
}

.nav-item.danger {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.nav-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.sidebar-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

.logout-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--nav-hover);
}

/* Map Popup Overrides */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--bg-color) !important;
  color: var(--text-main) !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) !important;
  border: 1px solid var(--glass-border) !important;
}

.leaflet-popup-content b {
  color: var(--primary) !important;
}

/* ===== SIDEBAR DESIGN IMPROVEMENTS & MOBILE VIEW ===== */
.sidebar {
  padding: 24px 20px;
  gap: 16px;
  overflow: hidden;
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: 300px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s, border-color 0.3s;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.sidebar.collapsed {
  transform: translateX(-340px);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  .sidebar {
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 300px;
    border-radius: 0 24px 24px 0;
    transform: translateX(-110%);
    box-shadow: 20px 0 30px rgba(0, 0, 0, 0.3);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-backdrop.active {
    display: block;
    opacity: 1;
  }
}

.sidebar-header {
  margin-bottom: 0;
  padding-bottom: 12px;
}

.sidebar-header h2 {
  font-size: 20px;
  letter-spacing: -0.3px;
}

.user-info {
  background: linear-gradient(145deg, var(--nav-hover), rgba(255, 255, 255, 0.02));
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 8px;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.user-info:hover {
  background: var(--nav-hover);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.nav-menu {
  gap: 8px;
  margin-top: 8px;
}

.nav-item {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  justify-content: flex-start;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  background: var(--nav-hover);
  border-color: var(--glass-border);
  transform: translateX(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-item:active {
  transform: scale(0.98) translateX(4px);
  background: rgba(0, 0, 0, 0.08);
}

/* OTP Boxes */
.otp-box {
  width: 56px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  caret-color: transparent;
}

.otp-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

/* Notification Panel */
.notification-panel {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 320px;
  max-height: 400px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.3s, transform 0.3s;
}
.notification-panel.hidden-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}
.notif-header {
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notif-list {
  overflow-y: auto;
  flex: 1;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background 0.2s;
}
.notif-item:hover {
  background: var(--nav-hover);
}
.notif-item.unread {
  background: rgba(26, 115, 232, 0.05);
  border-left: 4px solid var(--primary);
}
.notif-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.notif-body {
  font-size: 13px;
  color: var(--text-muted);
}
.notif-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}
.notif-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: bold;
  height: 18px;
  min-width: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.notif-badge.hidden {
  display: none !important;
}

/* Password Toggle */
.password-wrapper {
  position: relative;
  display: block;
  width: 100%;
  margin-bottom: 16px;
}
.password-wrapper .input {
  margin-bottom: 0;
  padding-right: 44px;
}
.eye-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color 0.2s;
}
.eye-toggle:hover {
  color: var(--text-main);
}