:root {
    --ta-primary: #4f46e5;
    --ta-primary-dark: #4338ca;
    --ta-sidebar-bg: #111827;
    --ta-sidebar-text: #9ca3af;
    --ta-sidebar-active: #ffffff;
    --ta-body-bg: #f1f5f9;
    --ta-card-bg: #ffffff;
    --ta-text: #1f2937;
    --ta-muted: #6b7280;
    --ta-border: #e5e7eb;
}

[data-theme="dark"] {
    --ta-body-bg: #0b1220;
    --ta-card-bg: #111827;
    --ta-text: #e5e7eb;
    --ta-muted: #9ca3af;
    --ta-border: #1f2937;
    --ta-sidebar-bg: #0a0f1c;
}

* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: var(--ta-body-bg);
    color: var(--ta-text);
    transition: background .2s ease, color .2s ease;
}

/* ---------- Layout shell ---------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--ta-sidebar-bg);
    color: var(--ta-sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
    overflow-y: auto;
}

.sidebar .brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar .brand .logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--ta-primary), #06b6d4);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.1rem;
}

.sidebar .nav-section {
    padding: 1rem 1.5rem .35rem;
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #4b5563;
}

.sidebar .nav-link {
    color: var(--ta-sidebar-text);
    padding: .7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .85rem;
    font-size: .92rem;
    border-left: 3px solid transparent;
    transition: all .15s ease;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

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

.sidebar .nav-link.active {
    color: var(--ta-sidebar-active);
    background: rgba(79, 70, 229, .15);
    border-left-color: var(--ta-primary);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 64px;
    background: var(--ta-card-bg);
    border-bottom: 1px solid var(--ta-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.page-body {
    padding: 1.75rem;
    flex: 1;
    min-width: 0;
    overflow-x: clip;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1035;
}

.sidebar-backdrop.show {
    display: block;
}

/* ---------- Cards ---------- */
.card {
    background: var(--ta-card-bg);
    border: 1px solid var(--ta-border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .03);
    color: var(--ta-text);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--ta-border);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.stat-card {
    border-radius: 16px;
    padding: 1.35rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px -12px rgba(0, 0, 0, .35);
}

.stat-card .stat-icon {
    position: absolute;
    right: -8px;
    bottom: -12px;
    font-size: 4.5rem;
    opacity: .18;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: .85rem;
    opacity: .9;
}

