/* ============================================
   Heliox Admin Panel - Enterprise Styles
   ============================================ */

/* --- CSS Custom Properties (design tokens) --- */
:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: rgba(79, 70, 229, 0.08);
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #06b6d4;

    /* Semantic tint backgrounds + text — single source of truth for badges/pills.
       The "tint" is a ~10% alpha wash; the "fg" is a darker, AA-compliant shade. */
    --tint-primary-bg: rgba(79, 70, 229, 0.10);
    --tint-primary-fg: #4338ca;
    --tint-success-bg: rgba(16, 185, 129, 0.12);
    --tint-success-fg: #047857;
    --tint-warning-bg: rgba(245, 158, 11, 0.14);
    --tint-warning-fg: #b45309;   /* darker amber — passes AA on white */
    --tint-danger-bg: rgba(239, 68, 68, 0.12);
    --tint-danger-fg: #b91c1c;
    --tint-info-bg: rgba(6, 182, 212, 0.12);
    --tint-info-fg: #0e7490;
    --tint-neutral-bg: rgba(100, 116, 139, 0.12);
    --tint-neutral-fg: #475569;
    --tint-twitter-bg: rgba(29, 155, 240, 0.12);
    --tint-twitter-fg: #1d74bd;

    --sidebar-width: 260px;
    --header-height: 65px;
    --sidebar-dark-start: #1a1a2e;
    --sidebar-dark-end: #16213e;

    --bg-header: #ffffff;
    --bg-content: #f1f5f9;
    --bg-card: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-sidebar: linear-gradient(180deg, var(--sidebar-dark-start) 0%, var(--sidebar-dark-end) 100%);

    --text-primary: #1e293b;
    --text-secondary: #475569;   /* raised from #64748b for better contrast */
    --text-muted: #64748b;       /* raised from #94a3b8 → ~4.6:1 on white (AA) */
    --text-faint: #94a3b8;       /* truly de-emphasized text, non-essential only */
    --text-on-dark: rgba(255, 255, 255, 0.85);
    --text-on-dark-muted: rgba(255, 255, 255, 0.5);

    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-card-hover: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-header: 0 1px 3px rgba(0, 0, 0, 0.05);

    --radius-card: 12px;
    --radius-btn: 8px;
    --radius-input: 6px;

    --transition-speed: 0.2s;
    --transition-ease: ease;
}

/* --- Global Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: var(--bg-content);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-speed) var(--transition-ease);
}

a:hover {
    color: var(--color-primary-hover);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-speed) var(--transition-ease);
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- Sidebar Brand --- */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--color-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-on-dark-muted);
    margin-top: 2px;
    letter-spacing: 0.03em;
}

/* --- Sidebar Navigation --- */

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}

.sidebar-nav-section {
    display: flex;
    flex-direction: column;
}

.sidebar-nav-label {
    display: block;
    padding: 12px 24px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-on-dark-muted);
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 1px 12px;
    color: var(--text-on-dark);
    font-size: 0.875rem;
    font-weight: 400;
    border-radius: 8px;
    border-left: 3px solid transparent;
    transition: all var(--transition-speed) var(--transition-ease);
    text-decoration: none;
}

.sidebar-nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--color-primary);
    font-weight: 500;
}

/* --- Sidebar Footer --- */

.sidebar-footer {
    padding: 12px 0 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: auto;
}

.sidebar-logout {
    color: rgba(255, 255, 255, 0.55) !important;
}

.sidebar-logout:hover {
    color: var(--color-danger) !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

/* --- Sidebar Overlay (mobile) --- */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity var(--transition-speed) var(--transition-ease);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ============================================
   MAIN WRAPPER
   ============================================ */

.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) var(--transition-ease);
}

/* ============================================
   HEADER
   ============================================ */

.main-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 32px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-header);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-btn);
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-ease);
    align-items: center;
    justify-content: center;
}

.header-toggle:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.header-breadcrumb .breadcrumb {
    font-size: 0.875rem;
}

.header-breadcrumb .breadcrumb-item a {
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.header-breadcrumb .breadcrumb-item a:hover {
    color: var(--color-primary);
}

.header-breadcrumb .breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.header-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    color: var(--text-muted);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Notification Bell --- */

.header-notification {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-notification:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
    border: 2px solid var(--bg-header);
}

/* --- Header User Dropdown --- */

.header-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border: none;
    background: transparent;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-ease);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.header-user-btn:hover {
    background: var(--bg-content);
}

