/* =============================================================================
 * Phase 6 Share/Manage — share.css (06-05)
 *
 * Styles for the /Shares flat-table list+drawer surface:
 *   - Toolbar (search + status segment + spacer + export)
 *   - Status segment chips (Active / Scheduled / Expired / Revoked)
 *   - Bulk action bar (slides in 180ms ease-out on first row select)
 *   - Shares table (flat, clickable rows, column layout)
 *   - Mobile: table → stacked card collapse at <768px (D-07 pattern)
 *   - Drawer content (inner content; shell/drawer chrome is in shell.css)
 *   - Reduced-motion guard (all transitions disabled)
 *
 * Token rule: ONLY hsl(var(--token)) references. No hex. No !important.
 * All values from /Users/sjplumm/Secuura/.brand-kit/BRAND-CHIPS.md §1.
 * ============================================================================= */

/* ---------------------------------------------------------------------------
 * Toolbar
 * --------------------------------------------------------------------------- */

.secuura-shares-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.secuura-shares-search {
    max-width: 280px;
}

.secuura-shares-toolbar-spacer {
    flex-grow: 1;
}

/* ---------------------------------------------------------------------------
 * Status segment chips
 * --------------------------------------------------------------------------- */

.secuura-status-segment {
    display: inline-flex;
    gap: 4px;
    padding: 2px;
    background-color: hsl(var(--muted));
    border-radius: 9999px;
}

.secuura-status-segment-chip {
    border: none;
    background-color: transparent;
    color: hsl(var(--muted-foreground));
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.secuura-status-segment-chip:hover {
    color: hsl(var(--foreground));
}

.secuura-status-segment-chip:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.secuura-status-segment-chip--active {
    background-color: hsl(var(--card));
    color: hsl(var(--foreground));
    box-shadow: 0 1px 2px hsl(var(--foreground) / 0.08);
}

.secuura-status-segment-count {
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 9999px;
    background-color: hsl(var(--background));
    color: hsl(var(--muted-foreground));
    font-size: 0.625rem;
}

/* ---------------------------------------------------------------------------
 * Bulk action bar (slides down 180ms ease-out on first selection)
 * --------------------------------------------------------------------------- */

.secuura-bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    margin-bottom: 12px;
    transform: translateY(-8px);
    opacity: 0;
    transition: transform 180ms ease-out, opacity 180ms ease-out;
}

.secuura-bulk-action-bar[data-active="true"] {
    transform: translateY(0);
    opacity: 1;
}

.secuura-bulk-action-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
}

.secuura-bulk-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
 * Shares table
 * --------------------------------------------------------------------------- */

.secuura-shares-table {
    width: 100%;
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    border-collapse: collapse;
    overflow: hidden;
}

.secuura-shares-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    background-color: hsl(var(--muted));
    border-bottom: 1px solid hsl(var(--border));
}
/* 06-13 pass 2: allow per-column overrides (e.g. Actions on RHS) without losing
   the shares-table base styling. .text-right wins via specificity + class match. */
.secuura-shares-table thead th.text-right,
.secuura-shares-table tbody td.text-right {
    text-align: right;
}

.secuura-shares-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    vertical-align: middle;
}

.secuura-shares-table tbody tr {
    cursor: pointer;
    transition: background-color 150ms ease;
}

.secuura-shares-table tbody tr:hover {
    background-color: hsl(var(--muted) / 0.5);
}

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

.secuura-shares-table tbody tr[data-selected="true"] {
    background-color: hsl(var(--primary) / 0.08);
}

/* Status-tinted rows (color is never the sole signal — text also changes) */
.secuura-shares-table tbody tr[data-status="expired"] td {
    color: hsl(var(--muted-foreground));
}

.secuura-shares-table tbody tr[data-status="expired"] td:nth-child(2) {
    text-decoration: line-through;
}

.secuura-shares-table tbody tr[data-status="revoked"] td {
    color: hsl(var(--destructive));
}

/* Checkbox column */
.secuura-shares-row-checkbox {
    cursor: pointer;
}

/* External recipient flag */
.secuura-shares-recipient-external {
    margin-left: 4px;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

/* Row ⋯ menu button */
.secuura-shares-row-menu-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    border-radius: calc(var(--radius) - 4px);
}

.secuura-shares-row-menu-btn:hover {
    background-color: hsl(var(--muted));
    color: hsl(var(--foreground));
}

