/* TomLink Concept A — teal brand, light + dark modes */

:root,
html[data-tl-theme="light"] {
    --tl-primary: #0d9488;
    --tl-primary-hover: #0f766e;
    --tl-primary-soft: rgba(13, 148, 136, 0.12);
    --tl-bg: #f1f5f9;
    --tl-surface: #ffffff;
    --tl-surface-2: #f8fafc;
    --tl-sidebar-bg: #ffffff;
    --tl-sidebar-border: #e2e8f0;
    --tl-header-bg: #ffffff;
    --tl-header-border: #e2e8f0;
    --tl-text: #0f172a;
    --tl-text-muted: #64748b;
    --tl-nav-color: #475569;
    --tl-nav-hover: #f1f5f9;
    --tl-nav-active-bg: rgba(13, 148, 136, 0.1);
    --tl-card-border: #e2e8f0;
    --tl-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    --tl-auth-panel-bg: linear-gradient(145deg, #0d9488 0%, #14b8a6 45%, #0f766e 100%);
    --tl-auth-form-bg: #ffffff;
    --bs-primary: #0d9488;
    --bs-primary-rgb: 13, 148, 136;
}

html[data-tl-theme="dark"] {
    --tl-primary: #2dd4bf;
    --tl-primary-hover: #14b8a6;
    --tl-primary-soft: rgba(45, 212, 191, 0.15);
    --tl-bg: #0f172a;
    --tl-surface: #1e293b;
    --tl-surface-2: #334155;
    --tl-sidebar-bg: #1e293b;
    --tl-sidebar-border: #334155;
    --tl-header-bg: #1e293b;
    --tl-header-border: #334155;
    --tl-text: #f1f5f9;
    --tl-text-muted: #94a3b8;
    --tl-nav-color: #cbd5e1;
    --tl-nav-hover: #334155;
    --tl-nav-active-bg: rgba(45, 212, 191, 0.12);
    --tl-card-border: #334155;
    --tl-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    --tl-auth-panel-bg: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #134e4a 100%);
    --tl-auth-form-bg: #1e293b;
    --bs-primary: #14b8a6;
    --bs-primary-rgb: 20, 184, 166;
}

/* ── Bootstrap primary overrides ── */
html[data-tl-theme] .btn-primary {
    background-color: var(--tl-primary) !important;
    border-color: var(--tl-primary) !important;
}
html[data-tl-theme] .btn-primary:hover,
html[data-tl-theme] .btn-primary:focus {
    background-color: var(--tl-primary-hover) !important;
    border-color: var(--tl-primary-hover) !important;
}
html[data-tl-theme] .btn-light-brand {
    background: var(--tl-primary-soft) !important;
    color: var(--tl-primary) !important;
    border: 1px solid transparent;
}
html[data-tl-theme] .text-primary { color: var(--tl-primary) !important; }
html[data-tl-theme] .bg-primary { background-color: var(--tl-primary) !important; }
html[data-tl-theme] .bg-soft-primary {
    background-color: var(--tl-primary-soft) !important;
    color: var(--tl-primary) !important;
}
html[data-tl-theme] .border-primary { border-color: var(--tl-primary) !important; }
html[data-tl-theme] .avatar-text.bg-primary { background-color: var(--tl-primary) !important; }
html[data-tl-theme] .badge.bg-primary { background-color: var(--tl-primary) !important; }
html[data-tl-theme] a:not(.btn):not(.nxl-link):not(.dropdown-item) { color: var(--tl-primary); }
html[data-tl-theme] .form-check-input:checked {
    background-color: var(--tl-primary);
    border-color: var(--tl-primary);
}
html[data-tl-theme] .page-link.active,
html[data-tl-theme] .active > .page-link {
    background-color: var(--tl-primary);
    border-color: var(--tl-primary);
}

/* ── Layout shell ── */
html[data-tl-theme] body {
    background-color: var(--tl-bg) !important;
    color: var(--tl-text);
}
html[data-tl-theme] .nxl-navigation {
    background: var(--tl-sidebar-bg) !important;
    border-right: 1px solid var(--tl-sidebar-border);
}
html[data-tl-theme] .nxl-navigation .m-header {
    border-bottom: 1px solid var(--tl-sidebar-border);
}
html[data-tl-theme] .nxl-navigation .nxl-link {
    color: var(--tl-nav-color) !important;
}
html[data-tl-theme] .nxl-navigation .nxl-link:hover {
    background: var(--tl-nav-hover) !important;
    color: var(--tl-text) !important;
}
html[data-tl-theme] .nxl-navigation .nxl-item.active > .nxl-link,
html[data-tl-theme] .nxl-navigation .nxl-link.active {
    background: var(--tl-nav-active-bg) !important;
    color: var(--tl-primary) !important;
}
html[data-tl-theme] .nxl-navigation .nxl-micon i {
    color: inherit;
}
html[data-tl-theme] .nxl-navigation .nxl-caption label {
    color: var(--tl-text-muted) !important;
}
html[data-tl-theme] .nxl-header {
    background: var(--tl-header-bg) !important;
    border-bottom: 1px solid var(--tl-header-border);
}
html[data-tl-theme] .nxl-header .hamburger-inner,
html[data-tl-theme] .nxl-header .hamburger-inner::before,
html[data-tl-theme] .nxl-header .hamburger-inner::after {
    background-color: var(--tl-text);
}
html[data-tl-theme] .nxl-header a,
html[data-tl-theme] .nxl-header i {
    color: var(--tl-text-muted);
}
html[data-tl-theme] .card {
    background: var(--tl-surface);
    border-color: var(--tl-card-border);
    box-shadow: var(--tl-shadow);
}
html[data-tl-theme] .card-header {
    background: var(--tl-surface);
    border-bottom-color: var(--tl-card-border);
}
html[data-tl-theme] .table {
    --bs-table-bg: transparent;
    color: var(--tl-text);
}
html[data-tl-theme] .table-light {
    --bs-table-bg: var(--tl-surface-2);
    color: var(--tl-text);
}
html[data-tl-theme] .form-control,
html[data-tl-theme] .form-select {
    background-color: var(--tl-surface);
    border-color: var(--tl-card-border);
    color: var(--tl-text);
}
html[data-tl-theme] .form-control:focus,
html[data-tl-theme] .form-select:focus {
    border-color: var(--tl-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}
html[data-tl-theme] .dropdown-menu {
    background: var(--tl-surface);
    border-color: var(--tl-card-border);
}
html[data-tl-theme] .dropdown-item {
    color: var(--tl-text);
}
html[data-tl-theme] .dropdown-item:hover {
    background: var(--tl-nav-hover);
    color: var(--tl-text);
}
html[data-tl-theme] .dropdown-header h6,
html[data-tl-theme] .text-dark {
    color: var(--tl-text) !important;
}
html[data-tl-theme] .text-muted {
    color: var(--tl-text-muted) !important;
}
html[data-tl-theme] .modal-content {
    background: var(--tl-surface);
    color: var(--tl-text);
    border-color: var(--tl-card-border);
}
html[data-tl-theme] .list-group-item {
    background: var(--tl-surface);
    border-color: var(--tl-card-border);
    color: var(--tl-text);
}
html[data-tl-theme] .page-link {
    background: var(--tl-surface);
    border-color: var(--tl-card-border);
    color: var(--tl-text);
}
html[data-tl-theme] .btn-light {
    background: var(--tl-surface-2);
    border-color: var(--tl-card-border);
    color: var(--tl-text);
}

/* Hide default png logos when TomLink brand is active */
html[data-tl-theme] .b-brand .logo {
    display: none !important;
}

/* ── TomLink wordmark ── */
html[data-tl-theme] .tl-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--tl-text);
}
html[data-tl-theme] .tl-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--tl-primary);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
html[data-tl-theme] .tl-brand-text {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.02em;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
html[data-tl-theme] .tl-brand-compact .tl-brand-text {
    display: none;
}
html[data-tl-theme] .tl-brand-accent {
    color: var(--tl-primary);
}

/* ── Theme toggle ── */
html[data-tl-theme] .tl-theme-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--tl-card-border);
    background: var(--tl-surface-2);
    color: var(--tl-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
html[data-tl-theme] .tl-theme-toggle:hover {
    color: var(--tl-primary);
    border-color: var(--tl-primary);
}
html[data-tl-theme] .tl-theme-toggle .tl-icon-for-dark { display: none; }
html[data-tl-theme] .tl-theme-toggle .tl-icon-for-light { display: inline; }
html[data-tl-theme] .tl-theme-toggle[data-active-theme="dark"] .tl-icon-for-dark { display: inline; }
html[data-tl-theme] .tl-theme-toggle[data-active-theme="dark"] .tl-icon-for-light { display: none; }
html[data-tl-theme] .tl-auth-theme-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
}

