/* ============================================================
   PiKVM Engineering Portal — Design adaptiert vom RTL-Stil
   ============================================================ */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --topbar-height: 56px;
    --primary: #0d6efd;
    --body-bg: #f0f2f5;
    --card-bg: #ffffff;
    --sidebar-bg: #1a1d2e;
    --sidebar-text: #b0b7c3;
    --sidebar-active-bg: rgba(13,110,253,.2);
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    margin: 0;
    font-size: .875rem;
    color: #1a1d2e;
}

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 1000; transition: width .25s ease; overflow: hidden;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: 64px;
}
.brand-icon {
    width: 36px; height: 36px; background: var(--primary);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1rem; flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: 1rem; }
.brand-sub  { color: var(--sidebar-text); font-size: .7rem; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section-label {
    color: rgba(176,183,195,.5); font-size: .65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em; padding: 10px 8px 2px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    color: var(--sidebar-text); border-radius: 8px; text-decoration: none;
    font-weight: 500; transition: background .15s, color .15s;
    white-space: nowrap; overflow: hidden;
}
.nav-item i { width: 18px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--primary); }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    color: #fff; font-weight: 700; display: flex; align-items: center;
    justify-content: center; font-size: .9rem; flex-shrink: 0;
}
.user-name { color: #fff; font-weight: 600; font-size: .85rem; }
.user-role { color: var(--sidebar-text); font-size: .7rem; }

/* ---- MAIN WRAPPER ---- */
.main-wrapper {
    margin-left: var(--sidebar-width); min-height: 100vh;
    display: flex; flex-direction: column; transition: margin-left .25s ease;
}
.topbar {
    position: sticky; top: 0; height: var(--topbar-height);
    background: #fff; border-bottom: 1px solid #e9ecef;
    display: flex; align-items: center; padding: 0 20px; gap: 12px;
    z-index: 900; box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar-title { font-weight: 700; font-size: 1rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.sidebar-toggle {
    padding: 4px 8px; border: none; background: transparent;
    cursor: pointer; color: #1a1d2e;
}
.page-content { padding: 24px; flex: 1; }

/* ---- SIDEBAR COLLAPSED ---- */
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-info > div,
.sidebar.collapsed .sidebar-footer .btn { display: none; }
.sidebar.collapsed .user-info { justify-content: center; }
.main-wrapper.collapsed { margin-left: var(--sidebar-collapsed); }

/* ---- STAT CARDS ---- */
.stat-card {
    background: #fff; border-radius: 12px; padding: 18px;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid #e9ecef; box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { color: #6c757d; font-size: .8rem; margin-top: 2px; }
.bg-primary-soft { background: rgba(13,110,253,.1); }
.bg-success-soft { background: rgba(25,135,84,.1); }
.bg-danger-soft  { background: rgba(220,53,69,.1); }
.bg-warning-soft { background: rgba(255,193,7,.1); }
.text-primary { color: #0d6efd; }
.text-success { color: #198754; }
.text-danger  { color: #dc3545; }
.text-warning { color: #ffc107; }

/* ---- PiKVM CARDS (analog RTL bench-card) ---- */
.pi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}
.pi-card {
    background: #fff; border: 1px solid #e9ecef; border-radius: 12px;
    overflow: hidden; transition: transform .15s, box-shadow .15s;
    display: flex; flex-direction: column;
}
.pi-card.online  { border-top: 3px solid #198754; cursor: pointer; }
.pi-card.offline { border-top: 3px solid #6c757d; opacity: .85; }
.pi-card.online:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.09); }
.pi-card-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 14px 16px 8px;
}
.pi-card-title { display: flex; align-items: center; gap: .5rem; }
.pi-dot { width: .65rem; height: .65rem; border-radius: 50%; background: #6c757d; flex: none; }
.pi-card.online  .pi-dot { background: #198754; box-shadow: 0 0 6px #198754; }
.pi-card.offline .pi-dot { background: #dc3545; }
.pi-name { font-weight: 700; font-size: .98rem; }
.pi-card-body { padding: 0 16px 12px; flex: 1; }
.pi-ip-block {
    background: #f8f9fa; border: 1px solid #eef0f3; border-radius: 6px;
    padding: 8px 10px; margin-bottom: 8px; display: grid; gap: 4px;
}
.pi-ip-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.pi-ip-row i { width: 14px; text-align: center; color: #6c757d; flex: none; }
.pi-ip-label { color: #6c757d; min-width: 72px; }
.pi-ip-val { font-family: monospace; color: #0d6efd; font-weight: 600; }
.pi-ip-na { color: #adb5bd; font-weight: 400; }

/* WLAN-Zeile: SSID + Signal-Bars + Meta (dBm/Mbps) */
.pi-wifi-row .pi-ip-val {
    display: inline-flex; align-items: center; gap: 6px;
    flex-wrap: wrap; font-family: inherit;
}
.pi-wifi-ssid {
    font-family: system-ui, sans-serif; color: #212529;
    font-weight: 600; max-width: 14ch; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.pi-wifi-meta {
    font-family: monospace; font-size: .72rem; color: #6c757d; font-weight: 400;
}
.pi-wifi-ip {
    font-family: monospace; font-size: .76rem; color: #0d6efd; font-weight: 600;
}
.pi-wifi-bars {
    display: inline-flex; align-items: flex-end; gap: 1px; height: 12px;
}
.pi-wifi-bars span {
    width: 3px; background: #d6d9dd; border-radius: 1px; display: block;
}
.pi-wifi-bars span:nth-child(1) { height: 25%; }
.pi-wifi-bars span:nth-child(2) { height: 50%; }
.pi-wifi-bars span:nth-child(3) { height: 75%; }
.pi-wifi-bars span:nth-child(4) { height: 100%; }
.pi-wifi-bars.bars-1 span:nth-child(-n+1) { background: #dc3545; }
.pi-wifi-bars.bars-2 span:nth-child(-n+2) { background: #fd7e14; }
.pi-wifi-bars.bars-3 span:nth-child(-n+3) { background: #ffc107; }
.pi-wifi-bars.bars-4 span               { background: #198754; }

.pi-notes { font-size: .78rem; color: #6c757d; font-style: italic; margin-bottom: 8px; }
.pi-detail-box {
    background: #f8f9fa; border-radius: 6px; padding: 10px 12px;
    display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .8rem;
}
.pi-detail-box dt { color: #6c757d; }
.pi-detail-box dd { margin: 0; color: #212529; word-break: break-word; }
.pi-warn {
    font-size: .78rem; color: #997404; background: #fff3cd;
    border: 1px solid #ffe69c; border-radius: 6px; padding: .4rem .6rem; margin-top: 8px;
}
.pi-offline-msg {
    font-size: .8rem; color: #842029; background: #f8d7da;
    border: 1px solid #f1aeb5; border-radius: 6px; padding: .5rem .7rem;
}
.pi-card-footer {
    padding: 12px 16px; border-top: 1px solid #f0f2f5; background: #fafafa;
}
.pi-footer-row { display: flex; gap: 8px; align-items: stretch; }
.pi-connect-btn {
    flex: 1; display: block; text-align: center; text-decoration: none;
    background: var(--primary); color: #fff; font-weight: 600;
    padding: .55rem; border-radius: 8px; border: 0; cursor: pointer; font-size: .9rem;
}
.pi-connect-btn:hover { background: #0b5ed7; }
.pi-card.offline .pi-connect-btn {
    background: #e9ecef; color: #6c757d; cursor: default;
}
.pi-sw-btn {
    flex: 0 0 auto; background: #fff; color: #495057;
    border: 1px solid #dee2e6; border-radius: 8px; cursor: pointer;
    padding: .55rem .8rem; font-size: .85rem; font-weight: 500;
}
.pi-sw-btn:hover { background: #f1f3f5; color: #0d6efd; border-color: #0d6efd; }
.pi-sw-btn i { margin-right: 4px; }

/* ---- Installer-Modal ---- */
.installer-card {
    border: 1px solid #dee2e6; border-radius: 8px; padding: 12px 14px;
    margin-bottom: 10px; background: #fff;
}
.installer-card-head {
    display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
}
.installer-card-desc {
    color: #495057; font-size: .85rem; margin: 0 0 8px;
}
.installer-card-foot {
    display: flex; align-items: center; gap: 8px;
}
.install-log {
    background: #0a0d12; color: #c0c6d0; font-family: monospace; font-size: .75rem;
    padding: .75rem; border-radius: 6px; margin: 0;
    max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}

.badge {
    font-size: .7rem; font-weight: 700; letter-spacing: .04em;
    padding: .25rem .55rem; border-radius: 20px;
}
.badge.online  { background: #d1f0e0; color: #198754; }
.badge.offline { background: #f8d7da; color: #dc3545; }

/* ---- LOGIN PAGE (analog RTL) ---- */
.login-page {
    background: linear-gradient(135deg, #0d1117 0%, #1a2035 50%, #0d1117 100%);
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 20px;
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
    background: #fff; border-radius: 16px; padding: 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon {
    width: 64px; height: 64px; background: var(--primary);
    border-radius: 16px; display: inline-flex; align-items: center;
    justify-content: center; font-size: 1.8rem; color: #fff;
    margin-bottom: 12px; box-shadow: 0 8px 24px rgba(13,110,253,.4);
}
.login-logo h2 { font-weight: 800; color: #1a1d2e; margin: .2rem 0 0; }
.login-logo p { color: #6c757d; font-size: .85rem; margin: .3rem 0 0; }
.login-card label { font-weight: 600; font-size: .82rem; color: #495057; display: block; margin: .8rem 0 .25rem; }
.login-card input {
    width: 100%; padding: .6rem .75rem; border: 1px solid #ced4da;
    border-radius: 8px; font-size: .95rem;
}
.login-card input:focus { outline: 2px solid rgba(13,110,253,.35); border-color: #0d6efd; }
.login-card button {
    width: 100%; margin-top: 1.2rem; padding: .65rem;
    background: var(--primary); color: #fff; border: 0; border-radius: 8px;
    font-weight: 700; font-size: .95rem; cursor: pointer;
}
.login-card button:hover { background: #0b5ed7; }
.login-err {
    margin-top: .9rem; color: #842029; background: #f8d7da;
    border: 1px solid #f1aeb5; border-radius: 8px; padding: .5rem .7rem;
    font-size: .85rem;
}

.btn-xs { padding: .15rem .45rem; font-size: .75rem; border-radius: 6px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; }
    .page-content { padding: 16px; }
    .stat-value { font-size: 1.3rem; }
}
