/* =========================================================
   Version Control Dashboard — Sidebar Mode (Studio Home)
   Renders inside the VC sidebar via dashboard.js
   ========================================================= */

/* ----------------------------------------------------------
   Sidebar Width Override (2/3 screen in dashboard mode)
   ---------------------------------------------------------- */

.course-vc-dashboard-mode .course-vc-sidebar {
    width: 66.67vw;
    left: -67vw;
}

body.course-vc-open .course-vc-dashboard-mode .course-vc-sidebar {
    left: 0;
}

body.course-vc-open.course-vc-dashboard .wrapper-view {
    margin-left: 66.67vw;
}

/* ----------------------------------------------------------
   Summary Cards (3-card row)
   ---------------------------------------------------------- */

.vc-dash-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.vc-dash-card {
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    cursor: help;
}

.vc-dash-card-number {
    font-size: 26px;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.vc-dash-card-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.vc-dash-card-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    text-transform: none;
    letter-spacing: 0;
}

/* ----------------------------------------------------------
   State Chips (below summary cards)
   ---------------------------------------------------------- */

.vc-dash-states {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.vc-dashboard-state-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.vc-dashboard-state-chip[data-state="draft"] {
    background: #fef3c7;
    color: #92400e;
}

.vc-dashboard-state-chip[data-state="in-revision"] {
    background: #cffafe;
    color: #155e75;
}

.vc-dashboard-state-chip[data-state="published"] {
    background: #d1fae5;
    color: #065f46;
}

/* ----------------------------------------------------------
   Course Table
   ---------------------------------------------------------- */

.vc-dashboard-table-wrapper {
    padding: 0 16px 16px 16px;
    overflow-x: auto;
}

.vc-dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.vc-dashboard-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

/* Sortable headers */
.vc-dashboard-table th.vc-dashboard-th-sort {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.vc-dashboard-table th.vc-dashboard-th-sort:hover {
    color: #2563eb;
}

.vc-dashboard-table th.vc-dashboard-th-sort.active {
    color: #1d4ed8;
}

.vc-dashboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.vc-dashboard-table tr:hover td {
    background: #f9fafb;
}

.vc-dashboard-table tr:last-child td {
    border-bottom: none;
}

/* State badge */
.vc-dashboard-state-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.vc-dashboard-state-badge[data-state="draft"] {
    background: #fef3c7;
    color: #92400e;
}

.vc-dashboard-state-badge[data-state="in-revision"] {
    background: #cffafe;
    color: #155e75;
}

.vc-dashboard-state-badge[data-state="published"] {
    background: #d1fae5;
    color: #065f46;
}

/* Course key */
.vc-dashboard-course-key {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: #111827;
}

/* Version */
.vc-dashboard-version {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    color: #374151;
}

/* Time in state */
.vc-dashboard-time {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

/* Discipline (KB-linked) */
.vc-dashboard-discipline {
    display: inline-block;
    padding: 2px 8px;
    background: #eef2ff;
    color: #3730a3;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* SA count column — right-aligned numeric */
.vc-dashboard-sa-count {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Revision history */
.vc-dashboard-revision-info {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
}

.vc-dashboard-revision-info .vc-revision-count {
    font-weight: 600;
    color: #374151;
}

/* Open count */
.vc-dashboard-open-count {
    font-weight: 700;
}

.vc-dashboard-open-count.has-blocking {
    /* color: #e36209; */
}

.vc-dashboard-blocking-note {
    font-size: 10px;
    color: #dc2626;
    font-weight: 600;
}

/* Severity mini-badges */
.vc-dashboard-severity {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.vc-dashboard-sev-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.vc-dashboard-sev-badge.sev-A {
    background: #ffeef0;
    color: #d73a49;
}

.vc-dashboard-sev-badge.sev-B {
    background: #fff5e6;
    color: #e36209;
}

.vc-dashboard-sev-badge.sev-C {
    background: #fffbdd;
    color: #735c0f;
}

.vc-dashboard-sev-badge.sev-D {
    background: #e6f0ff;
    color: #0366d6;
}

/* Certification indicator */
.vc-dashboard-cert-ready {
    color: #16a34a;
    font-weight: 600;
    font-size: 12px;
}

.vc-dashboard-cert-blocked {
    color: #dc2626;
    font-weight: 600;
    font-size: 12px;
}

/* Course link */
.vc-dashboard-course-link {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #0075b4;
    background: #eff6ff;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}

.vc-dashboard-course-link:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ----------------------------------------------------------
   Loading / Empty States
   ---------------------------------------------------------- */

.vc-dashboard-loading {
    color: #6b7280;
    font-size: 13px;
    text-align: center;
    padding: 12px 0;
}

.vc-dashboard-empty {
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    padding: 20px 0;
}

/* ----------------------------------------------------------
   Pagination
   ---------------------------------------------------------- */

.vc-dashboard-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0 4px 0;
    font-size: 12px;
    color: #6b7280;
}

.vc-dashboard-pagination-info {
    white-space: nowrap;
}

.vc-dashboard-page-buttons {
    display: flex;
    align-items: center;
    gap: 2px;
}

.vc-dashboard-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.vc-dashboard-page-btn:hover:not(:disabled):not(.active) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.vc-dashboard-page-btn.active {
    background: #0075b4;
    border-color: #0075b4;
    color: #fff;
}

.vc-dashboard-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.vc-dashboard-page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    font-size: 12px;
    color: #9ca3af;
}

/* ----------------------------------------------------------
   Filter Row
   ---------------------------------------------------------- */

.vc-dashboard-filters {
    padding: 12px 16px 0 16px;
}

.vc-dashboard-filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.vc-dashboard-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vc-dashboard-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.vc-dashboard-filter-select {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    color: #374151;
    background: #fff;
    cursor: pointer;
    min-width: 140px;
    font-family: inherit;
}

.vc-dashboard-filter-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Soft-reload state — applied to the table wrapper while a
   filter / sort / pagination fetch is in flight on top of an
   already-rendered table. Visually signals "data is changing"
   without wiping the rows; transition smooths the in/out so the
   table doesn't strobe on fast responses. */
.vc-dashboard-table-reloading {
    opacity: 0.55;
    transition: opacity 0.12s ease-in;
}

/* Per-column filter row (second row inside the exploded table's
   <thead>). Light background to distinguish from the sortable
   header above it; smaller controls so the row stays compact. */
.vc-dashboard-filter-row-cols th {
    background: #f9fafb;
    padding: 4px 6px;
    border-bottom: 1px solid #e5e7eb;
}
.vc-dashboard-col-filter-input,
.vc-dashboard-col-filter-select {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 11px;
    color: #374151;
    background: #fff;
    font-family: inherit;
    min-width: 0;
}
.vc-dashboard-col-filter-input:focus,
.vc-dashboard-col-filter-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.vc-dashboard-filter-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: #eff6ff;
    color: #2563eb;
    white-space: nowrap;
}

.vc-dashboard-filter-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #2563eb;
    font-size: 14px;
    font-weight: 700;
    padding: 0 0 0 4px;
    line-height: 1;
}

.vc-dashboard-filter-clear:hover {
    color: #1d4ed8;
}

/* ----------------------------------------------------------
   Charts Area (2-column grid)
   ---------------------------------------------------------- */

.vc-dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 8px 16px;
    height: 322px;
}

.vc-dashboard-chart-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.vc-dashboard-chart-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.vc-dashboard-chart-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
}

/* ----------------------------------------------------------
   Dashboard content padding
   ---------------------------------------------------------- */

.vc-dashboard-summary {
    padding: 16px 16px 0 16px;
}

/* ----------------------------------------------------------
   Dashboard Settings Panel
   ---------------------------------------------------------- */

#vc-dashboard-settings {
    padding: 16px;
}