.header-user-btn .bi-chevron-down {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform var(--transition-speed) var(--transition-ease);
}

.header-user-btn[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.header-user-btn::after {
    display: none;
}

.header-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.8rem;
}

.header-user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.header-user .dropdown-menu {
    min-width: 180px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    box-shadow: var(--shadow-card-hover);
    padding: 4px;
}

.header-user .dropdown-item {
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 8px 12px;
}

.header-user .dropdown-item:hover {
    background: var(--bg-content);
}

.header-user .dropdown-item-text {
    padding: 8px 12px 4px;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
    flex: 1;
    padding: 24px 32px;
    min-height: calc(100vh - var(--header-height));
}

/* ============================================
   FLASH MESSAGES (Admin Alerts)
   ============================================ */

.admin-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border-radius: var(--radius-btn);
    box-shadow: var(--shadow-card);
    font-size: 0.875rem;
    transition: all var(--transition-speed) var(--transition-ease);
    border-left: 4px solid transparent;
}

.admin-alert i:first-child {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.admin-alert span {
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.75rem;
    transition: color var(--transition-speed) var(--transition-ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-close:hover {
    color: var(--text-primary);
}

.admin-alert-success {
    border-left-color: var(--color-success);
    color: var(--color-success);
}

.admin-alert-success i:first-child {
    color: var(--color-success);
}

.admin-alert-danger {
    border-left-color: var(--color-danger);
    color: var(--color-danger);
}

.admin-alert-danger i:first-child {
    color: var(--color-danger);
}

/* ============================================
   FOOTER
   ============================================ */

.main-footer {
    padding: 16px 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================================
   PAGE HEADER
   ============================================ */

/* Unified page header bar — used at the top of every list/detail page.
   Replaces ad-hoc <h4 style="color:#1e293b"> patterns. */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin: 0;
}

.page-header-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 4px 0 0;
}

/* Legacy single-element helpers kept for compatibility */
.page-header .page-title,
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   CARD HEADER ACCENT BAR
   Unified "vertical color bar + title" pattern used by dashboard/analytics.
   ============================================ */

.card-accent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-accent-header::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 2px;
    background: var(--color-primary);
    flex-shrink: 0;
}

.card-accent-header.is-success::before { background: var(--color-success); }
.card-accent-header.is-warning::before { background: var(--color-warning); }
.card-accent-header.is-info::before    { background: var(--color-info); }
.card-accent-header.is-danger::before  { background: var(--color-danger); }

.card-accent-header .card-accent-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ============================================
   BADGES & PILLS (semantic tints)
   .status-badge / .role-badge / .type-badge now share one definition.
   ============================================ */

.status-badge,
.role-badge,
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.35em 0.65em;
    border-radius: 6px;
    white-space: nowrap;
    background: var(--tint-neutral-bg);
    color: var(--tint-neutral-fg);
}

/* Modifier classes drive the tint so templates don't hardcode rgba/hex. */
.tint-primary { background: var(--tint-primary-bg); color: var(--tint-primary-fg); }
.tint-success { background: var(--tint-success-bg); color: var(--tint-success-fg); }
.tint-warning { background: var(--tint-warning-bg); color: var(--tint-warning-fg); }
.tint-danger  { background: var(--tint-danger-bg);  color: var(--tint-danger-fg); }
.tint-info    { background: var(--tint-info-bg);    color: var(--tint-info-fg); }
.tint-neutral { background: var(--tint-neutral-bg); color: var(--tint-neutral-fg); }
.tint-twitter { background: var(--tint-twitter-bg); color: var(--tint-twitter-fg); }

/* ============================================
   EMPTY STATE (global)
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--text-faint);
}

.empty-state i {
    font-size: 2.25rem;
    color: var(--border-color);
}

.empty-state p {
    margin: 10px 0 0;
    font-size: 0.9rem;
}

/* ============================================
   TABLE CELL TRUNCATION
   Replaces inline max-width/ellipsis repeated across templates.
   ============================================ */

.cell-truncate {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.cell-w-xs { max-width: 160px; }
.cell-w-sm { max-width: 240px; }
.cell-w-md { max-width: 320px; }

/* ============================================
   CONTENT CARD
   ============================================ */

.content-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border: none;
    overflow: hidden;
    transition: box-shadow var(--transition-speed) var(--transition-ease);
}

.content-card:hover {
    box-shadow: var(--shadow-card-hover);
}

