:root {
  --bg-color: #f5f7fa;
  --text-color: #222;
  --card-bg: #ffffff;

  --border-color: #d0d7de;
  --table-header-bg: #2d8659;
  --table-header-text: #ffffff;
  --table-row-even: #f8fafb;
  --table-row-hover: color-mix(in srgb, #2d8659 8%, #f8fafb);

  --button-bg: #2d8659;
  --button-hover: #25694a;

  --pre-bg: #eef2f5;

  --message-color: #2c7a7b;
  --error-color: #c53030;

  --status-online: #2f9e44;
  --status-offline: #e03131;
  --status-pending: #f59f00;
  --status-unknown: #868e96;

  --accent-blue: #1e88e5;
  --accent-blue-hover: #1565c0;
  --accent-purple: #8e44ad;
  --accent-purple-hover: #6c3483;
  --accent-orange: #fb8c00;
  --accent-orange-hover: #ef6c00;
}

body.dark {
  --bg-color: #0a0e17;
  --text-color: #e8ecef;
  --card-bg: #131820;

  --border-color: #2a3442;
  --table-header-bg: #2f4d68;
  --table-header-text: #f1f5f9;
  --table-row-even: #1a2332;
  --table-row-hover: color-mix(in srgb, #0ea5e9 12%, #131820);

  --button-bg: #10b981;
  --button-hover: #0284c7;

  --pre-bg: #1e293b;

  --message-color: #10b981;
  --error-color: #ef4444;

  --status-online: #10b981;
  --status-offline: #ef4444;
  --status-pending: #f59e0b;
  --status-unknown: #6b7280;

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-purple: #8b5cf6;
  --accent-purple-hover: #7c3aed;
  --accent-orange: #f97316;
  --accent-orange-hover: #ea580c;
}

  body {
  font-family: Arial, sans-serif;
  margin: 20px;
  background: var(--bg-color);
  color: var(--text-color);
}  

h1 {
  color: var(--text-color);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  position: sticky;         
  top: 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.page-title {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 1.6rem;
}

#logoutBtn {
  margin: 0;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--button-bg);
  color: #fff;
  cursor: pointer;
  font-size: 0.9em;
}

#logoutBtn:hover {
  background: var(--button-hover);
}

.right-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.toggle-text {
  font-size: 0.95rem;
}

.theme-toggle input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  width: 40px;
  height: 20px;
  background: #ccc;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.theme-toggle input[type="checkbox"]:checked + .toggle-switch {
  background: #4caf50;
}

.theme-toggle input[type="checkbox"]:checked + .toggle-switch::before {
  transform: translateX(20px);
}

main {
  padding: 20px;
}

table,
#devicesTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 0.92em;
}

th,
td {
  border: 1px solid var(--border-color);
  padding: 6px 8px;
  text-align: left;
  line-height: 1.3;
  vertical-align: middle;
}

th {
  background: var(--table-header-bg) !important;
  color: var(--table-header-text) !important;
  font-weight: 600;
  padding: 8px 10px;
}

tr:nth-child(even),
.device-row:nth-child(even) {
  background: var(--table-row-even);
}

.device-row:hover {
  background: var(--table-row-hover) !important;
  transition: background 0.2s ease;
}

#devicesTable th {
  text-align: left;
  font-weight: bold;
  border-bottom: 2px solid var(--border-color);
}

#devicesTable td {
  border-bottom: 1px solid var(--border-color);
}

#devicesTable th:nth-child(5),
#devicesTable th:nth-child(6),
#devicesTable td:nth-child(5),
#devicesTable td:nth-child(6) {
  text-align: center;
}

#devicesTable th:nth-child(1),
#devicesTable td:nth-child(1) { width: 5%; }
#devicesTable th:nth-child(2),
#devicesTable td:nth-child(2) { width: 17%; }
#devicesTable th:nth-child(3),
#devicesTable td:nth-child(3) { width: 17%; }
#devicesTable th:nth-child(4),
#devicesTable td:nth-child(4) { width: 17%; }
#devicesTable th:nth-child(5),
#devicesTable td:nth-child(5) { width: 17%; }
#devicesTable th:nth-child(6),
#devicesTable td:nth-child(6) { width: 27%; }

.id-cell { text-align: left; font-weight: bold; }
.device-id { font-size: 0.88em; }

.android-id {
  font-size: 1.2em;
  color: var(--text-color);
  word-break: break-all;
  background: var(--pre-bg);
  padding: 3px 6px;
  border-radius: 3px;
  display: inline-block;
}

.date-cell { font-size: 0.88em; }
.date-value { line-height: 1.3; }
.created-cell .date-value { color: var(--text-color); }
.lastseen-cell .date-value { color: var(--text-color); font-weight: 500; }

.status-cell { text-align: center; }
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: bold;
  text-transform: uppercase;
  min-width: 65px;
  color: #fff;
}
.status-cmd {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: bold;
  text-transform: uppercase;
  min-width: 65px;
}
.status-online  { background: var(--status-online); }
.status-offline { background: var(--status-offline); }
.status-pending { background: var(--status-pending); }
.status-unknown { background: var(--status-unknown); }

button,
.action-toggle-btn,
.quick-action-btn {
  padding: 5px 10px;
  background: var(--button-bg);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  margin: 5px 5px 5px 0;
  transition: all 0.3s ease;
  font-size: 0.9em;
}

