/* SkillBridge - Main Styles
 *
 * CSS variable system for per-org branding.
 * Brand colors (primary, accent, highlight) are customizable per organization.
 * Semantic colors and neutrals are fixed for consistency.
 */

/* ============================================
   CSS Variables
   ============================================ */

:root {
    /* Brand Colors (per-org customizable via context processor) */
    --brand-primary: #46062b;
    --brand-accent: #5e043b;
    --brand-highlight: #800051;

    /* Semantic Colors (fixed) */
    --color-success: #008139;
    --color-warning: #f59e0b;
    --color-error: #d9002b;
    --color-info: #6431da;

    /* Focus Ring (fixed - not per-org, uses info color for accessibility) */
    --color-focus-ring: #6431da;
    --color-focus-ring-alpha: rgba(100, 49, 218, 0.25);

    /* Neutrals (fixed) */
    --color-page-bg: #f0f0f0;
    --color-card-bg: #ffffff;
    --color-text: #232323;
    --color-text-light: #33232c;
    --color-border: #e0e0e0;
    --color-border-dark: #232323;

    /* Sidebar Variables */
    --sidebar-width: 256px;
    --sidebar-bg: var(--brand-primary);
    --sidebar-text: #ffffff;
    --sidebar-text-muted: rgba(255, 255, 255, 0.7);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: var(--brand-accent);

    /* Header */
    --header-height: 52px;
    --header-bg: var(--color-card-bg);

    /* Mobile safe area */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Typography */
    --font-family: 'Poppins', 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-heading: 'Poppins', 'Avenir', sans-serif;
    --font-size-base: 16px;
    --line-height: 1.5;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Form component tokens */
    --input-min-height: 44px;
    --form-group-gap: 1rem;
    --required-color: var(--color-error);
    --color-text-muted: #9ca3af;
    --color-surface-subtle: #f8f9fa;
    --color-surface-hover: #e9ecef;
}

/* ============================================
   Base Styles
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    font-family: var(--font-family);
    line-height: var(--line-height);
    color: var(--color-text);
    background-color: var(--color-page-bg);
    padding-top: var(--safe-top);
}

/* ============================================
   Layout: Sidebar + Main Content
   ============================================ */

.app-layout {
    min-height: 100vh;
}

.app-layout.no-sidebar .app-main {
    margin-left: 0;
}

/* Main content area */
.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
}

.app-content {
    flex: 1;
    padding: var(--spacing-lg);
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================
   Top Header (Mobile)
   ============================================ */

.app-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem var(--spacing-md);
    background: var(--header-bg);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
    position: sticky;
    top: var(--safe-top);
    z-index: 1050;
}

.app-header-title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-55%);
    text-align: center;
    font-family: var(--font-family-heading);
    font-weight: 900;
    text-transform: uppercase;
    color: var(--color-text);
    margin: 0;
    font-size: clamp(1.15rem, 4.2vw, 1.75rem);
    letter-spacing: 0.5px;
    line-height: 1;
    pointer-events: none;
}

.app-header-title::after {
    content: "";
    display: block;
    width: 60px;
    height: 3px;
    background: var(--brand-primary);
    margin: 0.2rem auto 0;
    border-radius: 2px;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    position: relative;
    z-index: 1;
    margin-left: auto;
}

/* Header button base — 28px square, transparent, border, brand hover */
.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    min-width: 28px;
    padding: 0 0.375rem;
    border-radius: var(--radius-md);
    color: var(--color-text-light);
    background: transparent;
    border: 1px solid var(--color-border);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    gap: 0.25rem;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.header-btn:hover {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}

.header-btn i {
    font-size: 0.85rem;
}

/* Icon-only variant (square) */
.header-btn-icon {
    padding: 0;
    width: 28px;
}

/* Active state (filled) */
.header-btn-active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}

/* Settings button — alias for backwards compat */
.header-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    color: var(--color-text-light);
    background: transparent;
    border: 1px solid var(--color-border);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.header-settings-btn:hover {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
}