/* ── Auth pages (Concept A split) ── */
html[data-tl-theme] .auth-cover-wrapper .auth-img img {
    display: none !important;
}
html[data-tl-theme] .auth-cover-content-inner {
    background: var(--tl-auth-panel-bg) !important;
}
html[data-tl-theme] .auth-cover-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 2rem;
}
html[data-tl-theme] .tl-auth-hero {
    max-width: 420px;
    color: #fff;
    text-align: left;
}
html[data-tl-theme] .tl-auth-hero .tl-brand-mark {
    width: 56px;
    height: 56px;
    font-size: 28px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}
html[data-tl-theme] .tl-auth-hero .tl-brand-text {
    color: #fff;
    font-size: 32px;
}
html[data-tl-theme] .tl-auth-hero .tl-brand-accent {
    color: #ccfbf1;
}
html[data-tl-theme] .tl-auth-hero p {
    margin-top: 1rem;
    opacity: 0.9;
    font-size: 15px;
    line-height: 1.6;
}
html[data-tl-theme] .auth-cover-sidebar-inner {
    background: var(--tl-bg) !important;
}
html[data-tl-theme] .auth-cover-card {
    background: var(--tl-auth-form-bg) !important;
    border: 1px solid var(--tl-card-border);
    box-shadow: var(--tl-shadow);
    border-radius: 16px !important;
}
html[data-tl-theme] .auth-cover-card .wd-50 img {
    display: none;
}

