/* 
   FamilyConnect Premium Dark Glassmorphic Design System
   Color Palette: Deep Midnight Navy, Neon Cyan, Royal Violet, Soft White Typography
*/

:root {
  --bg-primary: #080a10;
  --bg-secondary: #0e1220;
  --panel-bg: rgba(18, 24, 43, 0.65);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f1f3f9;
  --text-muted: #8d98af;
  --neon-cyan: #00f0ff;
  --neon-purple: #9d4edd;
  --neon-green: #390099;
  --accent-blue: #3a86f0;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  --font-family: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar configuration */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

/* App Layout */
.app-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling */
.sidebar {
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 8px;
}

.brand-logo {
  font-size: 24px;
  color: var(--neon-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.neon-glow {
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
  filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.4));
}

.brand-name h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-name h2 span {
  color: var(--neon-cyan);
}

.brand-name .subtext {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
}

/* Nav Menu */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.nav-item i {
  font-size: 18px;
  width: 20px;
  display: flex;
  justify-content: center;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(58, 134, 240, 0.15), rgba(157, 78, 221, 0.15));
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: var(--neon-cyan);
  box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.05);
}

/* Active Devices List inside Sidebar */
.member-list-panel {
  flex: 1;
  border-top: 1px solid var(--panel-border);
  padding-top: 24px;
  overflow-y: auto;
}

.section-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  padding: 0 8px;
}

.sidebar-devices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-device-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-device-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.sidebar-device-item.active {
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.03);
}

.device-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

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

.device-item-battery {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.device-item-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.device-item-battery.charging {
  color: var(--accent-success);
}

.device-item-battery.low {
  color: var(--accent-danger);
}

.dot-online {
  height: 6px;
  width: 6px;
  background-color: var(--accent-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-success);
}

.dot-offline {
  height: 6px;
  width: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
}

.admin-profile .avatar {
  height: 36px;
  width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
}

.profile-info .name {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.profile-info .role {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Top Header */
.app-header {
  height: 80px;
  border-bottom: 1px solid var(--panel-border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 10, 16, 0.8);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.header-title .subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 12px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-success);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-primary-neon {
  background: linear-gradient(135deg, #00d2ff 0%, #00a8ff 100%);
  border: none;
  color: #080a10;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn-primary-neon:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 210, 255, 0.5);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-danger);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
  border-color: var(--accent-danger);
}

/* Content Container & Switchable Panes */
.content-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  display: none;
  height: 100%;
  width: 100%;
}

.tab-pane.active {
  display: block;
}

/* TAB 1: Leaflet Live Map Integration */
.map-wrapper {
  position: relative;
  height: 100%;
  width: 100%;
}

#map {
  height: 100%;
  width: 100%;
  background: #080a10;
}

/* Glassmorphic Map Overlay for Live Signal Stream */
.map-overlay-widget {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 320px;
  max-height: calc(100% - 40px);
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  z-index: 1000;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.widget-header h3 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 10px;
  text-transform: uppercase;
  background: rgba(0, 240, 255, 0.1);
  color: var(--neon-cyan);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.pings-feed {
  flex: 1;
  overflow-y: auto;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.ping-feed-item {
  border-left: 2px solid var(--accent-blue);
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  animation: slideIn 0.3s ease-out;
}

.ping-feed-item.location { border-color: var(--neon-cyan); }
.ping-feed-item.sms { border-color: var(--neon-purple); }
.ping-feed-item.calls { border-color: var(--accent-warning); }

.feed-item-time {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Glassmorphic custom layout to match openstreetmap color theme */
.leaflet-container {
  font-family: var(--font-family) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-secondary) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--panel-border);
  border-radius: 12px !important;
  box-shadow: var(--glass-shadow) !important;
}

.leaflet-popup-tip {
  background: var(--bg-secondary) !important;
}

/* Leaflet dark filter */
.leaflet-tile-layer {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* Log View Layout (SMS and Calls) */
.log-view-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px 32px;
  gap: 20px;
  overflow: hidden;
}

.filter-bar {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: 16px 20px;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

.search-input-wrapper input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 16px 12px 48px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.search-input-wrapper input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.filter-actions {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 4px;
}

.filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn:hover {
  color: var(--text-main);
}

.filter-btn.active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
}

/* Premium Glassmorphic Table */
.log-table-container {
  flex: 1;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow-y: auto;
  box-shadow: var(--glass-shadow);
}

.premium-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.premium-table th {
  padding: 18px 24px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 10, 16, 0.3);
  position: sticky;
  top: 0;
  z-index: 10;
}

.premium-table td {
  padding: 16px 24px;
  font-size: 14px;
  color: var(--text-main);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.premium-table tbody tr {
  transition: var(--transition);
}

.premium-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

/* SMS Type Pill Labels */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
}

.type-badge.incoming {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-success);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.type-badge.outgoing {
  background: rgba(58, 134, 240, 0.1);
  color: var(--accent-blue);
  border: 1px solid rgba(58, 134, 240, 0.15);
}

.type-badge.missed {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.05);
}

.empty-state.hidden {
  display: none !important;
}

/* TAB 4: Devices Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  padding: 24px 32px;
  overflow-y: auto;
  max-height: 100%;
}

.device-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: var(--transition);
}

.device-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 240, 255, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header .avatar {
  height: 48px;
  width: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neon-cyan);
  font-size: 20px;
}

.card-header .online-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
}

.device-info h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.device-info .device-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}

.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
  padding: 16px 0;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.metric-label {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-value {
  font-weight: 500;
}

.btn-card-action {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 10px;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-card-action:hover {
  background: var(--neon-cyan);
  color: #080a10;
  font-weight: 600;
  border-color: var(--neon-cyan);
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.2);
}

/* Spinner for loading */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  gap: 8px;
  padding: 24px 0;
}

/* Custom Leaflet Map Markers Styling */
.leaflet-custom-marker {
  background: none !important;
  border: none !important;
}

.custom-map-marker {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--neon-purple));
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 10;
  position: relative;
}

.custom-map-marker.online .marker-circle {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px var(--neon-cyan);
}

.custom-map-marker.offline .marker-circle {
  border-color: var(--text-muted);
  background: #2b3040;
}

.marker-pulse {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.2);
  z-index: 1;
  animation: markerPulse 2s infinite ease-out;
  display: none;
}

.custom-map-marker.online .marker-pulse {
  display: block;
}

@keyframes markerPulse {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.marker-label {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 10, 16, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  pointer-events: none;
}

