/* ==========================================
   LAN CONNECT - MODERN DARK UI STYLESHEET
   ========================================== */

:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(23, 31, 51, 0.7);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(15, 23, 42, 0.8);
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #8b5cf6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* --- App Container & Layout --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
}

.logo-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Header ECG Pulse Line Canvas */
.header-ecg-canvas {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  border: 1px solid var(--bg-card-border);
  margin-left: 12px;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.15);
  vertical-align: middle;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.device-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--bg-card-border);
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-subtle);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px 32px;
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* --- Cards & Containers --- */
.sidebar, .dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

/* --- Form Controls & Buttons --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-text {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-text:focus {
  border-color: var(--primary);
}

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--bg-card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.btn-text:hover {
  color: var(--danger);
}

/* --- Peer Discovery Cards --- */
.device-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
}

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
}

.device-card.self {
  border-color: rgba(59, 130, 246, 0.3);
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-name {
  font-size: 13px;
  font-weight: 600;
}

.device-ip {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Dropzone & File Transfers --- */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  background: rgba(15, 23, 42, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.drop-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.drop-text {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Transfer Queue Cards */
.transfer-queue {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.transfer-card {
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.transfer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.transfer-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.1s linear;
}

.progress-fill.failed {
  background: var(--danger);
}

.transfer-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Received Vault Cards */
.received-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.received-card {
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.received-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-info-col {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.file-name-text {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.file-size-text {
  font-size: 11px;
  color: var(--text-muted);
}

.preview-container {
  width: 100%;
  max-height: 160px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-img, .preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-pdf {
  width: 100%;
  height: 140px;
  border: none;
}

/* --- Real-Time Chat Engine --- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 320px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 4px;
}

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-bubble.sent {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-bubble.received {
  align-self: flex-start;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.chat-meta {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state-small {
  color: var(--text-muted);
  font-size: 12px;
  padding: 8px 0;
}

/* --- Modal Popup Component --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
  transform: scale(1);
  transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-card {
  transform: scale(0.95);
}

.modal-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Status Footer --- */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 32px;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid var(--bg-card-border);
  font-size: 12px;
  color: var(--text-muted);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.developer-credit {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.developer-credit strong {
  color: var(--text-main);
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

/* Responsive Overrides */
@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  
  .app-header, .status-bar {
    padding: 12px 16px;
  }

  .header-ecg-canvas {
    display: none; /* Hide ECG canvas on narrow mobile screens to avoid overflow */
  }
}

/* --- Animated Network Canvas Background --- */
#network-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  background: #0b0f19;
}
