/* Transport Bot Web Panel — styles on top of PicoCSS */

/* ===== Layout ===== */
.layout {
    display: flex;
    gap: 1.5rem;
    min-height: calc(100vh - 4rem);
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    padding-top: 1rem;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin-bottom: 2px;
}

.sidebar a {
    display: block;
    padding: 0.6rem 0.85rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--pico-color);
    font-size: 0.925rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar a:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--pico-primary);
}

[data-theme="dark"] .sidebar a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pico-primary);
}

.sidebar a.active {
    background: var(--pico-primary);
    color: #fff;
    font-weight: 600;
}

.sidebar a.active:hover {
    background: var(--pico-primary);
    color: #fff;
}

.sidebar-divider {
    border-top: 1px solid var(--pico-muted-border-color);
    margin: 0.6rem 0;
    list-style: none;
}

.content {
    flex: 1;
    min-width: 0;
    padding-top: 1rem;
    padding-bottom: 2rem;
}

/* ===== Top nav ===== */
.top-nav {
    background: var(--pico-card-background-color);
    border-bottom: 1px solid var(--pico-muted-border-color);
    padding: 0.5rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-nav ul {
    margin: 0;
    align-items: center;
    gap: 0.5rem;
}

.top-nav li {
    margin: 0;
    padding: 0;
}

.nav-brand {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.user-info {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--pico-muted-color);
}

/* ===== Login page ===== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 1rem;
}

.login-card {
    max-width: 400px;
    width: 100%;
}

.login-card header {
    text-align: center;
    padding-bottom: 0;
}

.login-card h2 {
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--pico-muted-color);
    margin-top: 0;
    margin-bottom: 0;
    font-size: 0.95rem;
}

.login-card button[type="submit"] {
    width: 100%;
    margin-top: 0.5rem;
    min-height: 48px;
    font-size: 1rem;
}

.error-msg {
    background: #d32f2f18;
    color: #d32f2f;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 3px solid #d32f2f;
    font-size: 0.9rem;
}

[data-theme="dark"] .error-msg {
    background: #ef535018;
    color: #ef9a9a;
    border-left-color: #ef5350;
}

/* ===== Stats grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    padding: 1.25rem 1rem;
    margin: 0;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.825rem;
    color: var(--pico-muted-color);
    margin: 0.35rem 0 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.online-card .stat-value { color: #2e7d32; }
.offline-card .stat-value { color: #c62828; }

[data-theme="dark"] .online-card .stat-value { color: #66bb6a; }
[data-theme="dark"] .offline-card .stat-value { color: #ef5350; }

/* ===== Status dots ===== */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}

.status-dot.online { background: #4caf50; }
.status-dot.offline { background: #f44336; }

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
}

table {
    width: 100%;
    white-space: nowrap;
}

table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pico-muted-color);
    font-weight: 600;
}

table td, table th {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
}