button:hover,
.action-toggle-btn:hover,
.quick-action-btn:hover {
  background: var(--button-hover);
}

.action-toggle-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  border-radius: 6px;
}

.action-toggle-btn.active { background: var(--status-offline); }

#details {
  margin-top: 30px;
  padding: 15px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

pre {
  background: var(--pre-bg);
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
}

#message {
  margin-top: 10px;
  font-weight: bold;
  color: var(--message-color);
}

#error {
  margin-top: 10px;
  font-weight: bold;
  color: var(--error-color);
}

.side-menu {
  position: absolute;
  width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.25);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  padding: 0;
  overflow: hidden;
}

.side-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 9px;
  border-bottom: 1px solid var(--border-color);
  background: var(--table-header-bg);
  color: var(--table-header-text);
}

.side-menu-header h4 {
  margin: 0;
  font-size: 1em;
}

.close-menu-btn {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1em;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.close-menu-btn:hover {
  background: rgba(255,255,255,0.15);
}

.menu-section {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-color);
}

.menu-section:last-child {
  border-bottom: none;
}

.section-title {
  margin: 0 0 8px 0;
  font-size: 0.75em;
  color: var(--text-color);
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.icon-grid.small-icons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.icon-btn.small-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
}

.icon-btn.small-icon:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.command-icon {
  background: linear-gradient(135deg, var(--button-bg), var(--button-hover));
  color: white;
}

.command-icon:hover {
  background: linear-gradient(135deg, var(--button-hover), #0369a1);
}

.view-icon {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
  background-color: #10b981;
  color: white;
}

.view-icon:hover {
  background: linear-gradient(135deg, var(--accent-blue-hover), #1d4ed8);
}

.quick-actions .section-title {
  margin-bottom: 8px;
}

.quick-action-buttons {
  display: flex;
  gap: 8px;
}

.quick-action-btn {
  flex: 1;
  height: 28px;
  font-size: 0.8em;
  gap: 5px;
  padding: 0 8px;
}

.send-all-btn {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-hover));
  color: white;
}

.send-all-btn:hover {
  background: linear-gradient(135deg, var(--accent-purple-hover), #6d28d9);
  transform: translateY(-1px);
}

.refresh-btn {
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-hover));
  color: white;
}

.refresh-btn:hover {
  background: linear-gradient(135deg, var(--accent-orange-hover), #c2410c);
  transform: translateY(-1px);
}

.icon-btn.small-icon::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7em;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1001;
}

.icon-btn.small-icon:hover::after {
  opacity: 1;
  visibility: visible;
  bottom: 110%;
}

@media (max-width: 1200px) {
  #devicesTable {
    display: block;
    overflow-x: auto;
  }

  #devicesTable th,
  #devicesTable td {
    min-width: 120px;
  }

  .side-menu {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw;
    max-width: 300px;
    max-height: 80vh;
    overflow-y: auto;
  }

  .side-menu.active {
    transform: translate(-50%, -50%) !important;
  }
}

@media (max-width: 768px) {
  .icon-grid.small-icons {
    grid-template-columns: repeat(3, 1fr);
  }

  #devicesTable th,
  #devicesTable td {
    min-width: 100px;
    padding: 5px 6px;
    font-size: 0.88em;
  }

  .date-cell {
    font-size: 0.85em;
  }

  .top-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .page-title {
    order: -1;
    flex-basis: 100%;
  }
}



.no-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--pre-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  border: 2px solid var(--border-color);
}


.file-path {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8em;
}


.read-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.read-status.read    { background: #e8f5e9; color: #2e7d32; }
.read-status.unread  { background: #fff3e0; color: #ef6c00; }

.permission-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.permission-status.granted { background: #e8f5e9; color: #2e7d32; }
.permission-status.denied  { background: #ffebee; color: #c62828; }

.permission-name {
  font-size: 1.0em;
  font-weight: bold;
}

.permission-summary {
  background: var(--pre-bg);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9em;
}

.muted {
  color: var(--text-color);
  opacity: 0.6;
  font-style: italic;
}

.granted-count { color: var(--message-color); font-weight: bold; }
.total-count   { color: var(--text-color); opacity: 0.8; }
.last-updated  { color: var(--text-color); opacity: 0.7; }

.device-id,.last-modified {
  background: var(--pre-bg);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 1.3em;
  margin-left: auto;
  font-weight: bold;
}

.last-updated, .total-count {
  background: var(--pre-bg);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 1.3em;
  margin-left: auto;
  font-weight: bold;

}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}


.args-pre {
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.9em;
  max-height: 60px;
  overflow-y: auto;
}


.error-message {
  padding: 20px;
  background: var(--error-color, #ffebee);
  color: #c62828;
  border-radius: 8px;
  margin: 20px 0;
  border: 1px solid #ffcdd2;
}



.details-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #333;
  margin-bottom: 10px;
}

.details-left {
  justify-self: start;
}

.details-center {
  justify-self: center;
}

.details-center h2 {
  margin: 0;
  font-size: 1.4rem;
}

.details-right {
  justify-self: end;
}

#stopAutoRefreshBtn {
  padding: 6px 10px;
  font-size: 0.9rem;
  cursor: pointer;
}
