/* Dark Theme Variables */
:root {
    --bam-bg-dark: #1e1e2d;
    --bam-bg-card: #2b2b40;
    --bam-text-primary: #ffffff;
    --bam-text-secondary: #a2a3b7;
    --bam-border-color: #3b3b4f;

    /* Status Colors */
    --bam-status-normal: #1bc54e;
    --bam-status-warning: #ffa800;
    --bam-status-critical: #f64e60;
    --bam-status-muted: #6c757d;
}

/* Global Overrides */
.bam-app {
    background-color: var(--bam-bg-dark);
    color: var(--bam-text-primary);
    font-family: 'Poppins', 'Inter', sans-serif;
    min-height: 100vh;
    padding: 20px;
}

/* Card Styling */
.bam-card {
    background-color: var(--bam-bg-card);
    border-radius: 12px;
    box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
    border: 1px solid var(--bam-border-color);
}

.bam-card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--bam-border-color);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bam-services-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.bam-card-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bam-services-title-wrap {
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.bam-services-title {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--bam-text-primary);
    letter-spacing: 0.01em;
}

.bam-view-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem;
    border-radius: 999px;
    border: 1px solid var(--bam-border-color);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.bam-view-switch-option {
    border: 0;
    background: transparent;
    color: var(--bam-text-secondary);
    padding: 0.65rem 1.2rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    min-height: 2.5rem;
}

.bam-view-switch-option:hover {
    color: var(--bam-text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.bam-view-switch-option.is-active {
    color: var(--bam-text-primary);
    background: rgba(27, 197, 95, 0.14);
}

.bam-view-switch-count {
    min-width: 1.55rem;
    height: 1.55rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.08);
    color: var(--bam-text-primary);
}

.bam-view-switch-option.is-active .bam-view-switch-count {
    background: rgba(255, 255, 255, 0.16);
}

.bam-card-body {
    padding: 24px;
}

.bam-detail-title {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.5rem;
}

ui-bam-favorite-button {
    display: inline-flex;
    line-height: 0;
}

.bam-kpi-tile-favoritable > ui-bam-favorite-button {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 1;
}

.bam-detail-title > ui-bam-favorite-button {
    flex: 0 0 auto;
}

/* KPI Tiles */
.bam-kpi-tile {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background-color: #323248;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    border: 1px solid transparent;
}

.bam-kpi-tile-favoritable {
    position: relative;
    padding-top: 3rem;
}

.bam-kpi-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-color: var(--bam-status-normal);
}

.bam-kpi-tile.active {
    border-color: var(--bam-status-normal);
    background-color: rgba(27, 197, 189, 0.1);
}

.bam-kpi-tile.is-favorite {
    box-shadow: inset 0 0 0 1px rgba(255, 208, 72, 0.18);
}

.bam-kpi-tile.is-reorderable {
    cursor: grab;
}

.bam-kpi-tile.is-reorderable:active {
    cursor: grabbing;
}

.bam-favorite-dragging .bam-kpi-tile {
    opacity: 0.45;
    transform: none;
}

.bam-favorite-drop-before .bam-kpi-tile,
.bam-favorite-drop-after .bam-kpi-tile {
    border-color: rgba(27, 197, 95, 0.85);
}

.bam-favorite-drop-before .bam-kpi-tile {
    box-shadow: inset 4px 0 0 var(--bam-status-normal);
}

.bam-favorite-drop-after .bam-kpi-tile {
    box-shadow: inset -4px 0 0 var(--bam-status-normal);
}

.bam-favorite-drag-handle {
    position: absolute;
    top: 0.85rem;
    left: 0.85rem;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 1;
    cursor: grab;
}

.bam-favorite-drag-handle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--bam-text-primary);
    transform: scale(1.05);
}

.bam-favorite-drag-handle:active {
    cursor: grabbing;
}

.bam-favorite-button {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 1;
}

.bam-favorite-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

.bam-favorite-button.is-active {
    color: #ffd24a;
    background: rgba(255, 210, 74, 0.12);
}

.bam-favorite-button i {
    pointer-events: none;
}

.bam-favorite-button-inline {
    width: 2.25rem;
    height: 2.25rem;
}

.bam-kpi-name {
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    margin-bottom: 10px;
    color: var(--bam-text-primary);
}

.bam-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bg-success {
    background-color: rgba(27, 197, 95, 0.2) !important;
    color: var(--bam-status-normal) !important;
}

.bg-warning {
    background-color: rgba(255, 168, 0, 0.2) !important;
    color: var(--bam-status-warning) !important;
}

.bg-danger {
    background-color: rgba(246, 78, 96, 0.2) !important;
    color: var(--bam-status-critical) !important;
}

.bg-muted {
    background-color: rgba(108, 117, 125, 0.2) !important;
    color: var(--bam-status-muted) !important;
}

/* Buttons */
.btn-bam {
    background-color: #3699ff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-bam:hover {
    background-color: #2b7bc0;
}

.btn-icon {
    background: transparent;
    color: var(--bam-text-secondary);
    border: 1px solid var(--bam-border-color);
}

.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--bam-text-primary);
}