.truncate {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Actions cell ===== */
.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.actions-cell form {
    margin: 0;
    display: inline-flex;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.725rem;
    font-weight: 600;
    background: var(--pico-secondary-background);
    color: var(--pico-secondary-inverse);
    white-space: nowrap;
}

.badge-login { background: #4caf5022; color: #2e7d32; }
.badge-logout { background: #ff980022; color: #e65100; }
.badge-login_failed { background: #f4433622; color: #c62828; }
.badge-error { background: #f4433622; color: #c62828; }

[data-theme="dark"] .badge-login { background: #4caf5025; color: #81c784; }
[data-theme="dark"] .badge-logout { background: #ff980025; color: #ffb74d; }
[data-theme="dark"] .badge-login_failed { background: #f4433625; color: #ef9a9a; }
[data-theme="dark"] .badge-error { background: #f4433625; color: #ef9a9a; }

/* ===== Buttons ===== */
.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    line-height: 1.4;
    min-height: 32px;
    margin: 0;
}

/* Touch-friendly: all buttons min 44px on touch devices */
@media (pointer: coarse) {
    .btn-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 0.4rem 0.75rem;
        font-size: 0.825rem;
    }

    .sidebar a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .pagination a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .log-row td {
        padding: 0.75rem;
    }
}

/* ===== Page header with button ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.page-header h2 { margin: 0; }

.page-header > button {
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Filters bar ===== */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input {
    margin: 0;
}

.filters-bar select {
    min-width: 180px;
}

.filters-bar input[type="text"] {
    min-width: 200px;
    flex: 1;
    max-width: 320px;
}

/* ===== Logs expandable ===== */
.log-row {
    cursor: pointer;
    transition: background 0.1s;
}

.log-row:hover {
    background: var(--pico-card-background-color);
}

.log-detail.hidden { display: none; }

.log-qa {
    padding: 0.75rem 1rem;
    background: var(--pico-card-background-color);
    border-radius: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.85rem;
    line-height: 1.5;
    border-left: 3px solid var(--pico-primary-background);
}

.log-qa p { margin: 0.3rem 0; }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
    margin: 1.5rem 0;
    font-size: 0.925rem;
}

.pagination a {
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 0.4rem;
    transition: background 0.15s;
}

.pagination a:hover {
    background: var(--pico-secondary-background);
}

.pagination span {
    color: var(--pico-muted-color);
}

/* ===== Fleet header ===== */
.fleet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.fleet-header h3 { margin: 0; }

.refresh-badge {
    color: var(--pico-muted-color);
    font-size: 0.8rem;
}

/* ===== Suggestions dropdown ===== */
.suggestions {
    position: relative;
}

.suggestion {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--pico-muted-border-color);
    font-size: 0.9rem;
    transition: background 0.1s;
}

.suggestion:hover {
    background: var(--pico-primary-background);
    color: var(--pico-primary-inverse);
}

/* ===== Theme toggle ===== */
.theme-toggle {
    padding: 0.25rem 0.5rem;
    margin: 0;
    font-size: 1.2rem;
    line-height: 1;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== Details cell ===== */
.details-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--pico-muted-color);
}

/* ===== Modals ===== */
dialog article {
    max-width: 480px;
    width: 90vw;
    margin: auto;
}

dialog article footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

dialog article footer button {
    min-width: 100px;
    margin: 0;
}

/* ===== Section headings ===== */
.content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}

.content h2 small {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--pico-muted-color);
    margin-left: 0.5rem;
}

.content h3 {
    font-size: 1.1rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--pico-muted-color);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--pico-muted-color);
}

/* ===== Mobile: tablet (<=992px) ===== */
@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Mobile: phone (<=768px) ===== */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        gap: 0;
    }

    .sidebar {
        width: 100%;
        padding: 0.5rem 0 0;
        border-bottom: 1px solid var(--pico-muted-border-color);
    }

    .sidebar ul {
        display: flex;
        gap: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 0.5rem 0.5rem;
        scrollbar-width: none;
    }

    .sidebar ul::-webkit-scrollbar {
        display: none;
    }

    .sidebar li {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .sidebar a {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        border-radius: 2rem;
    }

    .sidebar-divider {
        display: none;
    }

    .content {
        padding-top: 0.75rem;
    }

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

    .stat-value {
        font-size: 1.75rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .page-header > button {
        align-self: flex-start;
    }

    .filters-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filters-bar select,
    .filters-bar input[type="text"] {
        min-width: unset;
        max-width: unset;
        width: 100%;
    }

    .truncate {
        max-width: 180px;
    }

    .details-cell {
        max-width: 120px;
    }

    .fleet-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* ===== Mobile: small phone (<=480px) ===== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.85rem 0.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.725rem;
    }

    .top-nav {
        padding: 0.35rem 0.75rem;
    }

    .user-info {
        display: none;
    }

    .truncate {
        max-width: 120px;
    }

    dialog article {
        width: 95vw;
        max-width: none;
    }

    .content h2 {
        font-size: 1.3rem;
    }
}
