/* InfoDrone - Modern Dark Theme */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-card: #161f2d;
  --bg-hover: #1e293b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #06b6d4;
  --accent-secondary: #8b5cf6;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  
  --border-color: #374151;
  --border-light: #1f2937;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.3);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --header-height: 60px;
  --panel-width: 380px;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
}

/* Screens */
.screen {
  width: 100vw;
  height: 100vh;
}

.screen.hidden {
  display: none !important;
}

/* Login Screen */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: 
    radial-gradient(ellipse at top, rgba(6, 182, 212, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    var(--bg-primary);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 48px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  color: var(--accent-primary);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: var(--font-main);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: all 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 500;
  font-family: var(--font-main);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-primary), #0891b2);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-warning {
  background: var(--accent-warning);
  color: #000;
}

.btn-danger {
  background: var(--accent-danger);
  color: white;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.error-message {
  margin-top: 16px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-danger);
  font-size: 0.875rem;
  text-align: center;
  display: none;
}

.error-message.visible {
  display: block;
}

/* Dashboard */
#dashboard {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* Header */
.main-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

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

.logo-small {
  width: 36px;
  height: 36px;
  color: var(--accent-primary);
}

.main-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-warning);
  animation: blink 1.5s infinite;
}

.connection-status.connected .status-dot {
  background: var(--accent-success);
  animation: none;
}

.connection-status.disconnected .status-dot {
  background: var(--accent-danger);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.875rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn-small {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.icon-btn-small:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.icon-btn-small svg {
  width: 18px;
  height: 18px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
}

.leaflet-tile-pane {
  filter: brightness(1.0) contrast(1.0) saturate(1.0);
}

.map-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.map-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.map-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.map-btn svg {
  width: 22px;
  height: 22px;
}

/* Side Panel */
#side-panel {
  width: var(--panel-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
}

.tab-btn {
  flex: 1;
  padding: 16px 8px;
  font-size: 0.8rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

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

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

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.scanners {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-primary);
}

.stat-icon.drones {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-secondary);
}

.stat-icon.detections {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
}

.stat-icon.alerts {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Activity Feed */
.recent-activity h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.activity-item .activity-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-item .activity-icon.drone {
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent-secondary);
}

.activity-item .activity-icon.scanner {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-primary);
}

.activity-item .activity-icon.alert {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-warning);
}

.activity-item .activity-icon svg {
  width: 16px;
  height: 16px;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-content p {
  color: var(--text-primary);
  line-height: 1.4;
}

.activity-content .activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Items List */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.scanner-item, .drone-item, .alert-item {
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.scanner-item:hover, .drone-item:hover, .alert-item:hover {
  border-color: var(--accent-primary);
  background: var(--bg-hover);
}

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

.item-name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.item-status.online {
  background: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
}

.item-status.offline {
  background: var(--text-muted);
}

.item-status.detected {
  background: var(--accent-secondary);
  box-shadow: 0 0 8px var(--accent-secondary);
  animation: pulse 2s infinite;
}

.item-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Drone location & operator info */
.drone-location {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.drone-operator {
  margin-top: 8px;
  padding: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.drone-operator.no-data {
  background: rgba(100, 116, 139, 0.1);
  border-color: rgba(100, 116, 139, 0.3);
}

.drone-operator .operator-label {
  display: block;
  font-weight: 500;
  color: var(--accent-warning);
  margin-bottom: 4px;
}

.drone-operator.no-data .operator-label {
  color: var(--text-muted);
}

.drone-operator .operator-coords {
  display: block;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.drone-operator .operator-id {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Alert Items */
.alert-item {
  border-left: 3px solid var(--accent-warning);
}

.alert-item.critical {
  border-left-color: var(--accent-danger);
}

.alert-item.info {
  border-left-color: var(--accent-primary);
}

.alert-item.acknowledged {
  opacity: 0.6;
  border-left-color: var(--text-muted);
}

/* Filter Select */
.filter-select {
  padding: 6px 12px;
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-large {
  max-width: 800px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* Settings Tabs */
.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.settings-tab {
  padding: 10px 16px;
  font-size: 0.875rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.settings-tab:hover {
  background: var(--bg-hover);
}

.settings-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.settings-tab.admin-only {
  display: none;
}

.admin .settings-tab.admin-only {
  display: inline-block;
}

.settings-content {
  display: none;
}

.settings-content.active {
  display: block;
}

.settings-content h3 {
  font-size: 1rem;
  margin-bottom: 16px;
}

/* Users Table */
.users-table {
  width: 100%;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.user-row .user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.user-row .username {
  font-weight: 500;
}

.user-row .email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.role-badge {
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 20px;
}

.role-badge.admin {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-danger);
}

.role-badge.moderator {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-warning);
}

.role-badge.user {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-primary);
}

.role-badge.provider {
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent-secondary);
}

/* System Info */
.system-info {
  margin-bottom: 24px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.system-item {
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.system-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.system-item .value {
  font-size: 1.1rem;
  font-family: var(--font-mono);
  color: var(--accent-primary);
}

.settings-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.settings-section h4 {
  font-size: 0.875rem;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.save-status {
  font-size: 0.85rem;
  color: var(--accent-success);
}

.save-status.error {
  color: var(--accent-danger);
}

.system-actions h4 {
  font-size: 0.875rem;
  margin-bottom: 12px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Map Markers */
.scanner-marker-container,
.drone-marker-container,
.pilot-marker-container {
  background: transparent !important;
  border: none !important;
}

.scanner-marker {
  width: 30px;
  height: 30px;
  background: var(--accent-primary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

.scanner-marker.offline {
  background: var(--text-muted);
}

.drone-marker {
  width: 24px;
  height: 24px;
  background: var(--accent-secondary);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  animation: drone-pulse 2s infinite;
}

@keyframes drone-pulse {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow-md); }
  50% { transform: scale(1.1); box-shadow: 0 0 15px var(--accent-secondary); }
}

.pilot-marker {
  width: 20px;
  height: 20px;
  background: var(--accent-warning);
  border: 2px solid white;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: var(--shadow-md);
}

/* Leaflet Customization */
.leaflet-popup-content-wrapper {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.leaflet-popup-tip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.leaflet-popup-content {
  margin: 12px 16px;
}

.leaflet-control-zoom {
  border: none !important;
}

.leaflet-control-zoom a {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-hover) !important;
  color: var(--accent-primary) !important;
}

/* Popup Content */
.popup-content {
  min-width: 200px;
}

.popup-content h4 {
  font-size: 1rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-content .popup-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}

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

.popup-content .popup-label {
  color: var(--text-muted);
}

.popup-content .popup-value {
  font-family: var(--font-mono);
  color: var(--accent-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
  #side-panel {
    width: 320px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }
  
  #side-panel {
    width: 100%;
    height: 50%;
  }
  
  #map-container {
    height: 50%;
  }
}