.header-settings-btn i {
    font-size: 0.85rem;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 1023px) {
    .app-main {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 100vw;
        max-width: 320px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open + .sidebar-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-close {
        display: inline-flex;
    }

    /* Compact nav items on mobile to prevent scrollbar */
    .sidebar-nav a {
        padding: 0.35rem 0;
    }

    .sidebar-nav a i,
    .sidebar-nav a .bi {
        font-size: 1rem;
        width: 48px;
    }

    .sidebar-icon-rail {
        width: 48px;
    }

    .sidebar-profile {
        padding: 0.25rem 0;
    }
}

@media (min-width: 1024px) {
    .sidebar-toggle {
        display: none;
    }

    .sidebar-scrim {
        display: none;
    }

    .sidebar-collapse-btn {
        display: flex;
    }

    /* Show header on desktop for settings gear and page title */
    .app-header {
        display: flex;
        padding-left: var(--spacing-sm);
    }

    .app-header-title {
        font-size: 1.5rem;
    }

    /* On desktop the sidebar sits in its fixed column; app-main pushes right via
       margin-left so the sidebar never overlays content. Bootstrap modals are
       z-index 1040 (backdrop) / 1050 (dialog). Keeping sidebar at 1060 here
       caused modals to render behind it. 1030 is below the modal stack. */
    .sidebar {
        z-index: 1030;
    }
}

/* ============================================
   Bootstrap Overrides
   ============================================ */

/* Primary color overrides */
.btn-primary {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--brand-accent);
    --bs-btn-hover-border-color: var(--brand-accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-highlight);
    --bs-btn-active-border-color: var(--brand-highlight);
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-bg: var(--brand-primary);
    --bs-btn-disabled-border-color: var(--brand-primary);
    --bs-btn-disabled-color: #fff;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary);
    --bs-btn-hover-border-color: var(--brand-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-accent);
    --bs-btn-active-border-color: var(--brand-accent);
    --bs-btn-active-color: #fff;
}

/* Link color for main content */
a {
    color: var(--brand-primary);
}

a:hover {
    color: var(--brand-accent);
}

/* Ensure sidebar links always stay white - override general link styles */
.sidebar a,
.sidebar a:link,
.sidebar a:visited,
.sidebar a:hover,
.sidebar a:focus,
.sidebar a:active {
    color: var(--sidebar-text) !important;
    text-decoration: none;
}

/* Form focus states */
.form-control:focus,
.form-select:focus {
    border-color: var(--color-focus-ring);
    box-shadow: 0 0 0 0.2rem var(--color-focus-ring-alpha);
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.form-check-input:focus {
    border-color: var(--color-focus-ring);
    box-shadow: 0 0 0 0.2rem var(--color-focus-ring-alpha);
}

/* Badge variants */
.badge.bg-primary {
    background-color: var(--brand-primary) !important;
}

.badge.bg-success {
    background-color: var(--color-success) !important;
}

.badge.bg-warning {
    background-color: var(--color-warning) !important;
    color: var(--color-text) !important;
}

.badge.bg-danger {
    background-color: var(--color-error) !important;
}

.badge.bg-info {
    background-color: var(--color-info) !important;
}

/* Alert variants */
.alert-primary {
    --bs-alert-bg: rgba(70, 6, 43, 0.1);
    --bs-alert-border-color: rgba(70, 6, 43, 0.2);
    --bs-alert-color: var(--brand-primary);
}

.alert-success {
    --bs-alert-bg: rgba(0, 129, 57, 0.1);
    --bs-alert-border-color: rgba(0, 129, 57, 0.2);
    --bs-alert-color: var(--color-success);
}

.alert-warning {
    --bs-alert-bg: rgba(245, 158, 11, 0.1);
    --bs-alert-border-color: rgba(245, 158, 11, 0.2);
    --bs-alert-color: #92400e;
}

.alert-danger {
    --bs-alert-bg: rgba(217, 0, 43, 0.1);
    --bs-alert-border-color: rgba(217, 0, 43, 0.2);
    --bs-alert-color: var(--color-error);
}

.alert-info {
    --bs-alert-bg: rgba(100, 49, 218, 0.1);
    --bs-alert-border-color: rgba(100, 49, 218, 0.2);
    --bs-alert-color: var(--color-info);
}

/* Pagination */
.page-link {
    color: var(--brand-primary);
}

.page-link:hover {
    color: var(--brand-accent);
}

.page-item.active .page-link {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* Navbar brand */
.navbar-brand {
    color: var(--brand-primary);
}

/* ============================================
   Cards
   ============================================ */

.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* Clickable cards */
.card-clickable {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    color: var(--color-text);
}

.card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--color-text);
}

.card-clickable .card-title {
    color: var(--color-text);
}

.card-clickable .card-text {
    color: var(--color-text-light);
}

/* Clickable table rows */
.table-clickable tbody tr {
    transition: background-color 0.1s ease;
}

.table-clickable tbody tr:hover {
    background-color: #f8f9fa;
}

/* Links within clickable rows - make them stand out */
.table-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
}

.table-link:hover {
    text-decoration: underline;
}

