/* ============================================================
   RESET & BASE STYLES
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f4f6f8;
  color: #1f2937;
  line-height: 1.5;
  font-size: 14px;
}

/* ================= Tidsintervall-knappar ================= */

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

tr.offline td {
  opacity: 0.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  padding: 12px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.stat-title {
  font-size: 11px;
  opacity: 0.65;
  margin-bottom: 4px;
  letter-spacing: .2px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-sub {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-sub span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 4px;
  font-weight: 500;
  font-size: 11px;
}



.range-btn.live {
  position: relative;
  padding-left: 18px;
}

.range-btn.live::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  width: 6px;
  height: 6px;
  background: #2ecc71;
  border-radius: 50%;
  transform: translateY(-50%);
}

.range-btn.live.active::before {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%   { transform: translateY(-50%) scale(1);   opacity: 1; }
  50%  { transform: translateY(-50%) scale(1.6); opacity: .4; }
  100% { transform: translateY(-50%) scale(1);   opacity: 1; }
}


.card-title {
  font-size: 14px;
  opacity: 0.8;
}

.range-selector {
  display: flex;
  gap: 6px;
}

.range-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  text-decoration: none;
  color: #555;
  background: #f1f3f5;
  border: 1px solid #e0e0e0;
  transition: all 0.15s ease;
}

.range-btn:hover {
  background: #e8eaed;
}

.range-btn.active {
  background: #3498db;
  color: #fff;
  border-color: #3498db;
  font-weight: 600;
}


.health-cell span {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 4px;
  font-size: 11px;
  border-radius: 4px;
  font-weight: 600;
  color: #fff;
}

.status-online {
  background: #2ecc71; /* grön */
}

.status-warn {
  background: #f39c12; /* orange */
}

