/* ================================
   RESET + LAYOUT
   ================================ */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
}

/* ================================
   MAPA
   ================================ */
#map {
    width: 100%;
    height: calc(100vh - 45px);
    /* odejmujemy pasek */
}

/* ================================
   GÓRNY PASEK
   ================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #222;
    color: #fff;
    padding: 5px 15px;
    box-sizing: border-box;
    height: 40px;
}

/* PODZIAŁ: LEWA / ŚRODEK / PRAWA */
.topbar-left,
.topbar-right {
    display: flex;
    gap: 8px;
}

/* NAGŁÓWEK ŚRODKOWY */
.topbar .title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
}

/* PRZYCISKI */
.topbar button {
    padding: 4px 10px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* WYLOGUJ */
.topbar .logout {
    background: #e74c3c;
    color: #fff;
}

/* ================================
   SYGNALIZATOR DROGOWY
   ================================ */
.signal-box {
    width: 16px;
    height: 45px;
    background: #222;
    border-radius: 6px;
    padding: 2px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
    box-sizing: border-box;
}

.signal-light {
    width: 11px;
    height: 11px;
    margin: 2.5px auto;
    border-radius: 50%;
    background: #444;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.6);
}

.signal-light.red.on {
    background: #e74c3c;
}

.signal-light.yellow.on {
    background: #f1c40f;
}

.signal-light.green.on {
    background: #2ecc71;
}

.signal-box.offline .signal-light {
    background: #666;
}

/* ================================
   POPUP – INPUTY
   ================================ */
.popup {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.popup input {
    width: 120px;
    /* mniejsze żeby zmieściło się w popup */
    padding: 4px 6px;
    box-sizing: border-box;
    font-size: 14px;
}

/* INPUTY W RZĘDZIE DWA */
.popup .row {
    display: flex;
    gap: 5px;
}

/* PRZYCISK DODAJ / RESET */
.popup button {
    padding: 6px 12px;
    font-size: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.popup .reset-btn {
    background: #e74c3c;
    color: #fff;
}

.popup .login-btn {
    background: #27ae60;
    color: #fff;
}

/* ================================
   POPUP LEAFLET
   ================================ */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    font-size: 14px;
    line-height: 1.4;
    margin: 10px 8px;
}

/* ================================
   HISTORIA (podstrona – tabela)
   ================================ */
.history-page {
    background: #f0f2f5;
}

.history-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px 32px;
    box-sizing: border-box;
}

.history-desc {
    margin: 0 0 16px;
    color: #555;
    font-size: 14px;
}

.history-loading,
.history-empty {
    color: #666;
    text-align: center;
    padding: 40px 16px;
    font-size: 15px;
}

.history-table-wrap {
    background: #fff;
    border: 1px solid #dde1e6;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}

.history-table thead {
    background: #2c3e50;
    color: #fff;
}

.history-table th {
    padding: 12px 14px;
    font-weight: 600;
    white-space: nowrap;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.history-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #eef0f3;
    vertical-align: middle;
    color: #222;
}

.history-table tbody tr:hover {
    background: #f8fafb;
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.history-table .col-name {
    font-weight: 600;
    min-width: 140px;
}

.history-table .col-id code {
    background: #f0f3f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #2c3e50;
}

.history-table .col-ts {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: #444;
}

.history-table .col-lights {
    white-space: nowrap;
}

.history-table .col-temp {
    font-weight: 600;
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.online {
    background: #d5f5e3;
    color: #1e8449;
}

.badge.offline {
    background: #f2f2f2;
    color: #7f8c8d;
}

.light-dot {
    display: inline-block;
    width: 22px;
    text-align: center;
    font-size: 16px;
    line-height: 1;
    color: #bbb;
}

.light-dot.red.on   { color: #e74c3c; }
.light-dot.yellow.on { color: #f1c40f; }
.light-dot.green.on  { color: #2ecc71; }

@media (max-width: 768px) {
    .history-wrap {
        padding: 12px 8px 24px;
    }

    .history-table th,
    .history-table td {
        padding: 9px 10px;
        font-size: 13px;
    }
}