/* =======================================================
   Eltra IoT Hub – Modern UI
   ======================================================= */

/* ---------- Variables ---------- */
:root {
  --c-primary:      #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-nav-bg:       #0f172a;
  --c-nav-border:   rgba(255,255,255,.06);
  --c-bg:           #f1f5f9;
  --c-card:         #ffffff;
  --c-border:       #e2e8f0;
  --c-text:         #1e293b;
  --c-muted:        #64748b;
  --c-success:      #10b981;
  --c-danger:       #ef4444;
  --c-warning:      #f59e0b;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 25px -3px rgba(0,0,0,.12), 0 4px 6px -2px rgba(0,0,0,.06);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  padding-top: 64px;
  padding-bottom: 56px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Navbar ---------- */
.eltra-navbar {
  height: 64px;
  background: var(--c-nav-bg);
  border-bottom: 1px solid var(--c-nav-border);
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.eltra-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff !important;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.3px;
  text-decoration: none !important;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--c-primary) 0%, #7c3aed 100%);
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.brand-name { color: #e2e8f0; }
.brand-name em { color: #60a5fa; font-style: normal; }

.eltra-nav-link {
  color: #94a3b8 !important;
  font-size: .85rem;
  font-weight: 500;
  padding: .4rem .75rem !important;
  border-radius: var(--r-sm);
  transition: color .15s, background .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.eltra-nav-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,.08);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37,99,235,.18);
  color: #93c5fd;
  border: 1px solid rgba(37,99,235,.3);
  font-size: .78rem;
  font-weight: 600;
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.user-pill i { font-size: .7rem; opacity: .8; }

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.7%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* ---------- Main ---------- */
.eltra-main { padding: 1.5rem 0 2rem; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 1.5rem; }
.page-title  { font-size: 1.35rem; font-weight: 700; margin: 0; line-height: 1.2; }
.page-sub    { font-size: .85rem; color: var(--c-muted); margin: .25rem 0 0; }

/* ---------- Breadcrumb ---------- */
.eltra-bc { margin-bottom: 1.25rem; }
.eltra-bc .breadcrumb { background: none; padding: 0; margin: 0; font-size: .78rem; --bs-breadcrumb-divider-color: var(--c-muted); }
.eltra-bc .breadcrumb-item a { color: var(--c-primary); text-decoration: none; }
.eltra-bc .breadcrumb-item.active { color: var(--c-muted); }

/* ---------- Cards ---------- */
.eltra-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.eltra-card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--c-border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.count-badge {
  font-size: .7rem;
  font-weight: 600;
  background: var(--c-bg);
  color: var(--c-muted);
  border: 1px solid var(--c-border);
  padding: 2px 8px;
  border-radius: 12px;
}

/* ---------- Tables ---------- */
.eltra-table { width: 100%; border-collapse: collapse; font-size: .875rem; }

.eltra-table thead th {
  padding: .6rem 1.25rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.eltra-table tbody td {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.eltra-table tbody tr:last-child td { border-bottom: none; }
.eltra-table tbody tr:hover         { background: #f8fafc; }

/* ---------- Status badge ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online  { color: #065f46; background: #d1fae5; }
.status-offline { color: var(--c-muted); background: #f1f5f9; }
.status-unknown { color: #92400e; background: #fef3c7; }

.status-online::before  { background: var(--c-success); animation: blink 2s infinite; }
.status-offline::before { background: #94a3b8; }
.status-unknown::before { background: var(--c-warning); }

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

/* ---------- Channel ID link ---------- */
.ch-id {
  font-family: 'Cascadia Code', 'JetBrains Mono', 'Courier New', monospace;
  font-size: .75rem;
  color: var(--c-primary);
  background: rgba(37,99,235,.06);
  border: 1px solid rgba(37,99,235,.14);
  padding: 3px 8px;
  border-radius: 5px;
  text-decoration: none;
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.ch-id:hover {
  background: rgba(37,99,235,.12);
  color: var(--c-primary-dark);
  text-decoration: none;
}

/* ---------- Device cells ---------- */
.dev-thumb {
  width: 52px;
  height: 52px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dev-thumb img { max-width: 46px; max-height: 46px; object-fit: contain; }

.dev-name { font-weight: 600; color: var(--c-text); text-decoration: none; }
.dev-name:hover { color: var(--c-primary); text-decoration: none; }

.mono-sm {
  font-family: 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: .72rem;
  color: var(--c-muted);
}

/* ---------- Chips ---------- */
.chip {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: .04em;
}

.chip-rw { background: #dbeafe; color: #1d4ed8; }
.chip-ro { background: #f1f5f9; color: #64748b; }
.chip-wo { background: #fef3c7; color: #92400e; }
.chip-ty { background: #f1f5f9; color: #475569; font-family: monospace; font-size: .7rem; }

/* ---------- OBD table ---------- */
.obd-table thead th,
.obd-table tbody td { padding: .45rem .875rem; font-size: .8rem; }
.obd-idx { font-family: monospace; font-size: .75rem; color: var(--c-muted); }

/* ---------- Hero ---------- */
.hero-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.hero-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 3rem 2.5rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.hero-icon {
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, var(--c-primary), #7c3aed);
  border-radius: 20px;
  display: grid;
  place-items: center;
  margin: 0 auto 1.5rem;
  font-size: 34px;
  color: #fff;
  box-shadow: 0 8px 20px rgba(37,99,235,.35);
}

.hero-title { font-size: 1.9rem; font-weight: 800; color: var(--c-text); margin-bottom: .5rem; }
.hero-desc  { font-size: .9rem; color: var(--c-muted); margin-bottom: 2rem; max-width: 340px; margin-left: auto; margin-right: auto; }

.btn-hero {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: .75rem 2rem;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.btn-hero:hover {
  background: var(--c-primary-dark);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(37,99,235,.4);
}

.btn-hero:active { transform: scale(.97); }

.hero-features {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.hero-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  color: var(--c-muted);
}

.hero-feature i { font-size: 1.1rem; color: var(--c-primary); opacity: .7; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 2.5rem;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--c-primary), #7c3aed);
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 1.25rem;
  font-size: 22px;
  color: #fff;
}

.login-title { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: .3rem; }
.login-sub   { font-size: .82rem; color: var(--c-muted); text-align: center; margin-bottom: 1.75rem; }

.field-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--c-text);
  display: block;
  margin-bottom: .35rem;
}

.field-input {
  width: 100%;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: .6rem .875rem;
  font-size: .88rem;
  color: var(--c-text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}

.field-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.field-group { margin-bottom: 1rem; }

.btn-login {
  width: 100%;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: .7rem 1.5rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1.5rem;
}

.btn-login:hover  { background: var(--c-primary-dark); }
.btn-login:active { transform: scale(.98); }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.eltra-toast {
  min-width: 300px;
  max-width: 420px;
  background: #fff;
  border-radius: var(--r-md);
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
  border-left: 4px solid var(--c-primary);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
}

.eltra-toast.t-success { border-left-color: var(--c-success); }
.eltra-toast.t-error   { border-left-color: var(--c-danger); }
.eltra-toast.t-warning { border-left-color: var(--c-warning); }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

.toast-ico { font-size: .95rem; margin-top: 1px; flex-shrink: 0; }
.t-info    .toast-ico { color: var(--c-primary); }
.t-success .toast-ico { color: var(--c-success); }
.t-error   .toast-ico { color: var(--c-danger); }
.t-warning .toast-ico { color: var(--c-warning); }

.toast-body  { flex: 1; min-width: 0; }
.toast-title { font-size: .78rem; font-weight: 700; color: var(--c-text); margin: 0 0 2px; }
.toast-msg   { font-size: .78rem; color: var(--c-muted); margin: 0; }

.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--c-muted); font-size: .75rem; padding: 2px;
  flex-shrink: 0; line-height: 1;
}
.toast-close:hover { color: var(--c-text); }

/* ---------- Error / access denied ---------- */
.error-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
}

.error-code  { font-size: 5rem; font-weight: 900; color: var(--c-border); line-height: 1; margin-bottom: .5rem; }
.error-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem; }
.error-desc  { font-size: .9rem; color: var(--c-muted); margin-bottom: 2rem; max-width: 360px; margin-left: auto; margin-right: auto; }

.btn-outline-primary-sm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
  border-radius: var(--r-sm);
  padding: .55rem 1.5rem;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.btn-outline-primary-sm:hover {
  background: var(--c-primary);
  color: #fff;
  text-decoration: none;
}

/* ---------- Logout / success ---------- */
.success-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: #d1fae5;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 1.25rem;
  font-size: 28px;
  color: var(--c-success);
}

/* ---------- Footer ---------- */
.eltra-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--c-nav-bg);
  border-top: 1px solid var(--c-nav-border);
  padding: 0 1.25rem;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 900;
}

.footer-txt { font-size: .72rem; color: #475569; margin: 0; }
.footer-ver {
  font-size: .68rem;
  color: #334155;
  font-family: monospace;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ---------- Cookie consent ---------- */
#cookieConsent {
  position: fixed;
  bottom: 48px; left: 0; right: 0;
  margin: 0;
  border-radius: 0;
  z-index: 1050;
  font-size: .82rem;
  background: #1e3a5f;
  border: none;
  color: #e2e8f0;
  padding: .7rem 1.25rem;
}

#cookieConsent a { color: #93c5fd; }

/* ---------- Empty state ---------- */
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--c-muted); }
.empty-state i { font-size: 2.5rem; opacity: .25; margin-bottom: .75rem; display: block; }
.empty-state p { font-size: .9rem; margin: 0; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar            { width: 6px; height: 6px; }
::-webkit-scrollbar-track      { background: #f1f5f9; }
::-webkit-scrollbar-thumb      { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: #94a3b8; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .eltra-main           { padding: 1rem 0; }
  .eltra-table thead th,
  .eltra-table tbody td { padding: .625rem .75rem; }
  .hero-card            { padding: 2rem 1.25rem; }
  .login-card           { padding: 2rem 1.25rem; }
}