.status-offline {
  background: #e74c3c; /* röd */
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* Header / menu */
header {
  background: #1f2937;
  color: #fff;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
}

nav .brand {
  font-weight: 600;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 24px;
  line-height: 1;
}

.brand-text {
  line-height: 1;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 16px;
}

nav a {
  color: #e5e7eb;
  text-decoration: none;
  font-weight: 500;
}

nav a:hover {
  color: #fff;
  text-decoration: underline;
}

/* Cards */
.card {
  background: #fff;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Compact card variant */
.card.compact { padding: 12px; }
.card.compact h2 { margin-bottom: 12px; font-size: 18px; }
.card.compact .form-group { margin-bottom: 10px; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 12px;
}

tr:hover {
  background: #f3f4f6;
}

/* Status */
.status-online {
  color: #059669;
  font-weight: 600;
}

.status-offline {
  color: #dc2626;
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.status-online {
  background: #d1fae5;
  color: #047857;
}

.status-badge.status-offline {
  background: #fee2e2;
  color: #991b1b;
}

/* Buttons */
button {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #1f2937;
  font-size: 13px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: #1f2937;
  transition: all 0.2s ease;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  padding-right: 32px;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Form groups */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  margin-bottom: 8px;
}

/* Error & Success messages */
.error {
  background: #fee;
  color: #dc2626;
  padding: 10px 12px;
  border-radius: 5px;
  margin-bottom: 16px;
  border-left: 4px solid #dc2626;
  font-weight: 500;
}

.success {
  background: #efe;
  color: #059669;
  padding: 10px 12px;
  border-radius: 5px;
  margin-bottom: 16px;
  border-left: 4px solid #10b981;
  font-weight: 500;
}

.success code {
  background: rgba(255,255,255,0.7);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

/* Buttons */
button {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-block;
}

button:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Link as button */
a.btn {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  padding: 10px 18px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

a.btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

a.btn.secondary {
  background: #6b7280;
}

a.btn.secondary:hover {
  background: #4b5563;
}

/* Danger button */
button.btn-danger,
a.btn-danger {
  background: #dc2626;
}

button.btn-danger:hover,
a.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* Device actions */
.device-actions {
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Admin actions */
.admin-actions {
  margin-bottom: 30px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Table filters */
.table-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 14px;
}

.filter-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 14px;
  background-color: #fff;
  cursor: pointer;
}

/* Sortable table headers */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

th.sortable:hover {
  background: #e5e7eb;
}

th.sortable.sorted {
  background: #dbeafe;
  color: #1e40af;
}

.sort-icon {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.5;
}

th.sortable.sorted .sort-icon {
  opacity: 1;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  margin-top: 60px;
  padding: 30px 20px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

/* ============================================================
   HEADINGS
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  margin-bottom: 16px;
  color: #1f2937;
  font-weight: 600;
}

h1 {
  font-size: 26px;
  margin-bottom: 16px;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

/* Links */
a {
  color: #2563eb;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
p {
  margin-bottom: 12px;
}

code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #1f2937;
}

code.agent-key {
  font-size: 14px;
}

/* Dashboard styles */
.dashboard-timezone {
  color: #6b7280;
  margin-bottom: 12px;
}

/* ================= LOGIN ================= */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
  padding: 20px;
}

.login-form {
  width: 100%;
  max-width: 400px;
  margin: 16px auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease-out;
}

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

.login-form h1 {
  text-align: center;
  margin: 0;
  font-size: 28px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.login-logo-icon {
  font-size: 56px;
  line-height: 1;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.login-logo h1 {
  margin: 0;
  font-size: 28px;
  color: #1f2937;
}

.login-subtitle {
  text-align: center;
  color: #6b7280;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
}

.login-form fieldset {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}

.form-group input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-form button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.login-form button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.login-form button:active {
  transform: translateY(0);
}

.login-meta {
  margin-top: 16px;
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  line-height: 1.6;
}

.login-meta p {
  margin: 0;
}

.login-meta a {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.login-meta a:hover {
  color: #2563eb;
  text-decoration: underline;
}

.login-info-box {
  border-left: 4px solid #3b82f6;
  background: #f0f9ff !important;
}

.login-info-box h2 {
  color: #1e40af;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.login-info-box ul li {
  margin-bottom: 6px;
}

/* Settings layout */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

/* Small buttons */
.btn-small, button.btn-small, a.btn-small {
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 3px;
  white-space: nowrap;
  margin-right: 4px;
  margin-bottom: 4px;
}

/* ============================================================
   TIME SELECTOR / RANGE BUTTONS
   ============================================================ */
.time-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.time-selector a {
  padding: 8px 14px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  color: #555;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
  font-weight: 500;
}

.time-selector a:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.time-selector a.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

/* ============================================================
   DEVICE INFO
   ============================================================ */
.device-info {
  background: #fff;
}

.device-specs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.spec {
  display: flex;
  flex-direction: column;
}

/* Allow certain specs to span wider across the grid */
.spec.wide {
  grid-column: span 2;
}

/* Group two specs on a dedicated full-width row */
.spec-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 20px;
}

.spec-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.spec-value {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

/* ============================================================
   Table actions layout
   ============================================================ */
.table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.table-actions .btn-small {
  padding: 4px 8px;
  font-size: 11px;
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */
@media (max-width: 768px) {
  nav ul {
    gap: 12px;
  }
  
  nav a {
    font-size: 13px;
  }

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

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 24px;
  }

  table {
    font-size: 13px;
  }

  th, td {
    padding: 8px;
  }

  .device-specs {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .table-actions {
    gap: 6px;
    flex-wrap: wrap;
    white-space: normal;
  }

  .spec-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .time-selector {
    gap: 6px;
  }

  .time-selector a {
    padding: 6px 12px;
    font-size: 12px;
  }

  button {
    padding: 8px 14px;
    font-size: 13px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .container {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  nav {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  nav ul {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 20px;
  }

  button {
    width: 100%;
  }

  /* Mobile: hide Återförsäljare, OS, Windows Updates columns */
  #devicesTable th:nth-child(3),
  #devicesTable td:nth-child(3),
  #devicesTable th:nth-child(5),
  #devicesTable td:nth-child(5),
  #devicesTable th:nth-child(6),
  #devicesTable td:nth-child(6) {
    display: none;
  }

  /* Make device table prettier on mobile - card layout */
  #devicesTable {
    border: none;
  }

  #devicesTable thead {
    display: none; /* Hide table header on mobile */
  }

  #devicesTable tbody tr {
    display: block;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
  }

  #devicesTable tbody tr:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
  }

  #devicesTable td {
    display: block;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
  }

  /* Hostname - larger and bold */
  #devicesTable td:first-child {
    padding: 16px 16px 8px 16px;
    font-size: 16px;
    font-weight: 600;
    max-width: none !important;
  }

  #devicesTable td:first-child a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1f2937;
    text-decoration: none;
  }

  #devicesTable td:first-child a:hover {
    color: #3b82f6;
  }

  /* Add labels before each info field on mobile */
  #devicesTable td:nth-child(2)::before {
    content: "Kund: ";
    font-weight: 600;
    color: #6b7280;
  }

  #devicesTable td:nth-child(4)::before {
    content: "Version: ";
    font-weight: 600;
    color: #6b7280;
  }

  #devicesTable td:nth-child(7)::before {
    content: "Status: ";
    font-weight: 600;
    color: #6b7280;
  }

  #devicesTable td:nth-child(8)::before {
    content: "Senast sedd: ";
    font-weight: 600;
    color: #6b7280;
  }

  /* Last item (Senast sedd) - add bottom padding */
  #devicesTable td:nth-child(8) {
    padding-bottom: 16px;
  }

  /* Make table more mobile-friendly */
  th, td {
    padding: 8px 6px;
    font-size: 11px;
  }

  table {
    font-size: 11px;
  }

  .table-filters {
    flex-direction: column;
  }

  .filter-input,
  .filter-select {
    width: 100%;
  }

  .table-actions {
    flex-direction: column;
    gap: 4px;
  }

  .table-actions .btn-small {
    width: 100%;
    text-align: center;
  }

  .device-specs {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .spec.wide {
    grid-column: 1;
  }

  .spec-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .time-selector {
    flex-wrap: wrap;
    gap: 6px;
  }

  .time-selector a {
    flex: 1;
    min-width: 80px;
    text-align: center;
    padding: 6px 8px;
    font-size: 12px;
  }

  .table-filters {
    gap: 8px;
  }

  .filter-input {
    min-width: unset;
  }
}

/* Tablet (768px - 1024px) - optimize for better readability */
@media (min-width: 768px) and (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 10px 8px;
  }

  h1 {
    font-size: 24px;
  }

  .device-specs {
    grid-template-columns: repeat(2, 1fr);
  }

  .spec-row {
    grid-template-columns: repeat(2, 1fr);
  }
}