@media (max-width: 768px) {
    .bam-view-switch {
        width: 100%;
    }

    .bam-view-switch-option {
        flex: 1 1 0;
        justify-content: center;
    }
}

/* Toolbar */
.bam-toolbar {
    background-color: var(--bam-bg-card);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--bam-border-color);
}

input.form-control,
.input-group-addon {
    background: transparent;
    border: none;
    color: var(--bam-text-secondary);
}

/* Charts & Gauges */
.ui-gauge {
    margin: 0 auto;
}

/* Loading Bar */
.query-progress-bar {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    background-color: var(--bam-status-normal);
}

/* Helpers */
.text-muted {
    color: var(--bam-text-secondary) !important;
}

.w-100 {
    width: 100%;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

/* ── Page Header ─────────────────────────────────────────────── */

.bam-top-header {
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    background:
        radial-gradient(circle at top left, rgba(54, 153, 255, 0.22), transparent 30%),
        radial-gradient(circle at 85% 20%, rgba(27, 197, 78, 0.14), transparent 26%),
        linear-gradient(135deg, rgba(52, 52, 79, 0.98), rgba(35, 35, 53, 0.98));
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.bam-top-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.02), transparent 35%, rgba(255, 255, 255, 0.03));
    pointer-events: none;
}

.bam-top-header-shell {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.75rem;
    padding: 1.35rem 1.6rem;
}

.bam-top-header-brand {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    min-width: 0;
}

.bam-top-header-logo-wrap {
    flex: 0 0 auto;
    width: 92px;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 30px rgba(10, 18, 38, 0.28);
}

.bam-top-header-logo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.bam-top-header-logo img {
    height: 40px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.18));
}

.bam-top-header-copy {
    min-width: 0;
}

.bam-top-header-kicker {
    display: inline-flex;
    margin-bottom: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.62);
}

.bam-top-header-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.bam-top-header-title {
    margin: 0;
    font-size: 1.8rem;
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--bam-text-primary);
}

.bam-top-header-badge {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.32rem 0.8rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7fddff;
    background: rgba(54, 153, 255, 0.15);
    border: 1px solid rgba(54, 153, 255, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.bam-top-header-subtitle {
    max-width: 42rem;
    margin: 0.65rem 0 0;
    font-size: 0.96rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.72);
}

.bam-top-header-user {
    flex: 0 0 auto;
    min-width: 220px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.9rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.bam-top-header-user-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 0;
}

.bam-top-header-user-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.bam-top-header-username {
    display: block;
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.98rem;
    color: var(--bam-text-primary);
    font-weight: 600;
}

.bam-top-header-avatar-wrap {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    padding: 4px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(54, 153, 255, 0.35), rgba(255, 255, 255, 0.08));
}

.bam-top-header-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(26, 26, 40, 0.75);
    object-fit: cover;
    display: block;
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 991px) {
    .bam-top-header-shell {
        align-items: flex-start;
        flex-direction: column;
    }

    .bam-top-header-user {
        width: 100%;
        justify-content: space-between;
    }

    .bam-top-header-user-copy {
        align-items: flex-start;
    }
}

@media (max-width: 576px) {
    .bam-top-header-shell {
        padding: 1.1rem;
    }

    .bam-top-header-brand {
        align-items: flex-start;
        flex-direction: column;
        gap: 1rem;
    }

    .bam-top-header-logo-wrap {
        width: 78px;
        height: 78px;
        border-radius: 20px;
    }

    .bam-top-header-title {
        font-size: 1.45rem;
    }

    .bam-top-header-subtitle {
        font-size: 0.9rem;
    }

    .bam-top-header-user {
        min-width: 0;
        padding: 0.85rem 0.9rem;
    }

    .bam-top-header-username {
        max-width: 12rem;
    }
}

/* ============================================================
   Services Status Page
   ============================================================ */

.svc-app {
    font-family: inherit;
    font-size: 1rem;
}

.svc-card-body {
    padding: 0;
}

/* ── Category grid ──────────────────────────────────────────── */

.svc-categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    gap: 0 24px;
}

.svc-col-left  { grid-column: 1; }
.svc-col-right { grid-column: 2; }

@media (max-width: 991px) {
    .svc-categories-grid {
        grid-template-columns: 1fr;
    }
    .svc-col-left,
    .svc-col-right {
        grid-column: 1;
    }
}

.svc-page-header {
    padding: 16px 0 20px;
}

.svc-app .bam-card-title {
    font-size: 1.0rem;
    font-weight: 600;
}

/* ── Header actions ──────────────────────────────────────────── */

.svc-header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.svc-last-updated {
    font-size: 0.9rem;
    color: var(--bam-text-secondary);
    white-space: nowrap;
}