.secuura-shares-row-menu-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * Mobile: table collapses to stacked cards at <768px (D-07 pattern)
 * --------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    .secuura-shares-table thead {
        display: none;
    }

    .secuura-shares-table tbody tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid hsl(var(--border));
        border-radius: var(--radius);
        overflow: hidden;
    }

    .secuura-shares-table tbody td {
        display: block;
        padding: 8px 12px;
        border-bottom: 1px solid hsl(var(--border) / 0.5);
    }

    .secuura-shares-table tbody td:last-child {
        border-bottom: none;
    }

    .secuura-shares-table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        color: hsl(var(--muted-foreground));
        margin-bottom: 2px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .secuura-bulk-action-buttons {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---------------------------------------------------------------------------
 * Drawer content (inner styles; shell drawer chrome lives in shell.css)
 * --------------------------------------------------------------------------- */

.secuura-share-drawer-section {
    padding: 16px 0;
    border-bottom: 1px solid hsl(var(--border));
}

.secuura-share-drawer-section:last-of-type {
    border-bottom: none;
}

.secuura-share-drawer-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    margin: 0 0 8px;
}

.secuura-share-drawer-doc-summary {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.secuura-share-drawer-doc-icon {
    font-size: 1.5rem;
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
    margin-top: 2px;
}

.secuura-share-drawer-doc-name {
    font-weight: 500;
    color: hsl(var(--foreground));
    word-break: break-word;
}

.secuura-share-drawer-doc-meta {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 2px;
}

.secuura-share-drawer-recipient {
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    word-break: break-all;
}

.secuura-share-drawer-activity {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* 06-13 polish: was border-left: 2px (side-stripe ban per DESIGN.md §6).
   Replaced with a 1px guide (under the threshold) plus a leading dot accent
   on the first entry, signalling timeline without the colored stripe pattern. */
.secuura-share-drawer-activity li {
    padding: 8px 0 8px 18px;
    border-left: 1px solid hsl(var(--border));
    margin-left: 4px;
    position: relative;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
}
.secuura-share-drawer-activity li::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 14px;
    width: 7px;
    height: 7px;
    border-radius: 9999px;
    background-color: hsl(var(--muted-foreground));
}
.secuura-share-drawer-activity li:first-child::before {
    background-color: hsl(var(--primary));
}

.secuura-share-drawer-activity li + li {
    margin-top: 4px;
}

.secuura-share-drawer-activity-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.75rem;
    color: hsl(var(--primary));
}

.secuura-share-drawer-activity-link:hover {
    color: hsl(var(--primary) / 0.8);
    text-decoration: underline;
}

.secuura-share-drawer-activity-empty {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    padding: 8px 0;
}

.secuura-share-drawer-actions {
    display: flex;
    gap: 8px;
    padding: 16px 0 0;
    justify-content: flex-end;
    border-top: 1px solid hsl(var(--border));
}

/* ---------------------------------------------------------------------------
 * Phase 11 mobile touch-target + layout refinements (06-11 append)
 * --------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    /* Bulk action bar wraps to column on phone */
    .secuura-bulk-action-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .secuura-bulk-action-buttons {
        flex-direction: column;
    }
    .secuura-bulk-action-bar .btn { min-height: 44px; }
    /* Status segment chips wrap on narrow screens */
    .secuura-status-segment { flex-wrap: wrap; }
    .secuura-status-segment-chip { min-height: 36px; padding: 8px 16px; }
    /* Drawer footer buttons stack and stretch full-width */
    .secuura-share-drawer-actions { flex-direction: column; }
    .secuura-share-drawer-actions .btn { width: 100%; min-height: 44px; }
}

/* ---------------------------------------------------------------------------
 * Reduced-motion guard — all transitions become instant
 * --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .secuura-bulk-action-bar {
        transition: none;
    }

    .secuura-status-segment-chip {
        transition: none;
    }

    .secuura-shares-table tbody tr {
        transition: none;
    }
}

/* ============================================================
   Phase 6 Revoke (06-06) — appended to share.css
   Modal entry animation, optimistic-row-update, undo toast.
   Token rule: hsl(var(--token)) only. No hex. No !important.
   ============================================================ */

/* ---------------------------------------------------------------------------
 * Modal entry animation
 * Overrides Bootstrap's default 300ms fade with 180ms scale + opacity.
 * Backdrop separately fades at 120ms.
 * --------------------------------------------------------------------------- */

.secuura-revoke-modal-shell .modal-content.secuura-revoke-modal-content,
.secuura-block-modal-shell  .modal-content {
    transform: scale(0.96);
    opacity: 0;
    transition: transform 180ms ease-out, opacity 180ms ease-out;
}

.secuura-revoke-modal-shell.show .modal-content.secuura-revoke-modal-content,
.secuura-block-modal-shell.show  .modal-content {
    transform: scale(1);
    opacity: 1;
}

