/* =============================================================================
   LiveCompliance Design System  (.lc-*)
   -----------------------------------------------------------------------------
   Shared token block + neutral-prefixed components, per STYLE_GUIDE.md §12.2.
   Canonical sources: policy_and_procedure_editor.php (.pp-*) and
   documents.php (.doc-*). This file is ADDITIVE — existing pages keep their
   own pp-/doc-/Bootstrap classes; only deliberately refreshed pages use .lc-*.
   ============================================================================= */

:root {
    /* Brand / primary */
    --b-primary:        #1a448a;
    --b-primary-light:  #eef3fc;
    --b-primary-dark:   #0d2f66;

    /* Semantic status colors (each has a -light tint for backgrounds) */
    --b-success:        #059652;   --b-success-light: #ecfdf3;
    --b-danger:         #dc2626;   --b-danger-light:  #fef2f2;
    --b-warning:        #d97706;   --b-warning-light: #fef3c7;
    --b-purple:         #6a3fa0;   --b-purple-light:  #f5f0ff;

    /* Text */
    --b-text:           #1a2332;
    --b-text-secondary: #6b7280;
    --b-text-muted:     #9ca3af;

    /* Surfaces */
    --b-border:         #e8ecf1;
    --b-bg:             #f8f9fb;
    --b-card:           #ffffff;

    /* Shape */
    --b-radius:         16px;
    --b-radius-sm:      10px;

    /* Elevation */
    --b-shadow:        0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    --b-shadow-hover:  0 4px 20px rgba(26,68,138,0.08);

    /* Motion */
    --b-transition:    all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================
   GRADIENT STAT CARDS  (§2 — semantic naming, Documents opacities)
   ========================================================= */
.lc-stat {
    border-radius: var(--b-radius);
    padding: 22px 26px;
    color: #fff;
    position: relative; overflow: hidden;
    cursor: pointer; user-select: none;
    transition: transform 0.25s, box-shadow 0.25s;
}
.lc-stat:hover  { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,0.18); }
.lc-stat.active { box-shadow: 0 0 0 3px rgba(255,255,255,0.6) inset, 0 8px 24px rgba(0,0,0,0.18); }
.lc-stat .stat-value   { font-size: 2.2rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.5px; }
.lc-stat .stat-label   { font-size: 0.78rem; font-weight: 500; opacity: 0.9; margin-top: 4px;
                         letter-spacing: 0.4px; text-transform: uppercase; }
.lc-stat .stat-bg-icon { position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
                         opacity: 0.18; pointer-events: none; }