.bg-grad-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.bg-grad-blue   { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.bg-grad-amber  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-grad-green  { background: linear-gradient(135deg, #10b981, #059669); }
.bg-grad-red    { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.bg-grad-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.bg-grad-slate  { background: linear-gradient(135deg, #64748b, #475569); }

.page-header-gradient {
    background: linear-gradient(120deg, var(--ta-primary), #06b6d4);
    color: #fff;
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
}

/* ---------- Misc ---------- */
.table > :not(caption) > * > * {
    color: var(--ta-text);
}

.text-muted-2 {
    color: var(--ta-muted) !important;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.progress {
    background: var(--ta-border);
    height: 8px;
    border-radius: 999px;
}

.progress-bar {
    transition: width .8s ease;
}

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

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

.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--ta-border);
    background: var(--ta-card-bg);
    color: var(--ta-text);
}

.form-control:focus, .form-select:focus {
    border-color: var(--ta-primary);
    box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15);
    background: var(--ta-card-bg);
    color: var(--ta-text);
}

.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-info    { background: #dbeafe; color: #1e40af; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-danger  { background: #fee2e2; color: #991b1b; }
.badge-soft-orange  { background: #ffedd5; color: #c2410c; }
.badge-soft-secondary { background: #e5e7eb; color: #374151; }

.timeline {
    list-style: none;
    padding-left: 1rem;
    border-left: 2px solid var(--ta-border);
    margin-left: .5rem;
}

.timeline li {
    position: relative;
    padding: 0 0 1.25rem 1.25rem;
}

.timeline li::before {
    content: '';
    position: absolute;
    left: -1.45rem;
    top: .2rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ta-primary);
    border: 2px solid var(--ta-card-bg);
}

/* ---------- Auth ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}

/* ===== Left illustration panel with animated gradient + floating blobs ===== */
.auth-illustration {
    background: linear-gradient(135deg, #4f46e5, #7c3aed, #06b6d4, #4f46e5);
    background-size: 300% 300%;
    animation: authGradient 16s ease infinite;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}
@keyframes authGradient {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Soft floating blobs */
.auth-illustration::before,
.auth-illustration::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    animation: authFloat 11s ease-in-out infinite;
    pointer-events: none;
}
.auth-illustration::after {
    width: 480px;
    height: 480px;
    bottom: -180px;
    right: -120px;
}
.auth-illustration::before {
    width: 260px;
    height: 260px;
    top: -90px;
    left: -80px;
    background: rgba(255, 255, 255, .10);
    animation-delay: -4s;
}
@keyframes authFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(18px, -26px) scale(1.06); }
}

/* Decorative grid dots */
.auth-illustration .auth-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, .14) 1.5px, transparent 1.5px);
    background-size: 26px 26px;
    opacity: .5;
    z-index: 1;
    pointer-events: none;
    mask-image: radial-gradient(circle at 30% 30%, #000, transparent 75%);
    -webkit-mask-image: radial-gradient(circle at 30% 30%, #000, transparent 75%);
}

/* Entrance animation for the illustration content */
.auth-illustration .auth-brand,
.auth-illustration .auth-copy { animation: authFadeUp .7s ease both; }
.auth-illustration .auth-copy { animation-delay: .12s; }
.auth-illustration .auth-feature {
    opacity: 0;
    animation: authFadeUp .55s ease forwards;
}
.auth-illustration .auth-feature:nth-child(1) { animation-delay: .30s; }
.auth-illustration .auth-feature:nth-child(2) { animation-delay: .42s; }
.auth-illustration .auth-feature:nth-child(3) { animation-delay: .54s; }
.auth-illustration .auth-feature i { transition: transform .2s ease; }
.auth-illustration .auth-feature:hover i { transform: scale(1.25); }

@keyframes authFadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Right form panel ===== */
.auth-form-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--ta-body-bg);
    position: relative;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--ta-card-bg);
    border: 1px solid var(--ta-border);
    border-radius: 22px;
    padding: 2.5rem;
    box-shadow: 0 25px 55px -25px rgba(0, 0, 0, .35);
    animation: authCardIn .65s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes authCardIn {
    from { opacity: 0; transform: translateY(24px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered reveal of the form content */
.auth-anim > * {
    opacity: 0;
    animation: authFadeUp .5s ease forwards;
}
.auth-anim > *:nth-child(1) { animation-delay: .15s; }
.auth-anim > *:nth-child(2) { animation-delay: .22s; }
.auth-anim > *:nth-child(3) { animation-delay: .30s; }
.auth-anim > *:nth-child(4) { animation-delay: .38s; }
.auth-anim > *:nth-child(5) { animation-delay: .46s; }
.auth-anim > *:nth-child(6) { animation-delay: .54s; }

/* Inputs: rounded + animated focus glow */
.auth-card .input-group-text {
    background: var(--ta-card-bg);
    border-color: var(--ta-border);
    color: var(--ta-muted);
}
.auth-card .form-control {
    border-color: var(--ta-border);
    padding-top: .6rem;
    padding-bottom: .6rem;
}
.auth-card .input-group:focus-within {
    box-shadow: 0 0 0 .22rem rgba(79, 70, 229, .15);
    border-radius: 10px;
    transition: box-shadow .2s ease;
}
.auth-card .input-group:focus-within .input-group-text {
    color: var(--ta-primary);
}

/* Sign-in button: gradient + hover lift + shine sweep */
.auth-card .btn-primary {
    background: linear-gradient(120deg, var(--ta-primary), #06b6d4);
    border: 0;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}
.auth-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -10px rgba(79, 70, 229, .7);
}
.auth-card .btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .35), transparent);
    transform: skewX(-20deg);
}
.auth-card .btn-primary:hover::after {
    animation: authShine .8s ease;
}
@keyframes authShine {
    to { left: 140%; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-illustration,
    .auth-illustration::before,
    .auth-illustration::after,
    .auth-card,
    .auth-anim > *,
    .auth-illustration .auth-brand,
    .auth-illustration .auth-copy,
    .auth-illustration .auth-feature {
        animation: none !important;
        opacity: 1 !important;
    }
}

@media (max-width: 991.98px) {
    .auth-wrapper {
        grid-template-columns: 1fr;
    }
    .auth-illustration {
        display: none;
    }
}

/* ============ Collapsible sidebar ============ */
.sidebar {
    transition: width .25s ease, transform .25s ease;
}

.collapse-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, .08);
    border: none;
    color: #cbd5e1;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    transition: background .15s ease, transform .25s ease;
    flex-shrink: 0;
}

.collapse-btn:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

/* Collapsed state (desktop only) */
@media (min-width: 992px) {
    .sidebar-collapsed .sidebar {
        width: 78px;
    }
    .sidebar-collapsed .main-content {
        margin-left: 78px;
    }
    .sidebar-collapsed .sidebar .brand {
        justify-content: center;
        padding: 1.25rem .5rem;
    }
    .sidebar-collapsed .sidebar .brand-text,
    .sidebar-collapsed .sidebar .nav-text,
    .sidebar-collapsed .sidebar .nav-section {
        display: none;
    }
    .sidebar-collapsed .collapse-btn {
        position: absolute;
        top: 18px;
        right: 14px;
        margin-left: 0;
    }
    .sidebar-collapsed .sidebar .brand {
        position: relative;
    }
    .sidebar-collapsed #collapseIcon {
        transform: rotate(180deg);
    }
    .sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        padding: .8rem 0;
    }
    .sidebar-collapsed .sidebar .nav-link i {
        font-size: 1.1rem;
    }
    .sidebar-collapsed .sidebar-footer .btn {
        padding-left: 0;
        padding-right: 0;
    }

    /* Hover tooltips when collapsed */
    .sidebar-collapsed .sidebar [data-tip] {
        position: relative;
    }
    .sidebar-collapsed .sidebar [data-tip]:hover::after {
        content: attr(data-tip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 12px;
        background: #1f2937;
        color: #fff;
        padding: .35rem .65rem;
        border-radius: 8px;
        font-size: .8rem;
        white-space: nowrap;
        z-index: 1060;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    }
    .sidebar-collapsed .sidebar [data-tip]:hover::before {
        content: '';
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 5px;
        border: 6px solid transparent;
        border-right-color: #1f2937;
        z-index: 1060;
    }
}

/* On mobile, hide the collapse button (off-canvas is used instead) */
@media (max-width: 991.98px) {
    .collapse-btn {
        display: none;
    }
}

/* ============ Animations ============ */
@keyframes ta-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    opacity: 0;
    animation: ta-fade-up .55s cubic-bezier(.21, 1, .36, 1) forwards;
}

