﻿/* ============================================================
   AXRIVO CONNECT - DEVICE DETAILS
   Scoped Device Dashboard styling
   ============================================================ */

.ax-device-details {
    width: 100%;
}


/* ============================================================
   HEADER
   ============================================================ */

.ax-device-header {
    margin-bottom: 24px;
}

.ax-device-header-main {
    min-width: 0;
}

.ax-device-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ax-device-title-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
    background: var(--ax-primary-soft, rgba(59, 130, 246, 0.10));
    color: var(--ax-primary, #2563eb);
}

.ax-device-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
    margin-left: 60px;
}

.ax-device-code,
.ax-device-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.ax-device-code {
    color: var(--ax-text-secondary, #64748b);
}

.ax-device-status {
    font-weight: 600;
}

.ax-device-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}


/* ============================================================
   SECTIONS
   ============================================================ */

.ax-device-section {
    margin-bottom: 24px;
}

.ax-device-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.ax-device-section-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.ax-device-section-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: var(--ax-text-secondary, #64748b);
}

.ax-device-live-indicator,
.ax-device-no-data-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.ax-device-live-indicator {
    background: rgba(34, 197, 94, 0.10);
    color: #15803d;
}

.ax-device-live-indicator > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}

.ax-device-no-data-indicator {
    background: rgba(100, 116, 139, 0.10);
    color: #64748b;
}


/* ============================================================
   LIVE STAT CARDS
   ============================================================ */

.ax-device-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.ax-device-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--ax-border, #e2e8f0);
    border-radius: 12px;
    background: var(--ax-surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ax-device-stat-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--ax-primary-soft, rgba(59, 130, 246, 0.10));
    color: var(--ax-primary, #2563eb);
    font-size: 18px;
}

.ax-device-stat-content {
    min-width: 0;
}

