/*
 * IX Endpoint Services -- dashboard shell + component styles.
 * Loaded on index.html and device.html, alongside ix-theme.css.
 */

/* ============ App shell: sidebar + main ============ */

.ix-shell {
    display: flex;
    min-height: 100vh;
}

.ix-sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--ix-surface);
    border-right: 1px solid var(--ix-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.ix-sidebar .ix-wordmark {
    padding: 0 0.4rem 1.5rem 0.4rem;
    border-bottom: 1px solid var(--ix-border);
    margin-bottom: 1rem;
}

.ix-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex-grow: 1;
}

.ix-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--ix-radius-sm);
    color: var(--ix-text-muted);
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    border-left: 2px solid transparent;
}

.ix-sidebar-link:hover {
    color: var(--ix-text);
    background: rgba(255, 255, 255, 0.03);
}

.ix-sidebar-link.active {
    color: var(--ix-accent);
    background: var(--ix-accent-tint);
    border-left-color: var(--ix-accent);
}

.ix-sidebar-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.85;
}

.ix-sidebar-footer {
    border-top: 1px solid var(--ix-border);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.ix-main {
    flex-grow: 1;
    min-width: 0;
}

.ix-content {
    max-width: 1480px;
    padding: 1.5rem 2rem 3rem 2rem;
}

/* ============ Top header ============ */

.ix-topheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 2rem;
    border-bottom: 1px solid var(--ix-border);
    background: rgba(7, 12, 7, 0.6);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}

.ix-topheader-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--ix-text);
}

.ix-topheader-crumbs {
    font-size: 0.78rem;
    color: var(--ix-text-faint);
}

.ix-user-chip {
    font-size: 0.83rem;
    color: var(--ix-text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ix-role-pill {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--ix-accent-tint);
    color: var(--ix-accent);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

/* ============ Summary stat cards (home) ============ */

.ix-stat-card {
    background: var(--ix-surface);
    border: 1px solid var(--ix-border);
    border-radius: var(--ix-radius);
    padding: 1.1rem 1.25rem;
}

.ix-stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ix-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ix-stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

/* ============ Tables ============ */

.ix-table {
    width: 100%;
    border-collapse: collapse;
}

.ix-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ix-text-muted);
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--ix-border);
}

.ix-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--ix-border);
    font-size: 0.86rem;
    vertical-align: middle;
}

.ix-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ix-hostname-link {
    color: var(--ix-accent);
    font-weight: 700;
    text-decoration: none;
}
.ix-hostname-link:hover { color: var(--ix-accent-dark); text-decoration: underline; }

/* ============ Device header ============ */

.ix-device-header h4 {
    color: var(--ix-text);
    font-weight: 800;
    letter-spacing: 0.01em;
}

/* ============ Report period control ============ */

.ix-report-period {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ix-period-btn {
    background: var(--ix-surface);
    border: 1px solid var(--ix-border);
    color: var(--ix-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
}

.ix-period-btn:hover {
    border-color: var(--ix-border-strong);
    color: var(--ix-text);
}

.ix-period-btn.active {
    background: var(--ix-accent-tint);
    border-color: var(--ix-accent);
    color: var(--ix-accent);
}

.ix-period-custom {
    display: none;
    align-items: center;
    gap: 0.5rem;
    background: var(--ix-surface);
    border: 1px solid var(--ix-border);
    border-radius: var(--ix-radius-sm);
    padding: 0.4rem 0.6rem;
}

.ix-period-custom.show { display: flex; }

.ix-period-custom input[type="date"] {
    background: var(--ix-surface-raised);
    border: 1px solid var(--ix-border);
    color: var(--ix-text);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.ix-period-label {
    font-size: 0.78rem;
    color: var(--ix-text-faint);
    margin-bottom: 0.75rem;
}

/* ============ Timeline ============ */

.ix-timeline-hours {
    display: flex;
    font-size: 0.68rem;
    color: var(--ix-text-faint);
    margin-bottom: 0.3rem;
}

.ix-timeline-hours span {
    flex: 1 0 0;
    text-align: left;
}

.ix-timeline-track {
    position: relative;
    width: 100%;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--ix-border);
    background: var(--ix-surface-raised);
}

.ix-timeline-seg {
    position: absolute;
    top: 0;
    bottom: 0;
}

.ix-timeline-seg-ACTIVE { background: var(--ix-online); }
.ix-timeline-seg-IDLE { background: var(--ix-idle); }
/* SLEEP_CONFIRMED: genuine sleep/power-state evidence -- currently never
   produced (no agent version sends such a signal yet), styled here for
   when it becomes available. Uses the same striped treatment previously
   used for the old combined SLEEP_GAP type. */
.ix-timeline-seg-SLEEP_CONFIRMED {
    background-color: var(--ix-sleep);
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.18) 0,
        rgba(255, 255, 255, 0.18) 4px,
        transparent 4px,
        transparent 8px
    );
}
/* MONITORING_GAP: heartbeat evidence disappeared, cause unknown, flanked
   by confirmed engagement -- deliberately a DIFFERENT color from
   SLEEP_CONFIRMED so it is never visually mistaken for confirmed sleep. */
.ix-timeline-seg-MONITORING_GAP {
    background-color: var(--ix-text-faint, #6b7280);
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.12) 0,
        rgba(255, 255, 255, 0.12) 4px,
        transparent 4px,
        transparent 8px
    );
}
/* OFF_SESSION: best-available inference of a boundary between two
   engagement periods -- distinct again from both Sleep states, since it
   makes a different (weaker, duration/evidence-based) claim. */
