/* Control-plane chrome on top of the shared SleepDiary theme (scss/custom-theme.css).
   Colours/typography come from the theme; these mirror the app's admin tables. */

html {
    font-size: 14px; /* base (mobile) root size — matches the main app */
}

/* The app scales the root up on ≥768px so 1rem-based type (inputs, labels, buttons)
   grows on desktop. Without this the control-plane text stayed at 14px and looked
   smaller than the app. Mirrors the app's site.css breakpoint. */
@media (min-width: 768px) {
    html {
        font-size: 20px;
    }
}

body {
    background-color: #f7f7fb;
}

/* Global content-area layout — mirrors the app's site.css so <main> behaves the same
   (auth pages and console alike). */
main {
    display: flex;
    flex-direction: column;
}

/* --- Top bar, modelled on the main app's TopMenuComponent (white bar + logo +
   avatar/name/role dropdown). Self-contained: the dropdown toggles via a tiny inline
   script in the component, since the control plane ships no bootstrap JS. --- */
.cp-topmenu {
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.cp-topmenu-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 68px;
}

.cp-topmenu-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--bs-body-color);
    flex-shrink: 0;
    margin-right: auto; /* push the user card to the right edge */
}

.cp-topmenu-logo {
    height: 34px;
    width: auto;
}

.cp-brand-sub {
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.10);
    padding: 5px 11px;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1;
}

/* User card + dropdown — verstka copied 1:1 from the main app's TopMenuComponent
   (.user-avatar / .avatar-placeholder / .user-info / .user-name-short|full /
   .user-role / .dropdown-arrow), scoped under .cp-topmenu. The dropdown uses
   bootstrap's own .dropdown / .dropdown-menu.show styling (custom-theme.css);
   only the open/close is driven by the component's inline script. */
.cp-topmenu .btn-link {
    color: inherit;
    text-decoration: none;
}

.cp-topmenu .btn-link:hover {
    color: inherit;
}