/* Hover lift on cards */
.stat-card {
    transition: transform .25s ease, box-shadow .25s ease;
    cursor: default;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 35px -14px rgba(0, 0, 0, .45);
}
.stat-card .stat-icon {
    transition: transform .35s ease, opacity .25s ease;
}
.stat-card:hover .stat-icon {
    transform: scale(1.15) rotate(-6deg);
    opacity: .28;
}

.dash-card {
    transition: transform .2s ease, box-shadow .2s ease;
}
.dash-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px -16px rgba(0, 0, 0, .25);
}

/* Spinning hint for in-progress icon */
@keyframes ta-spin-slow { to { transform: rotate(360deg); } }
.spin-slow { animation: ta-spin-slow 3.5s linear infinite; }

/* Gradient header subtle shine */
.page-header-gradient {
    background-size: 160% 160%;
    animation: ta-shift 8s ease infinite;
}
@keyframes ta-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .animate-in, .page-header-gradient, .spin-slow { animation: none; opacity: 1; }
}

/* ============ DataTables ============ */
.dt-container {
    padding: 1rem 1.25rem;
    max-width: 100%;
    overflow-x: auto;
}
.dt-container .dt-search,
.dt-container .dt-length {
    margin-bottom: 1rem;
}
.dt-container .dt-search input {
    min-width: 220px;
    margin-left: .5rem;
}
.dt-container .dt-info {
    color: var(--ta-muted);
    font-size: .85rem;
    padding-top: 1rem;
}
.dt-container .dt-length select {
    width: auto;
    display: inline-block;
}
table.dataTable thead th {
    border-bottom: 1px solid var(--ta-border);
    white-space: nowrap;
}
.dt-container .dt-paging {
    padding-top: 1rem;
}