.lc-stat-blue   { background: linear-gradient(135deg, #1a3c7a 0%, #4a8af4 100%); }
.lc-stat-green  { background: linear-gradient(135deg, #047857 0%, #34d399 100%); }
.lc-stat-amber  { background: linear-gradient(135deg, #b45309 0%, #fbbf24 100%); }
.lc-stat-purple { background: linear-gradient(135deg, #6d28d9 0%, #a78bfa 100%); }
.lc-stat-red    { background: linear-gradient(135deg, #b91c1c 0%, #f87171 100%); }

@media (max-width: 768px) {
    .lc-stat { padding: 18px 20px; }
    .lc-stat .stat-value { font-size: 1.8rem; }
}

/* =========================================================
   CARDS / SURFACES
   ========================================================= */
.lc-card {
    background: var(--b-card);
    border: 1.5px solid var(--b-border);
    border-radius: var(--b-radius);
    box-shadow: var(--b-shadow);
}

/* =========================================================
   BUTTONS  (§4)
   ========================================================= */
.lc-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1.5px solid var(--b-border);
    background: #fff; color: var(--b-text);
    padding: 8px 16px;
    border-radius: var(--b-radius-sm);
    font-size: 0.86rem; font-weight: 500; line-height: 1.2;
    cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: all 0.2s;
}
.lc-btn:hover                { border-color: var(--b-primary); color: var(--b-primary); }
.lc-btn-primary              { background: var(--b-primary);      border-color: var(--b-primary);      color: #fff; }
.lc-btn-primary:hover        { background: var(--b-primary-dark); border-color: var(--b-primary-dark); color: #fff; }
.lc-btn-success              { background: var(--b-success); border-color: var(--b-success); color: #fff; }
.lc-btn-success:hover        { background: #047a44;          border-color: #047a44;          color: #fff; }
.lc-btn-danger               { background: var(--b-danger); border-color: var(--b-danger); color: #fff; }
.lc-btn-danger:hover         { background: #b91c1c;         border-color: #b91c1c;         color: #fff; }
.lc-btn-danger-outline       { background: #fff; border-color: var(--b-danger); color: var(--b-danger); }
.lc-btn-danger-outline:hover { background: var(--b-danger-light); border-color: var(--b-danger); color: var(--b-danger); }
.lc-btn-ghost                { background: transparent; border-color: transparent; }
.lc-btn-ghost:hover          { background: var(--b-primary-light); color: var(--b-primary); }
.lc-btn-sm                   { padding: 5px 10px; font-size: 0.78rem; }
.lc-btn:disabled, .lc-btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.lc-btn svg                  { flex-shrink: 0; }

/* Ghost icon-only action (table rows / toolbars) */
.lc-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    border: none; background: transparent; color: var(--b-text-secondary);
    cursor: pointer; padding: 0; transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.lc-icon-btn:hover        { background: var(--b-primary-light); color: var(--b-primary); }
.lc-icon-btn.danger:hover { background: var(--b-danger-light);  color: var(--b-danger); }

/* =========================================================
   STATUS CHIPS  (§5 — capitalize + letter-spacing variant)
   ========================================================= */
.lc-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 50px;
    font-size: 0.72rem; font-weight: 600; line-height: 1.3;
    text-transform: capitalize; letter-spacing: 0.2px;
}
.lc-chip.chip-primary { background: var(--b-primary-light); color: var(--b-primary); }
.lc-chip.chip-success { background: var(--b-success-light); color: var(--b-success); }
.lc-chip.chip-warning { background: var(--b-warning-light); color: var(--b-warning); }
.lc-chip.chip-danger  { background: var(--b-danger-light);  color: var(--b-danger);  }
.lc-chip.chip-purple  { background: var(--b-purple-light);  color: var(--b-purple);  }
.lc-chip.chip-muted   { background: #f3f4f6;                color: #6b7280;          }

/* =========================================================
   FILTER PILL TABS  (§5)
   ========================================================= */
.lc-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; border-radius: 50px;
    font-size: 0.82rem; font-weight: 500;
    border: 1.5px solid var(--b-border); background: #fff; color: #555;
    cursor: pointer; user-select: none; transition: all 0.2s;
}
.lc-pill:hover  { border-color: var(--b-primary); color: var(--b-primary); }
.lc-pill.active { background: var(--b-primary); border-color: var(--b-primary); color: #fff; }
.lc-pill .pill-count { background: rgba(0,0,0,0.08); border-radius: 50px;
                       padding: 1px 8px; font-size: 0.74rem; font-weight: 600; }

.lc-pill-track {
    display: inline-flex; gap: 4px;
    background: #f1f4f9; padding: 4px; border-radius: 50px;
}
.lc-pill-track .lc-pill { border-color: transparent; background: transparent; }
.lc-pill-track .lc-pill:hover  { color: var(--b-primary); }
.lc-pill-track .lc-pill.active { background: var(--b-primary); color: #fff; }

@media (max-width: 768px) {
    .lc-pill { padding: 7px 14px; font-size: 0.8rem; }
}

/* =========================================================
   FORMS  (§6)
   ========================================================= */
.lc-input, .lc-select {
    width: 100%;
    padding: 9px 14px;
    font-size: 0.9rem;
    border: 1.5px solid var(--b-border);
    border-radius: var(--b-radius-sm);
    background: #fff; color: var(--b-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.lc-input:focus, .lc-select:focus {
    outline: none; border-color: var(--b-primary);
    box-shadow: 0 0 0 3px rgba(26,68,138,0.08);
}
.lc-input.is-invalid {
    border-color: var(--b-danger);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.08);
}
.lc-input::placeholder { color: var(--b-text-muted); }

.lc-label {
    display: block; font-size: 0.82rem; font-weight: 500;
    color: var(--b-text-secondary); margin-bottom: 4px;
}

/* Search box: wrap input, absolutely-positioned muted icon at left */
.lc-search { position: relative; }
.lc-search .lc-input { padding-left: 38px; }
.lc-search svg {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--b-text-muted); pointer-events: none;
}

/* Custom checkbox (§7) */
.lc-check {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 5px;
    border: 1.5px solid #d1d5db; background: #fff;
    cursor: pointer; flex-shrink: 0; vertical-align: middle;
    display: inline-block; position: relative; margin: 0;
    transition: background 0.15s, border-color 0.15s;
}
.lc-check:checked { background: var(--b-primary); border-color: var(--b-primary); }
.lc-check:checked::after {
    content: ""; position: absolute;
    left: 5px; top: 1.5px; width: 5px; height: 9px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.lc-check:disabled { opacity: 0.5; cursor: not-allowed; }
.lc-check:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(26,68,138,0.08); }

/* Toggle / switch (§6): 36×20 track, 16×16 knob */
.lc-switch { position: relative; display: inline-block; width: 36px; height: 20px; vertical-align: middle; }
.lc-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.lc-switch .lc-switch-slider {
    position: absolute; inset: 0; cursor: pointer;
    background: #d1d5db; border-radius: 50px;
    transition: background 0.2s;
}
.lc-switch .lc-switch-slider::before {
    content: ""; position: absolute;
    width: 16px; height: 16px; left: 2px; top: 2px;
    background: #fff; border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
.lc-switch input:checked + .lc-switch-slider { background: var(--b-primary); }
.lc-switch input:checked + .lc-switch-slider::before { transform: translateX(16px); }
.lc-switch input:focus-visible + .lc-switch-slider { box-shadow: 0 0 0 3px rgba(26,68,138,0.08); }
.lc-switch input:disabled + .lc-switch-slider { opacity: 0.5; cursor: not-allowed; }

/* =========================================================
   TABLES  (§7) — opt-in via .lc-table
   Exact mirror of the canonical /documents (documents.php) .b-table look.
   ========================================================= */
.lc-table-wrap { width: 100%; overflow-x: auto; }
.lc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
}
.lc-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--b-text-secondary);
    border-bottom: 1.5px solid var(--b-border);
    background: #f8f9fb;
    white-space: nowrap;
    user-select: none;
}
.lc-table thead th.text-center { text-align: center; }
.lc-table thead th.sortable { cursor: pointer; }
.lc-table thead th.sortable:hover { color: var(--b-primary); }
.lc-table thead th .sort-icon {
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.4;
    width: 10px; height: 10px;
    transition: transform 0.2s;
}
.lc-table thead th.sort-asc .sort-icon,
.lc-table thead th.sort-desc .sort-icon { opacity: 1; color: var(--b-primary); }
.lc-table thead th.sort-desc .sort-icon { transform: rotate(180deg); }
.lc-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #f0f2f5;
    color: var(--b-text);
    vertical-align: middle;
    background: #fff;
}
.lc-table tbody tr.row-clickable { cursor: pointer; }
.lc-table tbody tr:hover td { background: #f8fafd; }
.lc-table tbody td.text-center { text-align: center; }

/* =========================================================
   DIALOGS  (§8 — ported from documents.php .doc-dlg)
   ========================================================= */
.lc-dlg-backdrop {
    position: fixed; inset: 0; z-index: 10650;
    background: rgba(15, 23, 42, 0.42);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; opacity: 0; visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}
.lc-dlg-backdrop.show { opacity: 1; visibility: visible; }
.lc-dlg {
    background: #fff; border-radius: 18px;
    width: 100%; max-width: 460px;
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.06),
        0 24px 48px -12px rgba(15, 23, 42, 0.18);
    transform: scale(0.94) translateY(10px); opacity: 0;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    overflow: hidden;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 40px);
}
.lc-dlg.size-md { max-width: 540px; }
.lc-dlg.size-lg { max-width: 640px; }
.lc-dlg-backdrop.show .lc-dlg { transform: scale(1) translateY(0); opacity: 1; }

.lc-dlg-head {
    padding: 24px 24px 0;
    display: flex; align-items: flex-start; gap: 14px;
}
.lc-dlg-icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.lc-dlg-icon.tone-primary { background: var(--b-primary-light); color: var(--b-primary); }
.lc-dlg-icon.tone-success { background: var(--b-success-light); color: var(--b-success); }
.lc-dlg-icon.tone-danger  { background: var(--b-danger-light);  color: var(--b-danger); }
.lc-dlg-icon.tone-warning { background: var(--b-warning-light); color: var(--b-warning); }
.lc-dlg-icon.tone-purple  { background: var(--b-purple-light);  color: var(--b-purple); }
.lc-dlg-titles { flex: 1; min-width: 0; padding-top: 2px; }
.lc-dlg-title {
    font-size: 1.05rem; font-weight: 700;
    color: var(--b-text); line-height: 1.35; margin: 0;
    word-wrap: break-word;
}
.lc-dlg-message {
    margin-top: 6px; font-size: 0.88rem;
    color: var(--b-text-secondary); line-height: 1.5;
}
.lc-dlg-close {
    width: 30px; height: 30px; border-radius: 8px;
    border: none; background: transparent; color: #9ca3af;
    cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.lc-dlg-close:hover { background: #f3f4f6; color: var(--b-text); }
.lc-dlg-body {
    padding: 16px 24px 0;
    overflow-y: auto;
    flex: 1; min-height: 0;
}
.lc-dlg-body:empty { padding: 0; }
.lc-dlg-foot {
    padding: 18px 24px 22px; display: flex;
    justify-content: flex-end; gap: 8px; flex-shrink: 0;
    flex-wrap: wrap;
}
.lc-dlg-foot .lc-btn { padding: 9px 18px; font-size: 0.88rem; }
.lc-dlg-error {
    margin-top: 10px; font-size: 0.83rem; color: var(--b-danger);
    background: var(--b-danger-light); border-radius: 8px;
    padding: 8px 12px; display: flex; align-items: center; gap: 8px;
}
.lc-dlg-error svg { flex-shrink: 0; }
.lc-dlg.loading-dlg { max-width: 320px; }
.lc-dlg.loading-dlg .lc-dlg-head {
    padding: 32px 24px 24px;
    flex-direction: column; align-items: center; gap: 16px;
}
.lc-dlg.loading-dlg .lc-dlg-titles { text-align: center; padding-top: 0; }
.lc-dlg.loading-dlg .lc-dlg-foot { display: none; }
.lc-dlg-spinner {
    width: 38px; height: 38px;
    border: 3px solid var(--b-primary-light);
    border-top-color: var(--b-primary);
    border-radius: 50%;
    animation: lcDlgSpin 0.7s linear infinite;
}
@keyframes lcDlgSpin { to { transform: rotate(360deg); } }

/* =========================================================
   TOASTS  (§8)
   ========================================================= */
.lc-toast-stack {
    position: fixed; top: 24px; right: 24px; z-index: 10700;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none; max-width: 380px;
}
.lc-toast {
    background: #fff; border-radius: 12px;
    min-width: 260px; max-width: 380px;
    padding: 12px 16px; display: flex; align-items: center; gap: 12px;
    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.06),
        0 12px 28px -8px rgba(15, 23, 42, 0.18);
    pointer-events: auto;
    transform: translateX(120%); opacity: 0;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.32s ease;
    border-left: 3px solid var(--b-primary);
}
.lc-toast.show { transform: translateX(0); opacity: 1; }
.lc-toast.fadeout { opacity: 0; transform: translateX(20px); }
.lc-toast.tone-success { border-left-color: var(--b-success); }
.lc-toast.tone-danger,
.lc-toast.tone-error   { border-left-color: var(--b-danger); }
.lc-toast.tone-warning { border-left-color: var(--b-warning); }
.lc-toast .toast-icon {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.lc-toast.tone-success .toast-icon { background: var(--b-success-light); color: var(--b-success); }
.lc-toast.tone-danger .toast-icon,
.lc-toast.tone-error .toast-icon   { background: var(--b-danger-light); color: var(--b-danger); }
.lc-toast.tone-warning .toast-icon { background: var(--b-warning-light); color: var(--b-warning); }
.lc-toast.tone-info .toast-icon    { background: var(--b-primary-light); color: var(--b-primary); }
.lc-toast .toast-msg { font-size: 0.9rem; color: var(--b-text); flex: 1; line-height: 1.4; }

@media (max-width: 540px) {
    .lc-dlg { max-width: 100% !important; border-radius: 14px; }
    .lc-toast-stack { right: 12px; left: 12px; top: 12px; max-width: none; }
}

/* =========================================================
   EMPTY STATE + SKELETON  (§8)
   ========================================================= */
.lc-empty { text-align: center; padding: 48px 24px; }
.lc-empty .lc-empty-icon {
    width: 54px; height: 54px; border-radius: 12px;
    background: #f3f4f6; color: var(--b-text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
.lc-empty .lc-empty-title { font-size: 0.95rem; font-weight: 600; color: var(--b-text); }
.lc-empty .lc-empty-sub   { font-size: 0.84rem; color: var(--b-text-muted); margin-top: 4px; }

.lc-skeleton {
    height: 14px; border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: lcShimmer 1.4s infinite;
}
@keyframes lcShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