/* Clickable list items */
.list-clickable .list-group-item[data-href] {
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.list-clickable .list-group-item[data-href]:hover {
    background-color: #f8f9fa;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-md);
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-md);
}

/* Stat cards (dashboard) */
.stat-card {
    padding: var(--spacing-lg);
    text-align: center;
}

.stat-card-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--brand-primary);
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   Action Dropdown - Standard inline dropdowns
   ============================================ */

.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    line-height: 1.4;
}

.action-dropdown-toggle:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.action-dropdown-toggle:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(70, 6, 43, 0.1);
}

.action-dropdown-toggle--sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.action-dropdown-toggle--outline {
    background: transparent;
}

.action-dropdown-label {
    white-space: nowrap;
}

.action-dropdown-chevron {
    width: 1rem;
    height: 1rem;
    opacity: 0.5;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.action-dropdown-chevron.rotate-180 {
    transform: rotate(180deg);
}

.action-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    min-width: 10rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 50;
    overflow: hidden;
}

.action-dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    font-size: 0.875rem;
    font-weight: 400;
    color: #374151;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-family: var(--font-family);
}

.action-dropdown-item:hover {
    background: #f3f4f6;
}

.action-dropdown-item.is-active {
    background: rgba(70, 6, 43, 0.05);
    color: var(--brand-primary);
    font-weight: 500;
}

.action-dropdown-item .bi-check2 {
    color: var(--color-success);
}

/* Status toggle buttons (like Active/Archive) */
.status-toggle {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.25rem;
}

.status-toggle__btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-light);
    border-radius: var(--radius-md);
    padding: 0 0.875rem;
    min-width: 5.5rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    height: var(--filter-ctrl-h, 36px);
    line-height: 1;
    box-sizing: border-box;
    cursor: pointer;
}

.status-toggle__btn:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.status-toggle__btn--active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.status-toggle__btn--active:hover {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

/* ============================================
   Enhanced Form Controls
   ============================================ */

/* Modern form control styling */
.form-control-modern,
.form-select-modern {
    height: 44px;
    padding: 0.625rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    color: var(--color-text);
    font-size: 0.95rem;
    font-family: var(--font-family);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control-modern:hover,
.form-select-modern:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.form-control-modern:focus,
.form-select-modern:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(70, 6, 43, 0.1);
    background: #fff;
}

.form-control-modern::placeholder {
    color: #9ca3af;
}

/* Modern select with custom chevron */
.form-select-modern {
    padding-right: 2.5rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
}

/* Enhanced Bootstrap form overrides */
.form-control,
.form-select {
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:hover,
.form-select:hover {
    border-color: #9ca3af;
}

/* Form labels */
.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

/* Form help text */
.form-text {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.35rem;
}

/* Input groups */
.input-group-modern {
    display: flex;
    align-items: stretch;
}

.input-group-modern .form-control-modern {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group-modern .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Form card container */
.form-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    padding: 1.5rem;
}

.form-card-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

/* Color picker enhancement */
.form-control-color {
    width: 44px;
    height: 44px;
    padding: 4px;
    border-radius: 8px;
    cursor: pointer;
}

.form-control-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.form-control-color::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Checkbox and radio enhancements */
.form-check-input {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 4px;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.form-check-label {
    font-size: 0.95rem;
    cursor: pointer;
}

/* Switch toggle (Bootstrap style enhanced) */
.form-switch .form-check-input {
    width: 2.5rem;
    height: 1.35rem;
    border-radius: 999px;
    background-color: #e5e7eb;
    border: none;
    transition: background-color 0.2s ease;
}

.form-switch .form-check-input:checked {
    background-color: var(--brand-primary);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(70, 6, 43, 0.15);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--color-text-light);
    margin-bottom: var(--spacing-md);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
}

.empty-state-message {
    color: var(--color-text-light);
    margin-bottom: var(--spacing-lg);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   Status Badges
   ============================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-badge--active,
.status-badge--confirmed,
.status-badge--assigned {
    background: rgba(0, 129, 57, 0.1);
    color: var(--color-success);
}

.status-badge--pending,
.status-badge--draft {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
}

.status-badge--cancelled,
.status-badge--declined,
.status-badge--inactive {
    background: rgba(217, 0, 43, 0.1);
    color: var(--color-error);
}

.status-badge--open,
.status-badge--published {
    background: rgba(100, 49, 218, 0.1);
    color: var(--color-info);
}

/* ============================================
   Tables
   ============================================ */

.table {
    --bs-table-bg: var(--color-card-bg);
}

.table > thead {
    background: var(--color-page-bg);
}

.table > thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-light);
    border-bottom-width: 1px;
}

.table-hover > tbody > tr:hover {
    --bs-table-hover-bg: rgba(0, 0, 0, 0.02);
}

/* Responsive table wrapper */
.table-responsive {
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

/* ============================================
   Loading States (Alpine.js)
   ============================================ */

.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn .loading-spinner {
    margin-right: 0.5rem;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-border) 25%, var(--color-page-bg) 50%, var(--color-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Accessibility
   ============================================ */

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Visually hidden until focused (for skip links) */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible styles */
:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--brand-primary);
    color: white;
    border-radius: var(--radius-md);
    z-index: 9999;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--spacing-md);
}

