/* Power to Live admin overrides applied on every admin page (loaded via
   UNFOLD["STYLES"]). Keeps small layout tweaks in one place. */

/* Dashboard styles — moved here so light/dark mode rules can coexist without
   the inline-style precedence fights we had previously. */
.ptl-card { background:white; border-radius:8px; padding:18px 20px;
            box-shadow:0 1px 2px rgba(0,0,0,0.06); border:1px solid #e2e8f0; }
.ptl-card:hover { box-shadow:0 4px 10px rgba(0,0,0,0.08); }
.ptl-card .label { font-size:12px; color:#64748b; text-transform:uppercase;
                   letter-spacing:0.04em; font-weight:600; }
.ptl-card .value { font-size:32px; font-weight:600; color:#0f172a;
                   margin-top:4px; line-height:1.2; }
.ptl-card.highlight { border-color:#f59e0b; background:#fffbeb; }
.ptl-section h2 { font-size:14px; font-weight:600; color:#475569;
                  text-transform:uppercase; letter-spacing:0.04em;
                  margin:0 0 10px 0; }
.ptl-row { display:flex; align-items:center; justify-content:space-between;
           padding:10px 12px; border-radius:6px; }
.ptl-row:hover { background:#f8fafc; }
.ptl-row a { color:#0f766e; text-decoration:none; font-weight:500; }
.ptl-row .meta { color:#64748b; font-size:12px; }
.ptl-rag-bar { display:flex; gap:4px; margin-top:6px; }
.ptl-rag-pill { padding:2px 10px; border-radius:999px; font-size:12px;
                font-weight:600; color:white; }

/* Dark mode overrides — html.dark is the class unfold puts on <html>. */
html.dark .ptl-card { background:#1e293b; border-color:#334155; }
html.dark .ptl-card .value { color:#f8fafc; }
html.dark .ptl-card .label { color:#94a3b8; }
html.dark .ptl-card.highlight { background:#451a03; border-color:#92400e; }
html.dark .ptl-section h2 { color:#cbd5e1; }
html.dark .ptl-row a { color:#5eead4; }
html.dark .ptl-row .meta { color:#94a3b8; }
html.dark .ptl-row:hover { background:rgba(148,163,184,0.06); }

/* Multi-field form rows (fieldsets that group 2–4 fields on one line, e.g. the
   client Personal tab). Unfold lays each field-line as label + input side by
   side with a FIXED 224px (w-56) label. In a 3–4 column grid each column is too
   narrow for a 224px side-label, so labels and inputs crowd and misalign.
   For these multi-column rows, stack the label ABOVE the input and let the
   input fill the column. Single-field rows (grid-cols-1) keep Unfold's default
   side-label layout. */
.field-row[class*="grid-cols-2"] .field-line,
.field-row[class*="grid-cols-3"] .field-line,
.field-row[class*="grid-cols-4"] .field-line {
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
}
/* Neutralise the fixed-width, fixed-height label wrapper so it sits on its own
   line at natural size. */
.field-row[class*="grid-cols-2"] .field-line > div:first-child,
.field-row[class*="grid-cols-3"] .field-line > div:first-child,
.field-row[class*="grid-cols-4"] .field-line > div:first-child {
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    line-height: normal !important;
    margin-bottom: 0.375rem;
}

/* Changelist table: the first cell holds the row checkbox; unfold renders it
   right against the left border. Give it breathing room and match it on the
   header so columns stay aligned. */
#result_list th:first-child,
#result_list td:first-child {
    padding-left: 1rem !important;
    padding-right: 0.5rem !important;
}

/* The action-checkbox column is fixed-width — let the checkbox center inside it */
#result_list th.action-checkbox-column,
#result_list td.action-checkbox {
    text-align: center;
}

/* Reduce horizontal padding on the inner cells slightly so wider columns
   don't overflow the viewport with our long status labels. */
#result_list th,
#result_list td {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Whole-row click navigation: cursor hint + slight hover background. The actual
   click handler lives in row-click.js. */
#result_list tbody tr {
    cursor: pointer;
}
#result_list tbody tr:hover {
    background-color: rgba(15, 118, 110, 0.04);
}

/* Mobile: unfold's tab strip overflows the form container with 5 tabs in a
   narrow viewport. Allow horizontal scrolling instead of clipping. */
@media (max-width: 768px) {
    /* The tab strip is a <nav> whose first ancestor with overflow:hidden clips
       it. Force the nav to scroll its own content. */
    .form-rows nav.flex.flex-row,
    .form-rows > div > nav {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        scrollbar-width: thin;
    }
    .form-rows nav.flex.flex-row > a,
    .form-rows nav.flex.flex-row > * {
        flex-shrink: 0;
    }
    /* Help text shouldn't run off the right edge — let it wrap. */
    .help, .helptext, [class*=help-text] {
        word-break: break-word;
        white-space: normal !important;
        max-width: 100%;
    }
}

/* Login page renders TWO sibling .login-box wrappers, each holding the same
   django_google_sso "Sign in with Google" button — once from unfold's login
   layout, once from django_google_sso's own template injection. Hide all
   but the first. */
.login-box + .login-box { display: none !important; }

/* Django admin's history page renders a stock <table>, but unfold's global
   td styling adds a `::before { content: attr(data-label) }` for mobile
   responsiveness. On the history table that shows the column name (Date/Time,
   User, Action) twice — once as the header, once injected before each cell's
   value. Suppress on viewports wider than the mobile breakpoint. */
@media (min-width: 769px) {
    table[id$="history"] td::before,
    .module table td::before {
        content: none !important;
    }
}

/* Hide Django admin's "Note: You are N hours ahead of server time" warning
   that the DateTimeShortcuts JS attaches to date/datetime widgets. Staff know
   what timezone they're in; the warning is more confusing than helpful, and
   meaningless for DateField (date_of_birth etc.). */
.timezonewarning {
    display: none !important;
}

/* Filter side panel: on short screens the panel content (~2800px tall) runs off
   the viewport with no internal scroll because the outer wrapper has no height
   cap. Cap the wrapper to viewport height; unfold's own inner divs already use
   overflow: auto so they take over scrolling once the outer height is bounded.
   Don't reposition the element — leave it as the side panel unfold renders. */
#changelist-filter {
    max-height: calc(100vh - 80px) !important;
    overflow: hidden !important;
}

/* AI explanation card (matching/matchresult change page + result inline).
   The wrapping `<p class="readonly">` from Django/unfold applies a muted gray
   color that the card inherits, making the prose unreadable on the light card
   background. Force explicit foreground + background; provide a dark-mode
   variant so the demo looks right in either theme. */
.ptl-ai-card {
    background: #eff6ff !important;
    color: #0f172a !important;
    border-left: 3px solid #2563eb;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 1.02em;
    line-height: 1.55;
    max-width: 720px;
}
.ptl-ai-card .ptl-ai-icon {
    color: #2563eb;
    font-weight: 700;
    margin-right: 6px;
}
.dark .ptl-ai-card,
html.dark .ptl-ai-card {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border-left-color: #60a5fa;
}
.dark .ptl-ai-card .ptl-ai-icon,
html.dark .ptl-ai-card .ptl-ai-icon {
    color: #93c5fd;
}
.ptl-ai-empty {
    color: #94a3b8 !important;
    font-style: italic;
}
.ptl-ai-inline {
    max-width: 520px;
    font-size: 0.92em;
    line-height: 1.4;
    color: #0f172a;
}
.dark .ptl-ai-inline,
html.dark .ptl-ai-inline {
    color: #e2e8f0;
}