/* Dark theme pagination */
[data-theme="dark"] .page-link {
    background: var(--ta-card-bg);
    border-color: var(--ta-border);
    color: var(--ta-text);
}
[data-theme="dark"] .page-item.active .page-link {
    background: var(--ta-primary);
    border-color: var(--ta-primary);
    color: #fff;
}
[data-theme="dark"] .page-item.disabled .page-link {
    background: var(--ta-card-bg);
    color: var(--ta-muted);
}

/* ============ SweetAlert2 (dark theme) ============ */
[data-theme="dark"] .swal2-popup {
    background: var(--ta-card-bg);
    color: var(--ta-text);
}
[data-theme="dark"] .swal2-title,
[data-theme="dark"] .swal2-html-container {
    color: var(--ta-text);
}
.swal2-popup {
    border-radius: 16px;
}

/* ============ Filter bar ============ */
.filter-bar .form-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ta-muted);
    margin-bottom: .25rem;
    font-weight: 600;
}
.filter-bar .input-icon {
    position: relative;
}
.filter-bar .input-icon i {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ta-muted);
    font-size: .85rem;
    pointer-events: none;
}
.filter-bar .input-icon .form-control {
    padding-left: 2.1rem;
}

/* Priority dots for select options / legends */
.prio-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: .35rem;
}
.prio-critical { background: #e11d48; }
.prio-high     { background: #f97316; }
.prio-medium   { background: #f59e0b; }
.prio-low      { background: #10b981; }
.prio-very_low { background: #94a3b8; }

.badge-soft-orange { background: #ffedd5; color: #c2410c; }

/* Form section heading inside cards */
.form-section-title {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ta-muted);
    font-weight: 700;
    margin: 0 0 .25rem;
}
.form-card-head {
    background: linear-gradient(120deg, var(--ta-primary), #06b6d4);
    color: #fff;
    border-radius: 16px;
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

/* Gradient modal header */
.modal-header-grad {
    background: linear-gradient(120deg, var(--ta-primary), #06b6d4);
    border: 0;
}
.modal-header-grad .modal-title { color: #fff; }
.modal-header-grad .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: .9;
}
.modal-content {
    border-radius: 16px;
    overflow: hidden;
    background: var(--ta-card-bg);
    color: var(--ta-text);
}

/* ============ Right-side slide-in drawer (offcanvas) ============ */
.task-drawer {
    width: min(760px, 96vw) !important;
    background: var(--ta-card-bg);
    color: var(--ta-text);
    border-left: 0;
    box-shadow: -16px 0 50px -24px rgba(0, 0, 0, .45);
}
.task-drawer .drawer-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.task-drawer .offcanvas-header {
    flex: 0 0 auto;
    padding: 1.05rem 1.4rem;
}
.task-drawer .offcanvas-header .offcanvas-title {
    color: #fff;
}
.task-drawer .offcanvas-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.4rem;
}
.task-drawer .drawer-footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--ta-border);
    background: var(--ta-card-bg);
}
/* Quill inside the drawer should never overflow horizontally */
.task-drawer .ql-toolbar.ql-snow,
.task-drawer .ql-container.ql-snow {
    max-width: 100%;
}

/* ============ Trackit brand in the topbar ============ */
.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: .2px;
    color: var(--ta-text);
    white-space: nowrap;
}
.topbar-brand i {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: .85rem;
    color: #fff;
    background: linear-gradient(135deg, var(--ta-primary), #06b6d4);
}

/* ============ App footer ============ */
.app-footer {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .85rem 1.75rem;
    background: var(--ta-card-bg);
    border-top: 1px solid var(--ta-border);
    color: var(--ta-muted);
    font-size: .82rem;
}
.app-footer-brand {
    font-weight: 600;
    color: var(--ta-text);
}
.app-footer-credit strong {
    color: var(--ta-primary);
}

/* ============ Auth (login) footer credit ============ */
.auth-credit {
    text-align: center;
    margin: 1.25rem 0 0;
    font-size: .82rem;
    color: var(--ta-muted);
}
.auth-credit strong {
    color: var(--ta-primary);
}
