:root {
  /* Colors - Android Dark Theme Palette */
  --bg-primary: #121212;
  /* Deep Black */
  --bg-secondary: #1E1E1E;
  /* Surface Gray */
  --bg-tertiary: #2C2C2C;
  /* Elevated Surface */

  /* Android-ish Accents */
  --accent: #3DDC84;
  /* Android Green-ish */
  --accent-hover: #32b56e;

  /* Chat Bubbles */
  --bubble-own: #004D40;
  /* Teal/Green dark */
  --bubble-other: #303030;
  /* Dark Gray */

  --text-primary: #E0E0E0;
  --text-secondary: #A0A0A0;

  --success: #3DDC84;
  --error: #CF6679;
  --warning: #FDD835;

  /* Spacing */
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  /* Borders */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  /* Pill shape */
  --border-color: #333333;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', 'Inter', system-ui, -apple-system, sans-serif;
  /* Roboto is more Android */
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  /* Dynamic viewport height for mobile */
  display: flex;
  overflow: hidden;
}

/* Auth / Overlay */
#login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--bg-secondary);
  padding: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.login-card h2 {
  margin-bottom: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  /* Rounded inputs */
  color: var(--text-primary);
  font-size: 14px;
  transition: border 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #121212;
  /* Dark text on green button */
  font-weight: 500;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: var(--accent-hover);
}

.btn-sm {
  width: auto;
  display: inline-block;
  padding: 8px 16px;
  font-size: 14px;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.error-msg {
  color: var(--error);
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
  min-height: 20px;
}

/* App Layout */
#app-container {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: 250px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
  flex: 1;
  padding: 10px;
}

.nav-item {
  display: block;
  padding: 14px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-lg);
  /* Pill shapes */
  margin-bottom: 4px;
  cursor: pointer;
  font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
  background: var(--bg-tertiary);
  color: var(--accent);
  /* Highlight text option */
}

/* Active style specific for Android feel: maybe a pill background? */
.nav-item.active {
  background: rgba(61, 220, 132, 0.15);
  /* Tinted background */
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
}

.main-content {
  flex: 1;
  padding: 20px;
  /* Reduced padding for more screen */
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.view-section {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.stat-card h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 300;
  /* Thin font for numbers */
}

/* Admin Table */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

/* Chat Layouts - Android Style */
.chat-layout {
  display: flex;
  height: 100%;
  gap: 16px;
}

.peer-sidebar {
  width: 200px;
  /* Slimmer */
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.03);
  /* Very subtle background */
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  /* Cleaner look */
}

.peer-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 10px;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-window {
  flex: 1;
  background: transparent;
  /* Let body bg show */
  /* border: 1px solid var(--border-color); Can remove border for cleaner full-bleed feel */
  border-radius: var(--radius-md);
  padding: 10px 0;
  /* Vertical padding */
  overflow-y: auto;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Tight grouping */
}

.chat-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-secondary);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  /* Pill container */
  margin-bottom: 10px;
  /* Slight bottom margin from edge */
}

.chat-input-area input {
  background: transparent;
  border: none;
  padding: 8px 0;
  border-radius: 0;
}

.chat-input-area input:focus {
  border: none;
  outline: none;
}

.chat-input-area button {
  width: auto;
  aspect-ratio: 1;
  /* Square/Circle button */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  height: 40px;
  width: 40px;
  background: var(--accent);
  color: #000;
}

/* Messages - Bubbles */
.message {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 18px;
  /* Android standard bubble pill */
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  margin-bottom: 2px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.message-own {
  align-self: flex-end;
  background-color: var(--bubble-own);
  color: white;
  border-bottom-right-radius: 4px;
  /* Slight corner visual */
}

.message-other {
  align-self: flex-start;
  background-color: var(--bubble-other);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-sender {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 2px;
  font-weight: bold;
}

.message-content {}

.message.system {
  align-self: center;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

/* Peer Items */
.peer-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 4px;
  background: transparent;
  /* Minimalist list */
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.peer-item:hover {
  background: var(--bg-tertiary);
}

.peer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-weight: bold;
  color: var(--accent);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    z-index: 900;
    flex-direction: row;
    padding: 0;
    background: var(--bg-secondary);
  }

  .sidebar-header,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 0;
    margin: 0;
  }

  .nav-item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    margin: 0;
    border-radius: 0;
    font-size: 12px;
    /* Smaller text */
    display: flex;
    flex-direction: column;
    /* Icon + Text if we had icons */
    align-items: center;
    justify-content: center;
  }

  .nav-item.active {
    background: transparent;
    color: var(--accent);
    border-top: 2px solid var(--accent);
  }

  .main-content {
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    /* Handle notch */
    padding-bottom: 80px;
    /* Nav height + extra buffer */
  }

  /* Chat Stacking */
  .chat-layout {
    flex-direction: column;
    gap: 16px;
  }

  .peer-sidebar {
    width: 100%;
    max-height: none;
    flex-direction: column;
    padding: 8px 16px;
    /* Reduced vertical padding */
    gap: 0;
    background: transparent;
    /* Remove background on mobile */
  }

  /* Hide headers on mobile for "less intrusive" look */
  .peer-sidebar h3,
  .peer-sidebar small {
    display: none;
  }

  .peer-list {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-top: 0;
    /* Remove top margin since headers are gone */
  }

  .peer-item {
    min-width: 60px;
    flex-direction: column;
    text-align: center;
    padding: 0;
    background: transparent;
  }

  .peer-avatar {
    margin-right: 0;
    margin-bottom: 4px;
    width: 48px;
    /* Larger touch target */
    height: 48px;
  }

  /* Make input stick above nav */
  .chat-input-area {
    margin-bottom: 0;
  }
}