/* ============================================
   Utilities
   ============================================ */

.text-brand { color: var(--brand-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.text-info { color: var(--color-info); }
.text-muted { color: var(--color-text-light); }

.bg-brand { background-color: var(--brand-primary); }
.bg-brand-accent { background-color: var(--brand-accent); }
.bg-brand-highlight { background-color: var(--brand-highlight); }

.border-brand { border-color: var(--brand-primary); }

/* Avatar helper */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: 50%;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-xs {
    width: 20px;
    height: 20px;
    font-size: 0.55rem;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

.bg-brand-light {
    background-color: rgba(70, 6, 43, 0.1);
}

/* ============================================
   Icon Copy Button (click-to-copy)
   ============================================ */

.btn-icon-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-light);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-icon-copy:hover {
    background: var(--brand-primary);
    color: #fff;
}

.btn-icon-copy:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* ============================================
   Scroll Sentinel (for infinite scroll)
   ============================================ */

.scroll-sentinel {
    height: 1px;
    width: 100%;
    visibility: hidden;
}

.scroll-status {
    text-align: center;
    padding: var(--spacing-md);
}

/* ============================================
   Sidebar Desktop (show collapse button)
   ============================================ */

@media (min-width: 1024px) {
    .sidebar-collapse-btn {
        display: flex;
    }
}

/* ============================================
   Sidebar Collapsed State (Desktop)
   Icon rail pattern: only sidebar width changes.
   Icons sit in fixed 56px columns and never move.
   Text clips naturally via overflow: hidden on .sidebar.
   ============================================ */

@media (min-width: 1024px) {
    .app-layout.sidebar-collapsed .app-main {
        margin-left: 56px;
    }

    .app-layout.sidebar-collapsed .sidebar {
        width: 56px;
        overflow: hidden;
    }

    /* Hide elements that would cause layout issues or overlap */
    .app-layout.sidebar-collapsed .sidebar-org-toggle,
    .app-layout.sidebar-collapsed .sidebar-org-dropdown {
        display: none;
    }

    /* Footer actions: center the collapse button, hide admin icons */
    .app-layout.sidebar-collapsed .sidebar-footer-actions {
        justify-content: center;
    }

    .app-layout.sidebar-collapsed .sidebar-footer-actions a,
    .app-layout.sidebar-collapsed .sidebar-footer-actions button[aria-label="Settings"] {
        display: none;
    }

    .app-layout.sidebar-collapsed .sidebar-impersonate-toggle {
        display: none;
    }

    /* Collapsed: settings button aligns with logo center (28px in 56px rail) */
    .app-layout.sidebar-collapsed .header-settings-btn {
        margin-left: calc(28px - 14px - var(--spacing-sm));
    }

}

/* ============================================
   Reduced Motion Support
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .toast {
        transform: none;
        opacity: 1;
    }

    .toast-show {
        transform: none;
    }

    .toast-hiding {
        transform: none;
        opacity: 0;
    }
}

/* ============================================
   High Contrast Mode Support
   ============================================ */

@media (prefers-contrast: more) {
    :root {
        --color-border: #232323;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
    }

    .card,
    .filter-bar {
        border-width: 2px;
    }

    .btn {
        border-width: 2px;
    }

    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline-width: 3px;
    }
}

/* ============================================
   Form Loading State
   ============================================ */

.form-loading {
    pointer-events: none;
    opacity: 0.7;
}

.form-loading input,
.form-loading select,
.form-loading textarea {
    background-color: var(--color-page-bg);
}

.form-error {
    margin-bottom: var(--spacing-md);
}

/* ============================================
   HTMX Indicators
   ============================================ */

/* Hide indicators by default */
.htmx-indicator {
    display: none;
}

/* Show indicator when htmx is requesting */
.htmx-request .htmx-indicator {
    display: inline-block;
}

/* Hide the normal icon when loading */
.htmx-request .submit-icon {
    display: none;
}

/* Disable button during request */
.htmx-request {
    pointer-events: none;
    opacity: 0.7;
}

/* ============================================
   Sortable (SortableJS)
   ============================================ */

/* Ghost element during drag */
.sortable-ghost {
    opacity: 0.4;
    background-color: var(--bs-light, #f8f9fa);
}

/* Element being dragged (chosen) */
.sortable-chosen {
    background-color: var(--color-card-bg);
}

/* Element while being dragged (in motion) */
.sortable-drag {
    opacity: 0.9;
}

/* Drag handle styling */
.drag-handle {
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle:hover {
    color: var(--bs-primary, var(--brand-primary)) !important;
}

/* Skill card 3-dot options menu (positioned in top-right of card) */
.skill-card-menu {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
}

.skill-card-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    background: none;
    border: none;
    border-radius: var(--radius-sm, 0.25rem);
    color: var(--color-text-muted, #6c757d);
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.15s, background-color 0.15s;
}

.skill-card-menu-btn:hover {
    opacity: 1;
    background: var(--color-bg-subtle, rgba(0, 0, 0, 0.05));
}

.skill-card-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 140px;
    background: var(--color-card-bg, #fff);
    border: 1px solid var(--color-border, #dee2e6);
    border-radius: var(--radius-md, 0.375rem);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
    padding: 0.25rem 0;
    z-index: 100;
}

.skill-card-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.4rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--color-text, #212529);
    white-space: nowrap;
}

.skill-card-menu-item:hover {
    background: var(--color-bg-subtle, rgba(0, 0, 0, 0.05));
}

/* Level breakdown badges in skill cards */
.skill-level-badges {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

/* Elevate card above neighbors so tooltip isn't hidden behind adjacent cards.
   The card-clickable transform creates a stacking context that traps the tooltip. */
.card:has(.skill-level-badge:hover) {
    z-index: 3;
}

.skill-level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
}

.skill-level-badge-1 {
    background-color: color-mix(in srgb, var(--color-info, #0dcaf0) 15%, transparent);
    color: var(--color-info, #0dcaf0);
}

.skill-level-badge-2 {
    background-color: color-mix(in srgb, var(--color-primary, #0d6efd) 15%, transparent);
    color: var(--color-primary, #0d6efd);
}

.skill-level-badge-3 {
    background-color: color-mix(in srgb, var(--color-success, #198754) 15%, transparent);
    color: var(--color-success, #198754);
}

/* ============================================
   Home Page — Community Banner (CTA)
   ============================================ */
.home-community-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    border-radius: 16px;
    background: linear-gradient(135deg, #111827 0%, #1e293b 100%);
    position: relative;
    overflow: hidden;
}

/* Subtle accent glow in top-right corner */
.home-community-banner::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -10%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

/* Left: value proposition */
.home-community-text {
    flex: 1;
    min-width: 0;
    position: relative;
}

.home-community-headline {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: #f9fafb;
    line-height: 1.35;
}

.home-community-desc {
    margin: 0.3rem 0 0;
    font-size: 0.85rem;
    color: #9ca3af;
    line-height: 1.5;
}

/* Right: CTA pill (is an <a> link) */
.home-community-cta {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-shrink: 0;
    background: #fff;
    border-radius: 12px;
    padding: 0.75rem 1.35rem;
    white-space: nowrap;
    position: relative;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(165, 180, 252, 0.35), 0 0 6px rgba(255, 255, 255, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-community-cta:hover {
    transform: scale(1.05);
    box-shadow: 0 0 28px rgba(165, 180, 252, 0.5), 0 0 10px rgba(255, 255, 255, 0.2);
    color: inherit;
    text-decoration: none;
}

.home-community-join {
    font-size: 1.5rem;
    font-weight: 700;
    color: #374151;
}

/* Skool brand colors per letter */
.skool-brand {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

.skool-s { color: #1a3b6e; }
.skool-k { color: #c44230; }
.skool-o1 { color: #d4a74b; }
.skool-o2 { color: #5ba8d6; }
.skool-l { color: #c44230; }

.home-community-arrow {
    font-size: 1.35rem;
    color: #9ca3af;
    margin-left: 0.25rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.home-community-cta:hover .home-community-arrow {
    transform: translateX(3px);
    color: #374151;
}

@media (max-width: 576px) {
    .home-community-banner {
        flex-direction: column;
        padding: 1.5rem 1.25rem;
        gap: 1.25rem;
        text-align: center;
    }

    .home-community-cta {
        align-self: center;
    }
}
