/* Admin Studio Hub + Studios cockpit — dense, functional "Win32" styling.
   Reuses existing provider-badge / status color conventions from sites.css and
   staff-management.css to stay coherent with the rest of the app. */

/* ============================ Admin button paradigm ============================
   One consistent button style for the whole admin console. Buttons are content-
   sized (hug their label) with uniform height/padding, so table-row actions and
   toolbar controls line up cleanly. This overrides the global auth-form rule
   `.btn-primary { width: 100% }` (app.css), which would otherwise stretch every
   admin primary button — "Manage…", "Open Hub", "Apply", "+ Add location" — to
   fill its container and, inside a wrapping flex bar, drop it onto its own row. */
.admin-cockpit .btn,
.studio-hub .btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8125rem;
    line-height: 1.2;
    white-space: nowrap;
    vertical-align: middle;
}

.admin-cockpit .btn-sm,
.studio-hub .btn-sm {
    padding: 0.32rem 0.65rem;
    font-size: 0.78rem;
}

/* The back control is icon-only chrome, not a padded button. */
.studio-hub .btn.hub-back {
    padding: 0.2rem 0.4rem;
    width: auto;
}

/* Refresh / Apply / Add actions sit in-line with the search & filter controls,
   pushed to the far right of the filter bar for a consistent admin paradigm. */
.hub-filter-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================ Studios cockpit ============================ */
.admin-cockpit {
    padding: 1rem 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-cockpit-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-cockpit-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.admin-cockpit-header p {
    margin: 0.25rem 0 0;
    color: #6b7280;
    font-size: 0.875rem;
}

.admin-cockpit-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.admin-search {
    position: relative;
    flex: 1 1 260px;
    max-width: 420px;
}

.admin-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
}

.admin-search-input {
    width: 100%;
    padding: 0.45rem 0.6rem 0.45rem 2rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.admin-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
}