#vc-dashboard-settings .vc-dashboard-table {
    margin-bottom: 16px;
}

#vc-dashboard-settings .course-vc-btn-danger {
    font-size: 11px;
    padding: 3px 10px;
}

/* ----------------------------------------------------------
   Export Buttons
   ---------------------------------------------------------- */

.vc-dashboard-export-group {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.vc-dashboard-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}

.vc-dashboard-export-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.vc-dashboard-export-btn:active {
    background: #e5e7eb;
}

.vc-dashboard-export-btn svg {
    flex-shrink: 0;
}

.vc-dashboard-export-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.vc-export-spinner {
    animation: vc-spin 1s linear infinite;
}

@keyframes vc-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* SKIIM v2 lifecycle — per-state badges by integer id. Keep the
   legacy data-state="draft|in-revision|published" rules above for
   any v1 data still in flight; these new rules win when the v2
   integer id is present. */
.vc-dashboard-state-badge[data-state="5"]  { background: #f3e8ff; color: #6b21a8; }
.vc-dashboard-state-badge[data-state="10"] { background: #fef3c7; color: #92400e; }
.vc-dashboard-state-badge[data-state="15"] { background: #ffedd5; color: #9a3412; }
.vc-dashboard-state-badge[data-state="25"] { background: #cffafe; color: #155e75; }
.vc-dashboard-state-badge[data-state="28"] { background: #fed7aa; color: #7c2d12; }
.vc-dashboard-state-badge[data-state="35"] { background: #e0e7ff; color: #312e81; }
.vc-dashboard-state-badge[data-state="45"] { background: #ede9fe; color: #4c1d95; }
.vc-dashboard-state-badge[data-state="50"] { background: #dbeafe; color: #1e40af; }
.vc-dashboard-state-badge[data-state="80"] { background: #f3f4f6; color: #374151; }
.vc-dashboard-state-badge[data-state="90"] { background: #fee2e2; color: #991b1b; }
.vc-dashboard-state-badge[data-state="99"] { background: #dcfce7; color: #166534; }

/* SKIIM v2 lifecycle — summary state chips by integer id. Same
   palette family as .vc-dashboard-state-badge above, slightly more
   saturated to read on the white summary row. */
.vc-dashboard-state-chip[data-state="5"]  { background: #f3e8ff; color: #6b21a8; }
.vc-dashboard-state-chip[data-state="10"] { background: #fef3c7; color: #92400e; }
.vc-dashboard-state-chip[data-state="15"] { background: #ffedd5; color: #9a3412; }
.vc-dashboard-state-chip[data-state="25"] { background: #cffafe; color: #155e75; }
.vc-dashboard-state-chip[data-state="28"] { background: #fed7aa; color: #7c2d12; }
.vc-dashboard-state-chip[data-state="35"] { background: #e0e7ff; color: #312e81; }
.vc-dashboard-state-chip[data-state="45"] { background: #ede9fe; color: #4c1d95; }
.vc-dashboard-state-chip[data-state="50"] { background: #dbeafe; color: #1e40af; }
.vc-dashboard-state-chip[data-state="80"] { background: #f3f4f6; color: #374151; }
.vc-dashboard-state-chip[data-state="90"] { background: #fee2e2; color: #991b1b; }
.vc-dashboard-state-chip[data-state="99"] { background: #dcfce7; color: #166534; }

/* ─── Dashboard Settings: tab navigation ────────────────────────── */
.vc-dash-settings-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 16px;
}
.vc-dash-settings-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.vc-dash-settings-tab:hover { color: #28a745; }
.vc-dash-settings-tab.active {
    color: #28a745;
    border-bottom-color: #28a745;
}
.vc-dash-settings-tab-content { display: none; }
.vc-dash-settings-tab-content.active { display: block; }

/* Org selector strip at the top of the Papéis Globais tab. */
.vc-dash-roles-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.vc-dash-roles-toolbar label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.vc-dash-roles-toolbar select {
    flex: 0 1 280px;
}

/* Global Roles tab — the comma-separated bulk-add input now carries a
   longer placeholder ("utilizador, email, ou emails separados por
   vírgulas") that gets cropped at the default ~150 px browser width.
   Stretch it to fill the role card and stay aligned with the "Add"
   button via the row's flex layout. */
.vc-global-role-add {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
}
.vc-global-role-add-input {
    flex: 1;
    min-width: 320px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
}
.vc-global-role-add-btn {
    flex-shrink: 0;
}
