/* Klon layoutu Unet Web Service (Element UI) */

:root {
  --sidebar-bg: #304156;
  --sidebar-hover: #263445;
  --sidebar-active: #1f2d3d;
  --sidebar-text: #bfcbd9;
  --sidebar-active-text: #409eff;
  --navbar-bg: #fff;
  --navbar-border: #e6e6e6;
  --text: #303133;
  --muted: #909399;
  --border: #dcdfe6;
  --primary: #409eff;
  --success: #67c23a;
  --danger: #f56c6c;
  --tab-bg: #f5f7fa;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar (210px jak Unet) --- */
.sidebar-container {
  width: 210px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.sidebar-logo {
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
}

.sidebar-logo strong { color: #fff; font-weight: 700; }

.sidebar-menu { padding: 8px 0; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: background .2s;
}

.menu-item:hover { background: var(--sidebar-hover); color: #fff; }
.menu-item.is-active {
  background: var(--sidebar-active);
  color: #409eff;
  border-left: 3px solid #409eff;
  padding-left: 17px;
}

.menu-icon, .top-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* --- Main --- */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.navbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--navbar-border);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
}

.company-name { margin-right: 8px; }

.top-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #606266;
  cursor: pointer;
  text-decoration: none;
}

.top-icon-btn:hover { color: var(--primary); }

/* Device header meta */
.btn-back {
  display: inline-flex;
  align-items: center;
  padding: 7px 15px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  color: #606266;
  text-decoration: none;
  cursor: pointer;
}

.btn-back:hover { color: var(--primary); border-color: #c6e2ff; background: #ecf5ff; }

.meta-item { color: var(--muted); }
.meta-item strong { color: var(--text); font-weight: 500; margin-left: 4px; }

.badge-online {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 3px;
  background: #f0f9eb;
  color: var(--success);
  border: 1px solid #e1f3d8;
}

.badge-offline {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 3px;
  background: #fef0f0;
  color: var(--danger);
  border: 1px solid #fde2e2;
}

/* --- Tabs (el-tabs border-card) --- */
.device-tabs {
  background: var(--tab-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}

.device-tabs nav {
  display: flex;
  gap: 0;
  overflow-x: auto;
}

.tab-link {
  display: inline-block;
  padding: 12px 20px;
  font-size: 14px;
  color: #606266;
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab-link:hover { color: var(--primary); }

.tab-link.is-active {
  background: #fff;
  color: var(--primary);
  border-color: var(--border);
  border-bottom-color: #fff;
  border-radius: 4px 4px 0 0;
}

/* --- Content --- */
.app-main {
  flex: 1;
  padding: 15px;
  overflow: auto;
}

.app-container { padding: 5px; }

/* --- Overview layout --- */
.overview-alert {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid #f5dab1;
  background: #fdf6ec;
  color: #e6a23c;
  border-radius: 3px;
  font-size: 13px;
}

.overview-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

.device-photo {
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.device-image {
  width: 100%;
  max-width: 280px;
  height: auto;
  object-fit: contain;
}

.device-photo-inner {
  width: 70%;
  height: 75%;
  background: #fff;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  position: relative;
}

.device-photo-inner::before {
  content: "";
  position: absolute;
  top: 8px; right: 8px;
  width: 6px; height: 40px;
  background: #111;
  border-radius: 2px;
}

.overview-right { min-width: 0; }

.overview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.el-button {
  display: inline-block;
  padding: 9px 15px;
  font-size: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: #fff;
  color: #606266;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}

.el-button:hover {
  color: var(--primary);
  border-color: #c6e2ff;
  background: #ecf5ff;
}

.el-button--primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.el-button--primary:hover {
  background: #66b1ff;
  border-color: #66b1ff;
  color: #fff;
}

.el-button--danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.el-button--danger:hover {
  background: #f78989;
  border-color: #f78989;
  color: #fff;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px 32px;
}

.info-block .info-row {
  display: flex;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.info-label {
  width: 130px;
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 700;
}

.info-value { color: var(--text); word-break: break-all; }

/* --- Tables (Device list) --- */
.el-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.el-table th {
  background: #fafafa;
  color: #909399;
  font-weight: 500;
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #ebeef5;
}

.el-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #ebeef5;
}

.el-table tr:hover td { background: #f5f7fa; }

.el-table a { color: var(--primary); text-decoration: none; }
.el-table a:hover { text-decoration: underline; }

/* --- Login --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2d3a4b;
}

.login-box {
  width: 400px;
  background: #fff;
  border-radius: 4px;
  padding: 35px 35px 25px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.login-box h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 500;
  text-align: center;
}

.login-box .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-box label {
  display: block;
  font-size: 14px;
  margin-bottom: 16px;
  font-weight: 700;
}

.login-box input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 14px;
}

.login-box .el-button--primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-size: 14px;
}

.login-box .el-button--primary:hover {
  background: #66b1ff;
  border-color: #66b1ff;
}

.login-logo {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
}

.alert-error {
  background: #fef0f0;
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 3px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid #fde2e2;
}

/* --- Stub pages --- */
.page-title {
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 16px;
}

.stub-note {
  color: var(--muted);
  font-size: 14px;
  padding: 40px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: #fafafa;
}

@media (max-width: 1100px) {
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .overview-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar-container { width: 54px; }
  .sidebar-logo span, .menu-item span { display: none; }
  .menu-item { justify-content: center; padding: 0; }
  .overview-grid { grid-template-columns: 1fr; }
}

/* --- Gateway Configuration --- */
.gateway-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.gateway-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #303133;
  margin: 0 0 12px;
}

.gateway-table { margin-bottom: 16px; }

.gateway-empty {
  color: #909399;
  text-align: center;
  padding: 24px 16px;
  font-size: 13px;
}

.gateway-foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #ebeef5;
}

.el-button--text {
  border: none;
  background: transparent;
  color: var(--primary);
  padding: 4px 8px;
}

.el-button--text:hover {
  color: #66b1ff;
  background: transparent;
}

.status-finished { color: #67c23a; font-size: 13px; }
.status-waiting { color: #e6a23c; font-size: 13px; }
.status-failed { color: #f56c6c; font-size: 13px; }
.status-none { color: #c0c4cc; font-size: 13px; }

.ota-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.ota-form label { font-size: 13px; font-weight: 500; }
.ota-form select {
  display: block;
  margin-top: 6px;
  min-width: 320px;
  padding: 8px 10px;
  border: 1px solid #dcdfe6;
  border-radius: 3px;
}

/* --- Proxy Mode / Mirror banner --- */
.mirror-banner {
  background: #fdf6ec;
  color: #e6a23c;
  border-bottom: 1px solid #faecd8;
  padding: 8px 16px;
  font-size: 13px;
}

.mirror-banner code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 2px;
}

.mirror-banner a { color: #cf9236; font-weight: 600; }

.menu-item-proxy.menu-item-mirror-active {
  background: #422006 !important;
  color: #fbbf24 !important;
}

.mode-card {
  border: 1px solid #ebeef5;
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 16px;
}

.mode-card-ergo { border-left: 4px solid #409eff; }
.mode-card-mirror { border-left: 4px solid #e6a23c; background: #fffdf8; }

.mode-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.mode-label { margin: 0; font-size: 12px; color: #909399; text-transform: uppercase; letter-spacing: 0.04em; }
.mode-card h2 { margin: 4px 0 0; font-size: 20px; font-weight: 500; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.mode-panel {
  border: 1px solid #ebeef5;
  border-radius: 4px;
  padding: 16px;
  background: #fafafa;
}

.mode-panel h4 { margin: 0 0 10px; font-size: 14px; }
.mode-panel ul { margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: #606266; }
.mode-panel li { margin-bottom: 4px; }

.mode-switch-btn { min-width: 200px; padding: 10px 16px !important; }

.el-button--warning {
  color: #fff;
  background: #e6a23c;
  border-color: #e6a23c;
}

.el-button--warning:hover {
  background: #ebb563;
  border-color: #ebb563;
  color: #fff;
}

.mode-info {
  font-size: 13px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #f5f7fa;
  border-radius: 4px;
}

.mode-info code {
  background: #fff;
  padding: 2px 6px;
  border: 1px solid #e4e7ed;
  border-radius: 2px;
}

.log-preview {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 12px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 768px) {
  .mode-grid { grid-template-columns: 1fr; }
}

/* --- Device list (Unet) --- */
.device-list-page {
  padding: 0;
  margin: -4px 0 0;
}

.device-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 16px;
  flex-wrap: nowrap;
}

.toolbar-left {
  flex-shrink: 0;
}

.btn-add-device {
  padding: 9px 18px !important;
  font-size: 13px !important;
  border-radius: 3px !important;
}

.device-list-search {
  display: flex;
  align-items: stretch;
  margin-left: auto;
  flex-shrink: 0;
}

.fuzzy-input {
  width: 240px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #dcdfe6;
  border-right: none;
  border-radius: 3px 0 0 3px;
  font-size: 13px;
  outline: none;
  background: #fff;
  color: #606266;
}

.fuzzy-input::placeholder {
  color: #c0c4cc;
}

.fuzzy-input:focus {
  border-color: #409eff;
}

.fuzzy-search-btn {
  width: 38px;
  height: 34px;
  border: 1px solid #dcdfe6;
  border-left: none;
  border-radius: 0 3px 3px 0;
  background: #fff;
  color: #606266;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.fuzzy-search-btn:hover {
  color: #409eff;
  border-color: #c6e2ff;
  background: #ecf5ff;
}

.add-device-panel {
  margin-bottom: 10px;
  padding: 14px 16px;
  background: #f5f7fa;
  border: 1px solid #e4e7ed;
  border-radius: 3px;
}

.add-device-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.add-device-form label {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
  color: #606266;
}

.add-device-form input {
  display: block;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid #dcdfe6;
  border-radius: 3px;
  min-width: 200px;
  font-size: 13px;
}

.device-table-wrap {
  border: 1px solid #dfe6ec;
  background: #fff;
  overflow-x: auto;
}

table.device-list-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 13px;
}

table.device-list-table thead th {
  background: linear-gradient(180deg, #5dade2 0%, #4a9fd0 100%);
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  padding: 11px 12px;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  white-space: nowrap;
  text-align: left;
}

table.device-list-table thead th:last-child {
  border-right: none;
}

table.device-list-table tbody td {
  font-size: 13px;
  color: #606266;
  padding: 11px 12px;
  vertical-align: middle;
  border-bottom: 1px solid #ebeef5;
  background: #fff;
}

table.device-list-table tbody tr:hover td {
  background: #f5f7fa;
}

table.device-list-table .col-sn {
  font-family: "Consolas", "Monaco", monospace;
  font-size: 12px;
  color: #303133;
}

table.device-list-table .col-imei,
table.device-list-table .col-ccid {
  font-family: "Consolas", "Monaco", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
}

table.device-list-table .col-ccid {
  min-width: 220px;
  word-break: break-all;
}

table.device-list-table .col-status {
  text-align: center;
  width: 100px;
}

table.device-list-table .col-op {
  width: 130px;
}

.op-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}

.op-link {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  appearance: none;
  -webkit-appearance: none;
}

.op-enter {
  color: #409eff;
}

.op-enter:hover {
  color: #66b1ff;
  text-decoration: underline;
}

.op-delete-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

.op-delete {
  color: #f56c6c;
}

.op-delete:hover {
  color: #f78989;
  text-decoration: underline;
}

.status-pill {
  display: inline-block;
  min-width: 64px;
  padding: 5px 12px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  color: #fff !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.status-pill-online {
  background: #67c23a !important;
  border: 1px solid #5daf34;
}

.status-pill-offline {
  background: #909399 !important;
  border: 1px solid #82848a;
}

.device-empty {
  text-align: center;
  color: #909399;
  padding: 36px 16px !important;
  font-size: 13px;
}

/* Device list: mniejszy padding main */
.app-main:has(.device-list-page) {
  padding-top: 12px;
}

/* --- Real time Data --- */
.realtime-layout { margin-top: 4px; }

.realtime-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ebeef5;
}

.realtime-auto-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #606266;
  cursor: pointer;
  user-select: none;
}

.realtime-ts {
  margin-left: auto;
  font-size: 12px;
  color: #909399;
}

.realtime-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  min-height: 360px;
}

.realtime-sidebar {
  border: 1px solid #ebeef5;
  border-radius: 4px;
  background: #fafafa;
  overflow: hidden;
}

.realtime-sidebar-title {
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #303133;
  background: #f5f7fa;
  border-bottom: 1px solid #ebeef5;
}

.realtime-dev-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 480px;
  overflow-y: auto;
}

.realtime-dev-list li { margin: 0; }

.realtime-dev-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  border-left: 3px solid transparent;
}

.realtime-dev-btn:hover { background: #ecf5ff; }

.realtime-dev-btn.is-active {
  background: #ecf5ff;
  border-left-color: var(--primary);
}

.realtime-dev-name {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

.realtime-dev-addr {
  font-family: ui-monospace, "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
  font-size: 12px;
  color: #606266;
  margin-top: 3px;
  letter-spacing: 0.05em;
}

.realtime-empty {
  padding: 16px 12px;
  font-size: 13px;
  color: #909399;
}

.realtime-main {
  border: 1px solid #ebeef5;
  border-radius: 4px;
  padding: 12px 16px 16px;
  min-width: 0;
}

.realtime-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.realtime-header h3 {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: 0.03em;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

.realtime-table td { font-size: 13px; }

.realtime-value {
  font-family: "Consolas", "Monaco", monospace;
  color: #303133;
}

@media (max-width: 900px) {
  .realtime-body { grid-template-columns: 1fr; }
  .realtime-ts { margin-left: 0; width: 100%; }
}