.content-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.content-card > .card-body {
    padding: 20px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    border: none;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-speed) var(--transition-ease);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    border-radius: var(--radius-card) var(--radius-card) 0 0 !important;
    padding: 16px 20px;
}

.card-body {
    padding: 20px;
}

/* ============================================
   STAT CARDS  (dashboard / analytics KPIs)
   ============================================ */

.stat-card .card-body { padding: 1.25rem 1.5rem; }

.stat-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-card-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-card-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Colored left border variant for KPI cards */
.stat-card.is-accent {
    border-left-width: 4px;
    border-left-style: solid;
}
.stat-card.accent-primary { border-left-color: var(--color-primary); }
.stat-card.accent-warning { border-left-color: var(--color-warning); }
.stat-card.accent-success { border-left-color: var(--color-success); }
.stat-card.accent-info    { border-left-color: var(--color-info); }
.stat-card.accent-danger  { border-left-color: var(--color-danger); }
.stat-card.accent-violet  { border-left-color: #8b5cf6; }

/* ============================================
   QUICK ACTION CARD
   ============================================ */

.quick-action-card {
    transition: transform .15s ease, box-shadow .15s ease;
    text-decoration: none;
    border: 1px solid var(--border-color);
}

.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.quick-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* ============================================
   PIPELINE TRIGGER (primary gradient action)
   ============================================ */

.pipeline-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary), #6366f1);
    border: none;
    color: #fff;
    padding: .55rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.4;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
    white-space: nowrap;
}

.pipeline-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, .4);
    color: #fff;
}

.pipeline-trigger:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================
   CONTENT BLOCK (detail pages)
   ============================================ */

.content-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.content-block h6 {
    color: var(--color-primary);
    font-weight: 600;
    margin-bottom: .75rem;
}

.content-block pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    color: var(--text-secondary);
    font-size: .9rem;
    margin: 0;
}

/* ============================================
   TABLES
   ============================================ */

.table {
    margin-bottom: 0;
    color: var(--text-primary);
}

.table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    background: var(--bg-subtle);
    white-space: nowrap;
}

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

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

.table-hover tbody tr {
    transition: background-color var(--transition-speed) var(--transition-ease);
}

.table-hover tbody tr:hover {
    background-color: var(--color-primary-light);
}

/* ============================================
   BUTTONS (overrides)
   ============================================ */

.btn {
    border-radius: var(--radius-btn);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 16px;
    transition: all var(--transition-speed) var(--transition-ease);
}

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

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

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