.cp-topmenu .avatar-placeholder {
    width: 43px;
    height: 43px;
    background-color: var(--bs-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.cp-topmenu .user-info {
    display: none;
    margin-left: 18px;
}

.cp-topmenu .user-name {
    font-weight: 500;
    color: var(--bs-body-color);
}

.cp-topmenu .user-name-short {
    display: none;
}

.cp-topmenu .user-name-full {
    display: none;
}

.cp-topmenu .user-role {
    font-size: 14px;
}

.cp-topmenu .dropdown-arrow {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 6px;
    margin-left: 20px;
    color: var(--bs-secondary-color);
    transition: transform 0.2s;
}

.cp-topmenu [aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.cp-topmenu .dropdown-menu {
    /* Positioning is bootstrap + Popper's job (dropdown-menu-end right-aligns it);
       this only tunes the look, matching the main app's TopMenuComponent. */
    padding: 0;
    font-size: 14px;
    min-width: 190px;
    margin-top: 10px !important;
    overflow: hidden;
}

.cp-topmenu .dropdown-menu .dropdown-item {
    padding: 21px 13px;
}

.cp-topmenu .dropdown-menu li:first-child .dropdown-item {
    border-radius: 10px 10px 0 0;
}

.cp-topmenu .dropdown-menu li:last-child .dropdown-item {
    border-radius: 0 0 10px 10px;
}

.cp-topmenu .dropdown-divider {
    margin: 0;
}

@media (min-width: 768px) {
    .cp-topmenu-inner { min-height: 84px; }
    .cp-topmenu-logo { height: 42px; }

    .cp-topmenu .user-info { display: block; }
    .cp-topmenu .user-name-short { display: block; }
    .cp-topmenu .dropdown-arrow { display: flex; }
    .cp-topmenu .dropdown-menu { font-size: 16px; }
}

@media (min-width: 1024px) {
    .cp-topmenu .user-name-short { display: none; }
    .cp-topmenu .user-name-full { display: block; }
}

.cp-form {
    max-width: 640px;
}

/* --- The card a table (or a form) sits in --- */
.cp-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    padding: 30px;
}

/* --- Key/value detail list (tenant Details). A label column + value, one row per
   fact, with hairline dividers — reads as a sibling of the card tables. --- */
.cp-detail-list {
    margin: 0;
}

.cp-detail-item {
    display: flex;
    align-items: baseline;
    gap: 20px;
    padding: 8px 0;
}

.cp-detail-item:first-child {
    padding-top: 0;
}

.cp-detail-item:last-child {
    padding-bottom: 0;
}

.cp-detail-list dt {
    flex: 0 0 200px;
    margin: 0;
    font-weight: 500;
    color: var(--bs-secondary-color);
}

.cp-detail-list dd {
    margin: 0;
    min-width: 0; /* let long values (build ids, errors) wrap instead of overflowing */
    color: var(--bs-body-color);
    word-break: break-word;
}

.cp-detail-item--danger dt,
.cp-detail-item--danger dd {
    color: var(--bs-danger);
}

/* Narrow screens: stack the label above its value. */
@media (max-width: 575.98px) {
    .cp-detail-item {
        flex-direction: column;
        gap: 4px;
    }

    .cp-detail-list dt {
        flex-basis: auto;
    }
}

/* The table itself lives in Views/Shared/Partials/DataTable/_CpTable.cshtml.css, scoped
   to the component — these rules were its hand-rolled ancestor. */

/* Status pills — soft tint + solid text, like the app's data-table badges. */
.cp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Rides in the in-flight badge to say the wait is work in progress. Sized off the badge's
   own text and drawn in currentColor, so it stays the status's colour without repeating it. */
.cp-badge__spinner {
    width: 11px;
    height: 11px;
    border-width: 2px;
    flex-shrink: 0;
}

.cp-badge--active        { background: #29B2231A; color: #29B223; }
.cp-badge--failed        { background: #F549491A; color: #F54949; }
.cp-badge--pending       { background: #4876C61A; color: #4876C6; }
.cp-badge--inflight      { background: #F5A6231A; color: #C57A00; } /* provisioning/verifying/deprovisioning */
.cp-badge--destroyed     { background: #6c757d1A; color: #6c757d; }

/* ===========================================================================
   Admin dashboard — the super-admin landing. Mirrors the main app's admin
   dashboard (welcome header, quick-action cards, status metrics, health gauge,
   recent-activity table) but in cp- classes so it sits on the shared theme and
   inherits its light/dark tokens.
   =========================================================================== */
.cp-dash {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.cp-dash-welcome {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

/* Quick actions */
.cp-quick-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.cp-action-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
}

.cp-action-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.cp-action-head h3 {
    font-size: 22px;
    font-weight: 500;
    margin: 0;
}

.cp-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cp-action-icon--tenants { background: #69329A1A; color: #69329A; }
.cp-action-icon--owners  { background: #4876C61A; color: #4876C6; }
.cp-action-icon--invite  { background: #29B2231A; color: #29B223; }

.cp-action-desc {
    font-size: 15px;
    color: var(--bs-secondary-color);
    margin: 0 0 20px;
    flex: 1;
}

.cp-action-card hr {
    margin: 0 0 20px;
    border-color: var(--bs-border-color);
    opacity: 1;
}

.cp-action-btn {
    width: 100%;
    text-align: center;
}

/* Metrics row: fleet status tiles + health gauge */
.cp-metrics-row {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.cp-fleet-metrics,
.cp-health-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
}

/* Recent activity's heading is the table component's own now; these are the two cards
   that still title themselves. */
.cp-fleet-metrics h2,
.cp-health-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 24px;
}

/* "View all X" — the way out of a preview to the full list. Mirrors the app's own
   .view-all (notifications dropdown): a quiet primary link, deliberately not a button.
   The preview points at the list; it shouldn't compete with the page's real actions. */
.cp-view-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--bs-primary);
    text-decoration: none;
    white-space: nowrap;
}

.cp-view-all:hover {
    text-decoration: none;
}

.cp-view-all__arrow {
    transition: transform 0.15s;
}

.cp-view-all:hover .cp-view-all__arrow {
    transform: translateX(3px);
}

.cp-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.cp-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 20px;
    border: 1px solid var(--bs-border-color);
    border-radius: 14px;
}

.cp-stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.cp-stat-value--active    { color: #29B223; }
.cp-stat-value--inflight  { color: #C57A00; }
.cp-stat-value--failed    { color: #F54949; }
.cp-stat-value--pending   { color: #4876C6; }
.cp-stat-value--destroyed { color: #6c757d; }

.cp-stat-label {
    font-size: 14px;
    color: var(--bs-secondary-color);
}

/* Health gauge */
.cp-health-card {
    align-items: center;
}

.cp-health-card h2 {
    align-self: flex-start;
}

.cp-gauge-wrapper {
    width: 100%;
    max-width: 420px;
    align-self: center;
}

.cp-gauge {
    width: 100%;
    height: 100%;
}

.cp-gauge-tick { fill: var(--bs-border-color); }

.cp-gauge-bg {
    fill: none;
    stroke: var(--bs-border-color);
    stroke-width: 40;
    stroke-linecap: round;
}

.cp-gauge-fill {
    fill: none;
    stroke: url(#cpGaugeGradient);
    stroke-width: 40;
    stroke-linecap: round;
}

.cp-gauge-text {
    font-size: 90px;
    font-weight: 500;
    fill: var(--bs-primary);
    text-anchor: middle;
    dominant-baseline: central;
}

.cp-gauge-label {
    font-size: 24px;
    fill: var(--bs-secondary-color);
    text-anchor: middle;
}

.cp-health-message {
    font-size: 15px;
    padding: 10px 14px;
    border-radius: 10px;
    margin-top: auto;
    text-align: center;
    width: 100%;
}

.cp-health-message--good  { background: #e6f9ee; color: #16a34a; }
.cp-health-message--low   { background: #fdecea; color: #b42318; }
.cp-health-message--muted { background: #f1f3f5; color: var(--bs-secondary-color); }

/* Responsive */
@media (min-width: 768px) {
    .cp-dash-welcome { font-size: 28px; }

    /* Two quick actions live now (Create tenant, Tenants); the owner-facing pair is
       hidden in Dashboard/Index. Back to repeat(3, 1fr) if they return. */
    .cp-quick-actions { grid-template-columns: repeat(2, 1fr); }

    .cp-metrics-row { flex-direction: row; }

    .cp-fleet-metrics { flex: 1.4; }

    .cp-health-card { flex: 1; }

    .cp-stat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===========================================================================
   Create-tenant modal — a cosmetic layer over bootstrap's own modal (bootstrap
   handles open/close/backdrop/focus/fade), matching the main app's Add-Participant
   modal: rounded card, centered title/subtitle, stacked fields, split footer.
   =========================================================================== */
.cp-create-modal {
    border-radius: 20px;
    overflow: hidden;
}

.cp-create-modal .modal-body {
    padding: 40px 44px 0;
}

.cp-create-title {
    font-size: 26px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 6px;
}

.cp-create-subtitle {
    font-size: 16px;
    color: var(--bs-secondary-color);
    text-align: center;
    margin: 0 0 24px;
}

.cp-create-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cp-create-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cp-create-label {
    font-weight: 500;
    margin: 0;
}

.cp-create-footer {
    padding: 24px 44px 32px;
    border-top: none;
    gap: 12px;
    flex-wrap: nowrap;
}

.cp-create-footer .btn {
    flex: 1;
    margin: 0;
}

.cp-create-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