/* Mini sidebar: show compact mark only */
html[data-tl-theme] .minimenu .tl-brand-text {
    display: none;
}

@media (max-width: 991.98px) {
    html[data-tl-theme] .auth-cover-content-inner {
        min-height: 220px;
    }
    html[data-tl-theme] .tl-auth-hero {
        text-align: center;
        max-width: 100%;
    }
    html[data-tl-theme] .tl-auth-hero .tl-brand {
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE — extended fixes
   ═══════════════════════════════════════════════════════════ */

html[data-tl-theme="dark"] .nxl-container,
html[data-tl-theme="dark"] .nxl-content,
html[data-tl-theme="dark"] .main-content {
    background: transparent !important;
    color: var(--tl-text);
}

html[data-tl-theme="dark"] .page-header {
    background: transparent !important;
    border-bottom: 1px solid var(--tl-card-border);
}

html[data-tl-theme="dark"] h1,
html[data-tl-theme="dark"] h2,
html[data-tl-theme="dark"] h3,
html[data-tl-theme="dark"] h4,
html[data-tl-theme="dark"] h5,
html[data-tl-theme="dark"] h6,
html[data-tl-theme="dark"] .card-title,
html[data-tl-theme="dark"] .page-header-title h5 {
    color: var(--tl-text) !important;
}

html[data-tl-theme="dark"] .breadcrumb-item,
html[data-tl-theme="dark"] .breadcrumb-item a {
    color: var(--tl-text-muted) !important;
}
html[data-tl-theme="dark"] .breadcrumb-item.active {
    color: var(--tl-text) !important;
}

html[data-tl-theme="dark"] .card-body,
html[data-tl-theme="dark"] .card-footer {
    color: var(--tl-text);
}
html[data-tl-theme="dark"] .border-top,
html[data-tl-theme="dark"] .border-bottom,
html[data-tl-theme="dark"] .border-end,
html[data-tl-theme="dark"] .border-start {
    border-color: var(--tl-card-border) !important;
}

/* Pastel badges / avatars → dark-friendly */
html[data-tl-theme="dark"] .bg-soft-primary {
    background: rgba(45, 212, 191, 0.14) !important;
    color: #2dd4bf !important;
}
html[data-tl-theme="dark"] .bg-soft-success {
    background: rgba(74, 222, 128, 0.14) !important;
    color: #4ade80 !important;
}
html[data-tl-theme="dark"] .bg-soft-info {
    background: rgba(56, 189, 248, 0.14) !important;
    color: #38bdf8 !important;
}
html[data-tl-theme="dark"] .bg-soft-warning {
    background: rgba(251, 191, 36, 0.14) !important;
    color: #fbbf24 !important;
}
html[data-tl-theme="dark"] .bg-soft-danger {
    background: rgba(248, 113, 113, 0.14) !important;
    color: #f87171 !important;
}
html[data-tl-theme="dark"] .bg-soft-secondary {
    background: rgba(148, 163, 184, 0.14) !important;
    color: #94a3b8 !important;
}
html[data-tl-theme="dark"] .bg-white,
html[data-tl-theme="dark"] .avatar-text.bg-white {
    background: var(--tl-surface-2) !important;
    color: var(--tl-text) !important;
}
html[data-tl-theme="dark"] .bg-light {
    background: var(--tl-surface-2) !important;
    color: var(--tl-text) !important;
}

html[data-tl-theme="dark"] .text-success { color: #4ade80 !important; }
html[data-tl-theme="dark"] .text-info { color: #38bdf8 !important; }
html[data-tl-theme="dark"] .text-warning { color: #fbbf24 !important; }
html[data-tl-theme="dark"] .text-danger { color: #f87171 !important; }

/* Alerts */
html[data-tl-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
    color: #fecaca !important;
}
html[data-tl-theme="dark"] .alert-success {
    background: rgba(34, 197, 94, 0.12) !important;
    border-color: rgba(34, 197, 94, 0.35) !important;
    color: #bbf7d0 !important;
}
html[data-tl-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.12) !important;
    border-color: rgba(245, 158, 11, 0.35) !important;
    color: #fde68a !important;
}
html[data-tl-theme="dark"] .alert-info {
    background: rgba(14, 165, 233, 0.12) !important;
    border-color: rgba(14, 165, 233, 0.35) !important;
    color: #bae6fd !important;
}
html[data-tl-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1);
    opacity: 0.7;
}

/* Forms */
html[data-tl-theme="dark"] .form-control,
html[data-tl-theme="dark"] .form-select {
    background-color: #0f172a !important;
    border-color: #475569 !important;
    color: var(--tl-text) !important;
}
html[data-tl-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
    opacity: 1;
}
html[data-tl-theme="dark"] .form-label {
    color: var(--tl-text) !important;
}
html[data-tl-theme="dark"] .form-text {
    color: var(--tl-text-muted) !important;
}
html[data-tl-theme="dark"] .input-group-text {
    background: var(--tl-surface-2);
    border-color: #475569;
    color: var(--tl-text-muted);
}

/* Auth card typography */
html[data-tl-theme="dark"] .auth-cover-card h2,
html[data-tl-theme="dark"] .auth-cover-card h4,
html[data-tl-theme="dark"] .auth-cover-card .fw-bolder,
html[data-tl-theme="dark"] .auth-cover-card .fw-bold {
    color: var(--tl-text) !important;
}
html[data-tl-theme="dark"] .auth-cover-card .tl-brand-text {
    color: var(--tl-text) !important;
}
html[data-tl-theme="dark"] .auth-cover-card .tl-brand-accent {
    color: var(--tl-primary) !important;
}

/* Tables */
html[data-tl-theme="dark"] .table thead th,
html[data-tl-theme="dark"] .table-light th {
    background: var(--tl-surface-2) !important;
    color: var(--tl-text-muted) !important;
    border-color: var(--tl-card-border) !important;
}
html[data-tl-theme="dark"] .table td,
html[data-tl-theme="dark"] .table th {
    border-color: var(--tl-card-border) !important;
}
html[data-tl-theme="dark"] .table-hover tbody tr:hover {
    background: var(--tl-nav-hover) !important;
    color: var(--tl-text);
}
html[data-tl-theme="dark"] .table > :not(caption) > * > * {
    background: transparent;
    color: var(--tl-text);
}

/* Buttons */
html[data-tl-theme="dark"] .btn-outline-secondary {
    color: var(--tl-text-muted);
    border-color: #475569;
}
html[data-tl-theme="dark"] .btn-outline-secondary:hover {
    background: var(--tl-surface-2);
    color: var(--tl-text);
}
html[data-tl-theme="dark"] .btn-outline-danger {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.5);
}

/* Modals & dropdowns */
html[data-tl-theme="dark"] .modal-header,
html[data-tl-theme="dark"] .modal-footer {
    border-color: var(--tl-card-border);
}
html[data-tl-theme="dark"] .dropdown-divider {
    border-color: var(--tl-card-border);
}
html[data-tl-theme="dark"] .nxl-h-dropdown {
    background: var(--tl-surface) !important;
    border-color: var(--tl-card-border);
}

/* Code blocks (integration snippet) */
html[data-tl-theme="dark"] pre.bg-dark,
html[data-tl-theme="dark"] pre.bg-dark.text-success {
    background: #0f172a !important;
    color: #5eead4 !important;
    border: 1px solid var(--tl-card-border);
}

/* Nav tabs if any */
html[data-tl-theme="dark"] .nav-tabs {
    border-color: var(--tl-card-border);
}
html[data-tl-theme="dark"] .nav-tabs .nav-link {
    color: var(--tl-text-muted);
}
html[data-tl-theme="dark"] .nav-tabs .nav-link.active {
    background: var(--tl-surface);
    border-color: var(--tl-card-border);
    color: var(--tl-primary);
}

/* Ping summary cards — keep semantic colors readable */
html[data-tl-theme="dark"] .ping-card.active-card {
    border-color: var(--tl-primary) !important;
    box-shadow: 0 0 0 1px var(--tl-primary);
}

html[data-tl-theme="dark"] hr {
    border-color: var(--tl-card-border);
    opacity: 1;
}

html[data-tl-theme="dark"] .card.border-success {
    border-color: rgba(74, 222, 128, 0.45) !important;
}
html[data-tl-theme="dark"] .card.border-primary {
    border-color: rgba(45, 212, 191, 0.45) !important;
}