.svc-refresh-btn {
    background: rgba(54, 153, 255, 0.15);
    color: #3699ff;
    border: 1px solid rgba(54, 153, 255, 0.35);
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.svc-refresh-btn:hover:not(:disabled) {
    background: rgba(54, 153, 255, 0.25);
    box-shadow: 0 2px 8px rgba(54, 153, 255, 0.2);
}

.svc-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.svc-refresh-icon {
    display: inline-block;
    margin-right: 5px;
}

.svc-refresh-icon.svc-spin {
    animation: svc-spin 1s linear infinite;
}

@keyframes svc-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Loading / error ─────────────────────────────────────────── */

.svc-loading-body {
    padding: 32px;
    color: var(--bam-text-secondary);
    text-align: center;
    font-size: 1rem;
}

.svc-error-text {
    color: var(--bam-status-critical);
    padding: 14px 18px;
    font-size: 0.95rem;
}

/* ── Services table ──────────────────────────────────────────── */

.svc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.svc-table-inner {
    border-top: none;
    margin-top: 0;
}

.svc-item-row:not(:last-child) td {
    border-bottom: 1px solid var(--bam-border-color);
}

.svc-item-row td {
    padding: 11px 14px;
    vertical-align: middle;
}

/* ── Left accent bar per row status ──────────────────────────── */

.svc-item-row td:first-child {
    border-left: 3px solid transparent;
    padding-left: 12px;
}

.svc-item-row.svc-row-up td:first-child       { border-left-color: var(--bam-status-normal); }
.svc-item-row.svc-row-degraded td:first-child  { border-left-color: var(--bam-status-warning); }
.svc-item-row.svc-row-down td:first-child      { border-left-color: var(--bam-status-critical); }
.svc-item-row.svc-row-manual td:first-child    { border-left-color: #0dcaf0; }
.svc-item-row.svc-row-unknown td:first-child   { border-left-color: var(--bam-status-muted); }

/* ── Column sizing ───────────────────────────────────────────── */

.svc-item-name {
    font-weight: 500;
    color: var(--bam-text-primary);
    width: 35%;
}

.svc-item-status {
    width: 20%;
}

.svc-item-latency {
    width: 12%;
    text-align: right;
}

.svc-item-detail {
    width: 33%;
    color: var(--bam-text-secondary);
    font-size: 0.87rem;
    word-break: break-word;
}

.svc-latency {
    color: var(--bam-text-secondary);
    font-size: 0.87rem;
}

.svc-notes {
    font-style: italic;
}

.svc-error-inline {
    color: var(--bam-status-critical);
}

/* ── Status badges ───────────────────────────────────────────── */

.svc-status-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 12px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.svc-status-up {
    background: rgba(27, 197, 78, 0.15);
    color: var(--bam-status-normal);
    border-color: rgba(27, 197, 78, 0.35);
}

.svc-status-degraded {
    background: rgba(255, 168, 0, 0.15);
    color: var(--bam-status-warning);
    border-color: rgba(255, 168, 0, 0.35);
}

.svc-status-down {
    background: rgba(246, 78, 96, 0.15);
    color: var(--bam-status-critical);
    border-color: rgba(246, 78, 96, 0.35);
}

.svc-status-unknown {
    background: rgba(108, 117, 125, 0.15);
    color: var(--bam-status-muted);
    border-color: rgba(108, 117, 125, 0.3);
}

.svc-status-manual {
    background: rgba(13, 202, 240, 0.12);
    color: #0dcaf0;
    border-color: rgba(13, 202, 240, 0.3);
}

/* ── Category summary badge ──────────────────────────────────── */

.svc-category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    margin-left: 10px;
    border: 1px solid transparent;
}

.svc-badge-up {
    background: rgba(27, 197, 78, 0.15);
    color: var(--bam-status-normal);
    border-color: rgba(27, 197, 78, 0.35);
}

.svc-badge-degraded {
    background: rgba(255, 168, 0, 0.15);
    color: var(--bam-status-warning);
    border-color: rgba(255, 168, 0, 0.35);
}

.svc-badge-down {
    background: rgba(246, 78, 96, 0.15);
    color: var(--bam-status-critical);
    border-color: rgba(246, 78, 96, 0.35);
}

.svc-badge-neutral {
    background: rgba(108, 117, 125, 0.15);
    color: var(--bam-status-muted);
    border-color: rgba(108, 117, 125, 0.3);
}

/* ── Flink sub-jobs section ──────────────────────────────────── */

.svc-flink-jobs {
    border-top: 1px dashed var(--bam-border-color);
    background: rgba(0, 0, 0, 0.18);
    padding: 4px 0 8px;
}

.svc-flink-jobs-header {
    padding: 7px 14px 4px;
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--bam-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

/* ── Responsive tweaks ───────────────────────────────────────── */

@media (max-width: 576px) {
    .svc-item-latency { display: none; }
    .svc-item-name    { width: 40%; }
    .svc-item-status  { width: 30%; }
    .svc-item-detail  { width: 30%; }
}

.h-full {
    height: 100%;
}

/* Responsive Grid */
.bam-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

/* Drill Down Details */
.drilldown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.drilldown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.drilldown-item .item-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
    /* Take all available space */
    min-width: 0;
    /* Enable truncation in flex child */
}

.drilldown-item .item-name {
    font-weight: 500;
    color: var(--bam-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.drilldown-item .item-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    /* Prevent shrinking */
    margin-left: 1rem;
}

.drilldown-status-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}