.btn-outline-primary:hover {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* ============================================
   FORMS (overrides)
   ============================================ */

.form-control,
.form-select {
    border-radius: var(--radius-input);
    border-color: var(--border-color);
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: border-color var(--transition-speed) var(--transition-ease),
        box-shadow var(--transition-speed) var(--transition-ease);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.input-group-text {
    border-color: var(--border-color);
    background: var(--bg-content);
    color: var(--text-secondary);
    border-radius: var(--radius-input) 0 0 var(--radius-input);
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* ============================================
   BADGES (overrides)
   ============================================ */

.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 6px;
    letter-spacing: 0.01em;
}

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

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

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

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

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

/* ============================================
   PAGINATION
   ============================================ */

.pagination .page-link {
    border-radius: var(--radius-btn);
    margin: 0 2px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    padding: 6px 12px;
    transition: all var(--transition-speed) var(--transition-ease);
}

.pagination .page-link:hover {
    background-color: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

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

.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    background-color: var(--bg-content);
}

/* ============================================
   FILTER BAR
   Shared toolbar above list tables. Wraps gracefully on small screens.
   ============================================ */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-bar .form-select {
    max-width: 200px;
    flex: 0 1 200px;
}

.filter-bar .form-select,
.filter-bar .form-control {
    min-width: 140px;
}

/* ============================================
   ACCESSIBILITY — visible focus
   ============================================ */

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Decorative icons shouldn't be announced by screen readers (templates add aria-hidden) */
[aria-hidden="true"] {
    -webkit-user-select: none;
    user-select: none;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    body.sidebar-open {
        overflow: hidden;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .header-toggle {
        display: flex;
    }

    .main-header {
        padding: 0 16px;
    }

    .main-content {
        padding: 16px;
    }

    .main-footer {
        padding: 16px;
    }
}

@media (max-width: 575.98px) {
    .header-breadcrumb {
        display: none;
    }

    .header-user-name {
        display: none;
    }

    .header-user-btn {
        padding: 4px;
    }

    /* Page header stacks vertically and shrinks on phones */
    .page-header {
        align-items: flex-start;
    }
    .page-header-title {
        font-size: 1.25rem;
    }

    /* Filter controls go full-width stack on phones */
    .filter-bar .form-select,
    .filter-bar .form-control {
        max-width: none;
        flex: 1 1 100%;
    }
    .filter-bar .btn {
        flex: 1 1 auto;
    }

    /* Tighter table padding on phones */
    .table thead th,
    .table tbody td {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Truncation columns become wider percentage on phones */
    .cell-w-md { max-width: 200px; }
    .cell-w-sm { max-width: 160px; }

    /* Modals sit closer to top on phones */
    .modal-dialog {
        margin: 0.5rem;
    }
}

/* ============================================
   Software Notification Components
   (Toast & Confirm Modal — replaces native alert/confirm)
   ============================================ */

/* --- Toast Container --- */
.toast-stack {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100% - 32px);
}

/* --- Toast Item --- */
.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--color-primary);
    transform: translateX(120%);
    opacity: 0;
    transition: transform .3s cubic-bezier(.22,1,.36,1), opacity .3s ease;
    overflow: hidden;
}
.app-toast.show { transform: translateX(0); opacity: 1; }
.app-toast.hide { transform: translateX(120%); opacity: 0; }

.app-toast-icon {
    flex-shrink: 0;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    line-height: 1;
}
.app-toast-body {
    flex: 1;
    min-width: 0;
    font-size: .875rem;
    color: var(--text-primary);
    white-space: pre-line;
    word-break: break-word;
    padding-top: 1px;
}
.app-toast-close {
    flex-shrink: 0;
    background: none; border: none;
    color: var(--text-muted);
    font-size: .9rem;
    cursor: pointer;
    padding: 0 0 0 4px;
    line-height: 1;
}
.app-toast-close:hover { color: var(--text-primary); }

/* Toast variants */
.app-toast.toast-success { border-left-color: var(--color-success); }
.app-toast.toast-success .app-toast-icon { color: var(--color-success); }
.app-toast.toast-error   { border-left-color: var(--color-danger); }
.app-toast.toast-error   .app-toast-icon { color: var(--color-danger); }
.app-toast.toast-warning { border-left-color: var(--color-warning); }
.app-toast.toast-warning .app-toast-icon { color: var(--color-warning); }
.app-toast.toast-info    { border-left-color: var(--color-info); }
.app-toast.toast-info    .app-toast-icon { color: var(--color-info); }

/* Toast progress bar */
.app-toast-progress {
    position: absolute;
    left: 0; bottom: 0;
    height: 3px;
    background: currentColor;
    opacity: .35;
    width: 100%;
    transform-origin: left;
}

@media (max-width: 575.98px) {
    .toast-stack { right: 16px; left: 16px; max-width: none; }
}

/* --- Confirm Modal --- */
.app-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity .2s ease;
}
.app-modal-backdrop.show { opacity: 1; }

.app-modal {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: translateY(10px) scale(.97);
    transition: transform .2s cubic-bezier(.22,1,.36,1);
}
.app-modal-backdrop.show .app-modal { transform: translateY(0) scale(1); }

.app-modal-icon-wrap {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
    margin: 24px auto 0;
}
.app-modal-icon-wrap.confirm { background: rgba(79, 70, 229, .1); color: var(--color-primary); }
.app-modal-icon-wrap.danger  { background: rgba(239, 68, 68, .1); color: var(--color-danger); }
.app-modal-icon-wrap.warning { background: rgba(245, 158, 11, .1); color: var(--color-warning); }

.app-modal-body {
    padding: 16px 28px 8px;
    text-align: center;
}
.app-modal-title { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); margin: 0 0 8px; }
.app-modal-message {
    font-size: .9rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: pre-line;
    word-break: break-word;
}

.app-modal-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px 24px;
}
.app-modal-btn {
    flex: 1;
    padding: .55rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.app-modal-btn:active { transform: translateY(1px); }
.app-modal-btn-cancel {
    background: #f1f5f9;
    color: var(--text-secondary);
}
.app-modal-btn-cancel:hover { background: #e2e8f0; }
.app-modal-btn-confirm { background: var(--color-primary); color: #fff; }
.app-modal-btn-confirm:hover { background: var(--color-primary-hover); }
.app-modal-btn-confirm.danger { background: var(--color-danger); }
.app-modal-btn-confirm.danger:hover { background: #dc2626; }