.ax-device-stat-label {
    font-size: 12px;
    color: var(--ax-text-secondary, #64748b);
    margin-bottom: 5px;
}

.ax-device-stat-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ax-device-stat-value-small {
    font-size: 16px;
}

.ax-device-stat-description {
    margin-top: 5px;
    font-size: 11px;
    color: var(--ax-text-secondary, #94a3b8);
}


/* ============================================================
   DEVICE INFORMATION
   ============================================================ */

.ax-device-widget {
    overflow: hidden;
}

.ax-device-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px 24px;
}

.ax-device-info-item {
    min-width: 0;
}

.ax-device-info-wide {
    grid-column: span 2;
}

.ax-device-topic {
    overflow-wrap: anywhere;
    word-break: break-word;
}


/* ============================================================
   ANALYTICS
   ============================================================ */

.ax-device-analytics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.ax-device-analytics-card {
    position: relative;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--ax-border, #e2e8f0);
    border-radius: 12px;
    background: var(--ax-surface, #ffffff);
}

.ax-device-analytics-label {
    font-size: 12px;
    color: var(--ax-text-secondary, #64748b);
}

.ax-device-analytics-value {
    margin-top: 7px;
    font-size: 25px;
    font-weight: 700;
}

.ax-device-analytics-percent {
    margin-top: 5px;
    font-size: 12px;
    color: var(--ax-text-secondary, #64748b);
}

.ax-device-analytics-icon {
    position: absolute;
    right: 18px;
    top: 18px;
    font-size: 19px;
    color: var(--ax-primary, #2563eb);
}

.ax-device-analytics-panels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.ax-device-progress-row + .ax-device-progress-row {
    margin-top: 20px;
}

.ax-device-progress-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
    font-size: 12px;
}

.ax-device-progress-header span {
    color: var(--ax-text-secondary, #64748b);
}

.ax-device-progress-header strong {
    font-weight: 600;
}

.ax-device-progress {
    width: 100%;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.ax-device-progress-bar {
    height: 100%;
    min-width: 0;
    border-radius: inherit;
    background: var(--ax-primary, #2563eb);
    transition: width 0.25s ease;
}

.ax-device-progress-muted {
    background: #94a3b8;
}

.ax-device-analytics-period {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
    padding: 16px 18px;
    border: 1px solid var(--ax-border, #e2e8f0);
    border-radius: 12px;
    background: var(--ax-surface-subtle, #f8fafc);
}

.ax-device-analytics-period > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}


/* ============================================================
   PAYLOAD
   ============================================================ */

.ax-device-payload {
    border: 1px solid var(--ax-border, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
}

.ax-device-payload summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    font-weight: 600;
    background: var(--ax-surface-subtle, #f8fafc);
}

.ax-device-payload summary::-webkit-details-marker {
    display: none;
}

.ax-device-payload summary span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ax-device-payload[open] summary > .bi-chevron-down {
    transform: rotate(180deg);
}

.ax-device-payload pre {
    margin: 0;
    padding: 16px;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.55;
    background: #0f172a;
    color: #e2e8f0;
}


/* ============================================================
   HISTORY
   ============================================================ */

.ax-device-history-count {
    font-size: 12px;
    color: var(--ax-text-secondary, #64748b);
}

.ax-device-history-wrapper {
    width: 100%;
    overflow-x: auto;
}

.ax-device-history-table {
    min-width: 1000px;
}

.ax-device-history-date {
    white-space: nowrap;
}

.ax-device-history-status {
    font-weight: 600;
}

.ax-device-history-payload {
    min-width: 110px;
}

.ax-device-history-payload details summary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.ax-device-history-payload pre {
    width: 420px;
    max-width: 70vw;
    max-height: 260px;
    margin: 8px 0 0;
    padding: 12px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11px;
    line-height: 1.5;
}

.ax-device-pagination-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--ax-border, #e2e8f0);
    font-size: 12px;
    color: var(--ax-text-secondary, #64748b);
}


/* ============================================================
   FOOTER
   ============================================================ */

.ax-device-footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 4px 2px 20px;
    font-size: 11px;
    color: var(--ax-text-secondary, #94a3b8);
}

.ax-device-footer span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {

    .ax-device-stat-grid,
    .ax-device-analytics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ax-device-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ax-device-analytics-panels {
        grid-template-columns: 1fr;
    }

    .ax-device-analytics-period {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 768px) {

    .ax-device-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .ax-device-header-actions {
        width: 100%;
    }

    .ax-device-header-actions .ax-btn {
        width: 100%;
        justify-content: center;
    }

    .ax-device-meta {
        margin-left: 0;
    }

    .ax-device-stat-grid,
    .ax-device-analytics-grid,
    .ax-device-info-grid,
    .ax-device-analytics-period {
        grid-template-columns: 1fr;
    }

    .ax-device-info-wide {
        grid-column: auto;
    }

    .ax-device-section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .ax-device-stat-card {
        padding: 16px;
    }
}
/* ============================================================
   DEVICE HISTORY GRID - WIDTH FIX
   ============================================================ */

.ax-device-history-wrapper {
    width: 100%;
    overflow-x: auto;
}

.ax-device-history-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

/* Date / Time */
.ax-device-history-table th:nth-child(1),
.ax-device-history-table td:nth-child(1) {
    width: 16%;
}

/* Device Status */
.ax-device-history-table th:nth-child(2),
.ax-device-history-table td:nth-child(2) {
    width: 11%;
}

/* Device IP */
.ax-device-history-table th:nth-child(3),
.ax-device-history-table td:nth-child(3) {
    width: 13%;
}

/* PLC Status */
.ax-device-history-table th:nth-child(4),
.ax-device-history-table td:nth-child(4) {
    width: 11%;
}

/* PLC IP */
.ax-device-history-table th:nth-child(5),
.ax-device-history-table td:nth-child(5) {
    width: 13%;
}

/* Quality */
.ax-device-history-table th:nth-child(6),
.ax-device-history-table td:nth-child(6) {
    width: 21%;
}

/* Payload */
.ax-device-history-table th:nth-child(7),
.ax-device-history-table td:nth-child(7) {
    width: 15%;
}

.ax-device-history-table th,
.ax-device-history-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ax-device-history-payload {
    min-width: 0;
    width: 100%;
}

.ax-device-history-payload details {
    max-width: 100%;
}

.ax-device-history-payload details summary {
    white-space: nowrap;
}

.ax-device-history-payload pre {
    width: min(420px, 70vw);
    max-width: 100%;
    box-sizing: border-box;
}


/* ============================================================
   SMALL SCREENS
   Keep horizontal scrolling when the screen is genuinely narrow.
   ============================================================ */

@media (max-width: 900px) {

    .ax-device-history-table {
        min-width: 950px;
        table-layout: auto;
    }

    .ax-device-history-table th:nth-child(1),
    .ax-device-history-table td:nth-child(1),
    .ax-device-history-table th:nth-child(2),
    .ax-device-history-table td:nth-child(2),
    .ax-device-history-table th:nth-child(3),
    .ax-device-history-table td:nth-child(3),
    .ax-device-history-table th:nth-child(4),
    .ax-device-history-table td:nth-child(4),
    .ax-device-history-table th:nth-child(5),
    .ax-device-history-table td:nth-child(5),
    .ax-device-history-table th:nth-child(6),
    .ax-device-history-table td:nth-child(6),
    .ax-device-history-table th:nth-child(7),
    .ax-device-history-table td:nth-child(7) {
        width: auto;
    }
}