.ix-timeline-seg-OFF_SESSION {
    background-color: var(--ix-text-faint, #6b7280);
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.03) 0,
        rgba(255, 255, 255, 0.03) 5px,
        transparent 5px,
        transparent 10px
    );
}
.ix-timeline-seg-NO_SESSION {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.03) 0,
        rgba(255, 255, 255, 0.03) 5px,
        transparent 5px,
        transparent 10px
    );
    background-color: transparent;
}

.ix-timeline-legend {
    font-size: 0.76rem;
    color: var(--ix-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.6rem;
}

.ix-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 0.35rem;
    vertical-align: -1px;
}

.ix-day-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ix-day-select select {
    background: var(--ix-surface-raised);
    border: 1px solid var(--ix-border);
    color: var(--ix-text);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.ix-timeline-seg-clickable {
    cursor: pointer;
}
.ix-timeline-seg-clickable:hover {
    filter: brightness(1.2);
    outline: 1px solid rgba(255, 255, 255, 0.4);
    outline-offset: -1px;
}

.ix-app-row-clickable {
    cursor: pointer;
}
.ix-app-row-clickable:hover {
    background: var(--ix-surface-raised);
}
.ix-app-drilldown {
    padding: 0.25rem 0 0.75rem 2.5rem;
}
.ix-table-sm th, .ix-table-sm td {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ============ Activity Details ============ */

.ix-tz-indicator {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ix-text-faint);
    letter-spacing: 0.04em;
}

.ix-activity-details {
    max-height: 340px;
    overflow-y: auto;
    border: 1px solid var(--ix-border);
    border-radius: var(--ix-radius-sm);
}

.ix-activity-details .ix-table { font-size: 0.84rem; }

.ix-activity-details .ix-table th {
    position: sticky;
    top: 0;
    background: var(--ix-surface);
    z-index: 1;
}

.ix-activity-details .ix-table td {
    color: var(--ix-text);
    font-variant-numeric: tabular-nums;
}

.ix-activity-details .ix-table td.ix-activity-status-cell {
    color: var(--ix-text-muted);
    font-weight: 600;
    font-variant-numeric: normal;
}

.ix-activity-row {
    transition: background-color 0.3s ease;
}

.ix-activity-row.ix-row-highlight {
    background: var(--ix-accent-tint);
}

@media (max-width: 576px) {
    .ix-activity-row { flex-wrap: wrap; }
    .ix-activity-time { flex: 1 1 100%; }
}

/* ============ Donut / ring chart ============ */

.ix-donut {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.ix-donut::after {
    content: "";
    position: absolute;
    inset: 16px;
    background: var(--ix-surface);
    border-radius: 50%;
}

.ix-donut-label {
    position: absolute;
    inset: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ix-donut-pct {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--ix-text);
}

.ix-donut-caption {
    font-size: 0.62rem;
    color: var(--ix-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ix-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.8rem;
}

.ix-donut-legend .row-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ix-text-muted);
}

.ix-donut-legend .row-value {
    color: var(--ix-text);
    font-weight: 700;
    margin-left: auto;
}

.ix-excluded-note {
    font-size: 0.68rem;
    color: var(--ix-text-faint);
    font-style: italic;
}

/* ============ Application usage ============ */

.ix-app-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--ix-border);
}
.ix-app-row:last-child { border-bottom: none; }

.ix-app-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--ix-accent-tint);
    color: var(--ix-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.ix-app-icon svg { width: 16px; height: 16px; }

.ix-app-name {
    font-weight: 600;
    font-size: 0.87rem;
    color: var(--ix-text);
}

.ix-app-meta {
    font-size: 0.76rem;
    color: var(--ix-text-muted);
}

.ix-app-bar-track {
    background: var(--ix-surface-raised);
    border: 1px solid var(--ix-border);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
}

.ix-app-bar-fill {
    background: var(--ix-accent);
    height: 100%;
}

/* ============ Trend chart ============ */

.ix-trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
    padding-top: 0.5rem;
    overflow-x: auto;
}

.ix-trend-bar {
    flex: 1 0 22px;
    min-width: 22px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    border-radius: 4px 4px 0 0;
    overflow: hidden;
    background: var(--ix-surface-raised);
    border: 1px solid var(--ix-border);
}

.ix-trend-bar-seg { width: 100%; }
.ix-trend-bar-seg.active { background: var(--ix-online); }
.ix-trend-bar-seg.idle { background: var(--ix-idle); }
.ix-trend-bar-seg.sleep { background: var(--ix-sleep); }

.ix-trend-labels {
    display: flex;
    gap: 6px;
    font-size: 0.62rem;
    color: var(--ix-text-faint);
    margin-top: 0.3rem;
}
.ix-trend-labels span { flex: 1 0 22px; min-width: 22px; text-align: center; }

/* ============ MAC Health ============ */

.ix-health-card {
    background: var(--ix-surface);
    border: 1px solid var(--ix-border);
    border-radius: var(--ix-radius);
    padding: 1rem 1.15rem;
    height: 100%;
}

.ix-health-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ix-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.6rem;
}

.ix-health-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.84rem;
    padding: 0.25rem 0;
}

.ix-health-row .label { color: var(--ix-text-muted); }
.ix-health-row .value { font-weight: 600; text-align: right; color: var(--ix-text); }
.ix-health-row .value.na { color: var(--ix-text-faint); font-weight: 500; }

.ix-back-link {
    font-size: 0.85rem;
    color: var(--ix-text-muted);
    text-decoration: none;
}
.ix-back-link:hover { color: var(--ix-accent); }

/* ============ Responsive ============ */

@media (max-width: 1024px) {
    .ix-sidebar { width: 200px; }
    .ix-content { padding: 1.25rem 1.25rem 2.5rem 1.25rem; }
    .ix-topheader { padding: 0.9rem 1.25rem; }
}