.admin-filter-select,
.hub-filter-bar select,
.hub-filter-bar input {
    padding: 0.4rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.admin-cockpit-count {
    margin-left: auto;
    color: #6b7280;
    font-size: 0.8125rem;
}

/* ============================ Shared dense table ============================ */
.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.admin-table thead th {
    text-align: left;
    padding: 0.55rem 0.75rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.admin-table th.num,
.admin-table td.num {
    text-align: right;
}

.admin-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.admin-table th.sortable:hover {
    background: #f3f4f6;
}

.admin-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-row {
    cursor: pointer;
}

.admin-row:hover {
    background: #f8fafc;
}

.admin-cell-name {
    display: flex;
    flex-direction: column;
}

.admin-studio-name {
    font-weight: 600;
    color: #111827;
}

.admin-studio-id {
    font-size: 0.72rem;
    color: #9ca3af;
}

.admin-cell-action {
    text-align: right;
    white-space: nowrap;
}

.open-subs-badge {
    display: inline-block;
    min-width: 1.5rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
    text-align: center;
}

.cred-status {
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.cred-ok { background: #dcfce7; color: #166534; }
.cred-bad { background: #fee2e2; color: #991b1b; }
.cred-unknown { background: #f3f4f6; color: #6b7280; }

/* Provider badges (mirror sites.css conventions) */
.provider-badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.provider-badge-mbo { background: #e0e7ff; color: #3730a3; }
.provider-badge-wl { background: #d1fae5; color: #065f46; }

.admin-empty,
.hub-empty {
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}

.admin-error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    margin-bottom: 1rem;
}

/* ============================ Studio Hub ============================ */
.studio-hub {
    padding: 0 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.hub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 0 0.5rem;
}

.hub-header-main {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.hub-header-main h1 {
    margin: 0;
    font-size: 1.35rem;
}

.hub-back {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.hub-studio-id {
    color: #9ca3af;
    font-size: 0.78rem;
}

.hub-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.hub-mode-pill {
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
}

.hub-mode-readonly { background: #f3f4f6; color: #6b7280; }
.hub-mode-edit { background: #fee2e2; color: #991b1b; }

/* Provider capability notices */
.hub-notice {
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    margin: 0.5rem 0;
    border: 1px solid transparent;
}

.hub-notice-mbo { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.hub-notice-wl { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }

/* Superuser banner — color-coded, persistent */
.superuser-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.6rem 1rem;
    margin: 0.75rem 0;
    background: #b91c1c;
    color: #fff;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.superuser-banner-icon { font-size: 1.1rem; }
.superuser-banner-reason {
    font-weight: 400;
    opacity: 0.9;
    font-size: 0.78rem;
    max-width: 40ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.superuser-banner-exit {
    margin-left: auto;
    background: #fff;
    color: #b91c1c;
    border: none;
    font-weight: 700;
}

/* Tabs */
.hub-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid #e5e7eb;
    margin: 0.75rem 0 1rem;
    flex-wrap: wrap;
}

.hub-tab {
    background: none;
    border: none;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
}

.hub-tab:hover { color: #374151; }
.hub-tab.active { color: #2563eb; border-bottom-color: #2563eb; }

/* Overview cards */
.hub-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.hub-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.hub-card-alert { border-color: #fcd34d; background: #fffbeb; }
.hub-card-value { font-size: 1.35rem; font-weight: 700; color: #111827; }
.hub-card-label { font-size: 0.75rem; color: #6b7280; }

.hub-quick-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hub-quick-links h3 {
    width: 100%;
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
}

/* Filter bars inside tabs */
.hub-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.hub-filter-bar label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    color: #374151;
}

.hub-filter-bar h3 { margin: 0; font-size: 1rem; }

.hub-table { width: 100%; border: 1px solid #e5e7eb; border-radius: 8px; }
.hub-actions-cell { white-space: nowrap; display: flex; gap: 0.35rem; }

.muted { color: #9ca3af; font-size: 0.75rem; }

.status-pill {
    padding: 0.12rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #f3f4f6;
    color: #374151;
}

.status-pill.status-active { background: #dcfce7; color: #166534; }
.status-pill.status-inactive { background: #fee2e2; color: #991b1b; }

/* Superuser modals */
.superuser-modal-content { max-width: 520px; }
.superuser-modal-header h2 { color: #b91c1c; }

.superuser-warning {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 0.8125rem;
    color: #9a3412;
}

.confirm-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.confirm-row { display: flex; gap: 0.5rem; }
.confirm-label { min-width: 70px; font-weight: 600; color: #6b7280; font-size: 0.8125rem; }
.confirm-value { color: #111827; font-size: 0.8125rem; }
.confirm-value.reason-text { font-style: italic; }

/* InstructorModal MBO managed-fields notice (SysAdmin view) */
.mbo-managed-notice {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-size: 0.78rem;
    color: #3730a3;
    margin-bottom: 0.6rem;
}

.info-value-disabled { color: #9ca3af; }

.btn-warning {
    background: #f59e0b;
    color: #fff;
    border: none;
}

.btn-warning:hover { background: #d97706; }

/* ============================ Role mappings tab ============================
   Dense provider permission-group → SubGuru role editor. Reuses admin-table / status-pill /
   provider-badge / hub-actions-cell; only the provenance pill and column alignment are new. */
.hub-role-mappings .mapping-group-name {
    font-weight: 600;
    color: #111827;
    word-break: break-word;
}

.hub-role-mappings .mapping-group-name + .provider-badge { margin-left: 0.4rem; }

/* Provenance pill for the seeded (migration) row — reuses the amber open-subs-badge palette. */
.mapping-source-seeded {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-weight: 600;
}

.mapping-actions-col { text-align: right; }

/* Soft-deleted (inactive) mappings read as de-emphasized but remain fully actionable. */
.mapping-row-inactive { opacity: 0.6; }