/* Backdrop fade at 120ms (Bootstrap appends .show to .modal-backdrop.fade) */
.modal-backdrop.fade.show {
    transition: opacity 120ms ease-out;
}

/* ---------------------------------------------------------------------------
 * Recipient chip list inside the modal body
 * --------------------------------------------------------------------------- */

.secuura-revoke-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background-color: hsl(var(--muted));
    border-radius: calc(var(--radius) - 2px);
    min-height: 36px;
}

.secuura-revoke-recipient-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 9999px;
    font-size: 0.75rem;
    color: hsl(var(--foreground));
}

/* External recipient: gold accent border + label suffix */
.secuura-revoke-recipient-chip--external {
    border-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    background-color: hsl(var(--accent) / 0.15);
}

.secuura-revoke-recipient-chip--external::after {
    content: "External";
    margin-left: 4px;
    font-size: 0.625rem;
    color: hsl(var(--accent-foreground));
    font-weight: 600;
    opacity: 0.8;
}

/* ---------------------------------------------------------------------------
 * Optimistic row state — applied by revoke.js immediately on confirm
 * Reverts in 200ms if user clicks Undo.
 * --------------------------------------------------------------------------- */

.secuura-shares-table tbody tr[data-pending-revoke="true"] {
    background-color: hsl(var(--destructive) / 0.08);
    color: hsl(var(--destructive));
    text-decoration: line-through;
    transition: background-color 200ms ease-out, color 200ms ease-out, text-decoration 200ms ease-out;
}

/* ---------------------------------------------------------------------------
 * Undo toast — fixed bottom-right, slide up 200ms on appear
 * --------------------------------------------------------------------------- */

.secuura-revoke-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background-color: hsl(var(--foreground));
    color: hsl(var(--background));
    border-radius: var(--radius);
    box-shadow: 0 4px 16px hsl(var(--foreground) / 0.25);
    z-index: 1080;
    transform: translateY(16px);
    opacity: 0;
    transition: transform 200ms ease-out, opacity 200ms ease-out;
    min-width: 280px;
}

.secuura-revoke-toast[data-state="visible"] {
    transform: translateY(0);
    opacity: 1;
}

.secuura-revoke-toast[data-state="success"] {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    transform: translateY(0);
    opacity: 1;
}

.secuura-revoke-toast-message {
    flex: 1;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}

/* Countdown digit wrapper — pulse animation on each tick */
.secuura-revoke-toast-countdown {
    display: inline-block;
    min-width: 1ch;
    text-align: right;
    font-weight: 700;
    animation: secuura-revoke-pulse 60ms ease-in-out;
}

@keyframes secuura-revoke-pulse {
    0%   { transform: scale(1);   }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1);   }
}

/* ---------------------------------------------------------------------------
 * Reduced-motion guard — disable all Phase 6 Revoke animations
 * --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .secuura-revoke-modal-shell .modal-content.secuura-revoke-modal-content,
    .secuura-block-modal-shell  .modal-content,
    .secuura-shares-table tbody tr[data-pending-revoke="true"],
    .secuura-revoke-toast {
        transition: none;
    }

    .secuura-revoke-toast-countdown {
        animation: none;
    }
}

/* ============================================================================
   Phase 6 Plan 10 (06-10) — Distribution list extensions
   Appended to share.css per workspace-override rule:
   "extend share.css if needed for distribution-specific styles".
   Token rule: hsl(var(--token)) only. No hex. No !important.
   ============================================================================ */

/* ---------------------------------------------------------------------------
 * Toolbar heading (surface 7e uses a heading inside the toolbar row)
 * --------------------------------------------------------------------------- */

.secuura-shares-heading {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin: 0;
    white-space: nowrap;
}

.secuura-shares-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

/* When the toolbar wraps its heading and controls rows on narrow screens */
.secuura-shares-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------------------------------------------------------------------------
 * Distribution status badges (surface 7e — not the same as _StatusBadge which
 * is for DocumentDistributionResponse/Permission; these map to
 * S2Constants.DocumentDistributionStatus: NotStarted/Pending/InProgress/Complete)
 * Color is never the sole signal — text label always present (WCAG D-01).
 * --------------------------------------------------------------------------- */

.secuura-dist-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.5;
}

.secuura-dist-badge--notstarted {
    background-color: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
}

.secuura-dist-badge--pending {
    background-color: hsl(var(--accent) / 0.15);
    color: hsl(var(--accent-foreground));
    border: 1px solid hsl(var(--accent) / 0.4);
}

.secuura-dist-badge--inprogress {
    background-color: hsl(var(--secondary) / 0.12);
    color: hsl(var(--secondary));
    border: 1px solid hsl(var(--secondary) / 0.3);
}

.secuura-dist-badge--complete {
    background-color: hsl(var(--primary) / 0.12);
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--primary) / 0.3);
}

/* ---------------------------------------------------------------------------
 * Distribution table column widths
 * --------------------------------------------------------------------------- */

.secuura-shares-table .secuura-shares-col-check {
    width: 40px;
}

.secuura-shares-table .secuura-shares-col-status {
    width: 140px;
}

.secuura-shares-table .secuura-shares-col-date {
    width: 120px;
}

/* ---------------------------------------------------------------------------
 * Reduced-motion guard — distribution badge transitions
 * --------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .secuura-dist-badge {
        transition: none;
    }
}


/* =============================================================================
 * 06-13 pass 2 — modernised Share-create form
 * Replaces the legacy <select multiple> + <textarea> emails + radios layout in
 * Views/SendDocs/Share.cshtml. Chip recipients, segmented permission, expiry presets.
 * ============================================================================= */

.secuura-share-create {
    display: grid;
    gap: 24px;
}

.secuura-share-section {
    background-color: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 20px;
}
.secuura-share-section__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}
.secuura-share-section__header h6 {
    font-weight: 600;
    color: hsl(var(--foreground));
}
.secuura-share-section__hint {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

/* ----- Document picker ----- */
.secuura-share-doc-filter {
    margin-bottom: 12px;
}
.secuura-share-doc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
}
.secuura-share-doc-row {
    border-bottom: 1px solid hsl(var(--border) / 0.5);
}
.secuura-share-doc-row:last-child {
    border-bottom: none;
}
.secuura-share-doc-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    margin: 0;
    transition: background-color 120ms ease;
}
.secuura-share-doc-label:hover {
    background-color: hsl(var(--muted) / 0.4);
}
.secuura-share-doc-checkbox {
    width: 16px;
    height: 16px;
    accent-color: hsl(var(--primary));
    flex-shrink: 0;
}
.secuura-share-doc-row__icon {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}
.secuura-share-doc-row__name {
    color: hsl(var(--foreground));
    font-size: 0.9375rem;
    word-break: break-all;
}

/* ----- Recipient chips ----- */
.secuura-share-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    min-height: 24px;
}
.secuura-share-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: hsl(var(--primary) / 0.15);
    color: hsl(var(--foreground));
    padding: 4px 6px 4px 10px;
    border-radius: 9999px;
    font-size: 0.8125rem;
    line-height: 1.4;
    border: 1px solid hsl(var(--primary) / 0.3);
}
.secuura-share-chip__remove {
    background: transparent;
    border: none;
    color: hsl(var(--muted-foreground));
    width: 18px;
    height: 18px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0;
}
.secuura-share-chip__remove:hover {
    color: hsl(var(--foreground));
    background-color: hsl(var(--muted));
}
.secuura-share-email-input {
    max-width: 380px;
}

/* ----- Permission + Expiry grid ----- */
.secuura-share-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 767.98px) {
    .secuura-share-grid {
        grid-template-columns: 1fr;
    }
}

/* Permission segmented control */
.secuura-share-segment {
    display: inline-flex;
    border: 1px solid hsl(var(--border));
    border-radius: 9999px;
    padding: 4px;
    background-color: hsl(var(--muted) / 0.3);
}
.secuura-share-segment-btn {
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 150ms ease, color 150ms ease;
}
.secuura-share-segment-btn--active {
    background-color: hsl(var(--card));
    color: hsl(var(--foreground));
    /* Audit Phase 7: tokenised — was rgba(0,0,0,0.1), bypassing the layer-on-top rule. */
    box-shadow: 0 1px 2px hsl(var(--foreground) / 0.1);
}

/* Expiry preset chips */
.secuura-share-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.secuura-share-preset {
    background-color: hsl(var(--muted) / 0.4);
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}
.secuura-share-preset:hover {
    background-color: hsl(var(--muted));
}
.secuura-share-preset--active {
    background-color: hsl(var(--primary) / 0.15);
    border-color: hsl(var(--primary));
    color: hsl(var(--primary));
    font-weight: 600;
}
.secuura-share-expiry-custom {
    max-width: 140px;
}

/* ----- Sticky footer ----- */
.secuura-share-footer {
    position: sticky;
    bottom: 0;
    margin-top: 16px;
    padding: 16px 0;
    background-color: hsl(var(--background));
    border-top: 1px solid hsl(var(--border));
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}
