/* =====================================================================
   Bug Tracker - design system
   Built on Bootstrap 5.3. Colours are defined once here as variables.
   ===================================================================== */

:root {
    --bt-primary: #4f46e5;          /* indigo - buttons, links, active menu */
    --bt-primary-hover: #4338ca;
    --bt-primary-soft: #eef2ff;
    --bt-bg: #f5f6fa;               /* page background */
    --bt-surface: #ffffff;          /* cards */
    --bt-border: #e5e7eb;
    --bt-text-muted: #6b7280;
    --bt-radius: 0.75rem;
    --bt-sidebar-width: 250px;
    --bt-navbar-height: 60px;

    /* Make Bootstrap use our primary colour */
    --bs-primary: var(--bt-primary);
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: var(--bt-primary);
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: var(--bt-primary-hover);
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-border-radius: 0.5rem;
}

body {
    background: var(--bt-bg);
}
/* Login, sign-up and error pages: soft indigo backdrop behind the card */
body.auth-body {
    background:
        radial-gradient(circle at 10% 10%, #e0e7ff 0, transparent 40%),
        radial-gradient(circle at 90% 90%, #ede9fe 0, transparent 40%),
        var(--bt-bg);
}

.btn-primary {
    --bs-btn-bg: var(--bt-primary);
    --bs-btn-border-color: var(--bt-primary);
    --bs-btn-hover-bg: var(--bt-primary-hover);
    --bs-btn-hover-border-color: var(--bt-primary-hover);
    --bs-btn-active-bg: var(--bt-primary-hover);
    --bs-btn-active-border-color: var(--bt-primary-hover);
    --bs-btn-disabled-bg: var(--bt-primary);
    --bs-btn-disabled-border-color: var(--bt-primary);
}

/* Bootstrap's grey outline button is only 4.39:1 on our page background;
   a darker grey passes WCAG AA (4.5:1) on both the page and white cards. */
.btn-outline-secondary {
    --bs-btn-color: #4b5563;
    --bs-btn-border-color: #9ca3af;
    --bs-btn-hover-bg: #4b5563;
    --bs-btn-hover-border-color: #4b5563;
    --bs-btn-active-bg: #374151;
    --bs-btn-active-border-color: #374151;
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.2);
}

.card {
    border: 1px solid var(--bt-border);
    border-radius: var(--bt-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.skip-link:focus {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2000;
    background: var(--bt-surface);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ----- Brand ------------------------------------------------------- */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: var(--bt-primary);
    color: #fff;
    font-size: 1rem;
}
.brand-mark-lg {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.9rem;
    font-size: 1.5rem;
}

/* ----- Illustrations and branding ---------------------------------- */
.brand-logo { width: 2rem; height: 2rem; }
.empty-illustration {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    margin: 0 auto 0.75rem;
}
.empty-illustration-sm { display: block; width: 110px; height: auto; margin: 0 auto; }
.error-illustration { width: 100%; max-width: 240px; height: auto; }
.error-card { max-width: 480px; }

/* Split login / sign-up: illustrated brand panel + form */
.auth-shell {
    display: flex;
    width: 100%;
    max-width: 1080px;
    min-height: 620px;
    background: var(--bt-surface);
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(30, 27, 75, 0.14);
}
.auth-aside {
    flex: 0 0 46%;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    color: #fff;
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.14), transparent 45%),
        linear-gradient(150deg, #4f46e5 0%, #4338ca 55%, #312e81 100%);
}
.auth-logo { width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); }
.auth-logo-lg { width: 3.5rem; height: 3.5rem; }
.auth-headline { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-bottom: 0.75rem; }
.auth-lead { color: rgba(255, 255, 255, 0.82); margin-bottom: 0; }
.auth-hero { width: 100%; max-width: 400px; height: auto; align-self: center; }
.auth-features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
    color: rgba(255, 255, 255, 0.92);
}
.auth-features i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}
.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}
.auth-form-inner { width: 100%; max-width: 400px; }
.auth-form-inner.auth-form-wide { max-width: 520px; }
.demo-box {
    border: 1px dashed #c7d2fe;
    background: var(--bt-primary-soft);
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
}
@media (max-width: 991.98px) {
    .auth-shell { min-height: 0; max-width: 560px; }
}

/* Dashboard welcome banner */
.welcome-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.75rem 2rem;
    border-radius: 1rem;
    color: #fff;
    overflow: hidden;
    background:
        radial-gradient(circle at 85% 10%, rgba(255, 255, 255, 0.16), transparent 40%),
        linear-gradient(120deg, #4f46e5 0%, #4338ca 60%, #312e81 100%);
    box-shadow: 0 12px 30px rgba(67, 56, 202, 0.22);
}
.welcome-kicker {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
}
.welcome-sub { color: rgba(255, 255, 255, 0.88); }
.welcome-sub .status-pill { vertical-align: middle; }
.welcome-illustration { width: 250px; max-width: 34%; height: auto; flex-shrink: 0; }
@media (max-width: 575.98px) {
    .welcome-banner { padding: 1.25rem; }
}

/* ----- Auth pages (login, sign-up, errors) ------------------------- */
.auth-main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%;
    max-width: 440px;
}
.auth-card-wide {
    max-width: 640px;
}
.border-dashed {
    border-style: dashed;
    background: transparent;
    box-shadow: none;
}
.error-icon {
    font-size: 3rem;
    color: var(--bt-primary);
}

.role-option {
    border: 1px solid var(--bt-border);
    border-radius: var(--bt-radius);
    padding: 0.9rem 1rem;
    background: var(--bt-surface);
}
.btn-check:checked + .role-option {
    border-color: var(--bt-primary);
    background: var(--bt-primary-soft);
    box-shadow: 0 0 0 1px var(--bt-primary);
}
.btn-check:focus-visible + .role-option {
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.3);
}

.approval-note {
    background: var(--bt-primary-soft);
    border: 1px solid #c7d2fe;
    border-radius: var(--bt-radius);
    padding: 0.9rem 1rem;
    color: #312e81;
}

.password-rules li {
    color: var(--bt-text-muted);
}
.password-rules li.ok {
    color: #15803d;
}

/* ----- App layout (navbar + sidebar + content) --------------------- */
.app-navbar {
    background: var(--bt-surface);
    height: var(--bt-navbar-height);
    z-index: 1030;
}
.app-shell {
    display: flex;
    min-height: calc(100vh - var(--bt-navbar-height));
}
.app-main {
    flex: 1;
    min-width: 0;          /* lets wide tables scroll instead of stretching the page */
    padding: 1.5rem;
}
.app-main:focus {
    outline: none;
}

@media (min-width: 992px) {
    .app-sidebar {
        width: var(--bt-sidebar-width);
        flex-shrink: 0;
        background: var(--bt-surface);
        border-right: 1px solid var(--bt-border);
        position: sticky;
        top: var(--bt-navbar-height);
        height: calc(100vh - var(--bt-navbar-height));
        overflow-y: auto;
    }
    .app-main {
        padding: 2rem;
    }
}

.app-sidebar .nav-link {
    color: #374151;
    border-radius: 0.5rem;
    padding: 0.55rem 0.8rem;
}
.app-sidebar .nav-link:hover {
    background: #f3f4f6;
}
.app-sidebar .nav-link.active {
    background: var(--bt-primary-soft);
    color: var(--bt-primary);
    font-weight: 600;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ----- Avatars ----------------------------------------------------- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.avatar-sm { width: 2.25rem; height: 2.25rem; }
.avatar-lg { width: 4rem; height: 4rem; }
.avatar-xl { width: 6rem; height: 6rem; font-size: 1.6rem; }

/* Profile page */
.profile-card { overflow: hidden; }
.profile-cover {
    height: 90px;
    background:
        radial-gradient(circle at 85% 20%, rgba(255, 255, 255, 0.18), transparent 45%),
        linear-gradient(120deg, #4f46e5 0%, #4338ca 60%, #312e81 100%);
}
.profile-avatar-wrap { margin-top: -3rem; }
.profile-avatar-wrap .avatar { border: 4px solid var(--bt-surface); box-shadow: 0 4px 14px rgba(30, 27, 75, 0.15); }
.profile-stats > div + div { border-left: 1px solid var(--bt-border); }
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bt-primary-soft);
    color: var(--bt-primary);
    font-weight: 600;
    font-size: 0.8rem;
}

/* ----- Badges ------------------------------------------------------ */
.role-badge { font-weight: 500; }
.role-admin     { background: #fef3c7; color: #92400e; }
.role-tester    { background: #dbeafe; color: #1e40af; }
.role-developer { background: #dcfce7; color: #166534; }

/* ----- Empty states ------------------------------------------------ */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}
.empty-state-icon {
    font-size: 2.5rem;
    color: var(--bt-primary);
    display: block;
    margin-bottom: 0.75rem;
}

.account-summary dd { margin-bottom: 0.5rem; }

.min-w-0 { min-width: 0; }
.form-card { max-width: 900px; }
.role-select { width: auto; min-width: 8.5rem; }

/* ----- Status pills (projects now, bugs from Phase 5) --------------- */
.status-pill {
    font-weight: 500;
    border: 1px solid transparent;
}
.project-active    { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.project-on_hold   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.project-completed { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.project-archived  { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }

/* Bug statuses - each has its own colour */
.bug-open                 { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.bug-in_progress          { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.bug-fixed                { background: #ccfbf1; color: #115e59; border-color: #99f6e4; }
.bug-pending_verification { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.bug-reopened             { background: #ffe4e6; color: #9f1239; border-color: #fecdd3; }
.bug-closed               { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.bug-rejected             { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.bug-duplicate            { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

/* Severity and priority: coloured text with an icon (not colour alone) */
.severity, .priority { font-size: 0.875rem; font-weight: 500; white-space: nowrap; }
.sev-critical { color: #b91c1c; }
.sev-major    { color: #c2410c; }
.sev-minor    { color: #a16207; }
.sev-trivial  { color: #6b7280; }
.pri-urgent   { color: #b91c1c; }
.pri-high     { color: #c2410c; }
.pri-medium   { color: #1d4ed8; }
.pri-low      { color: #6b7280; }

/* ----- Bug details ------------------------------------------------- */
.text-prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.section-title {
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.75rem;
    color: var(--bt-text-muted);
    margin-bottom: 0.5rem;
}
.steps-box {
    background: #f9fafb;
    border: 1px solid var(--bt-border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.925rem;
}
.result-box {
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    border: 1px solid;
}
.result-expected { background: #f0fdf4; border-color: #bbf7d0; }
.result-expected h2 { color: #166534; }
.result-actual   { background: #fef2f2; border-color: #fecaca; }
.result-actual h2 { color: #991b1b; }

.detail-facts dt {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--bt-text-muted);
}
.detail-facts dd { margin-bottom: 0.9rem; }
.detail-facts dd:last-child { margin-bottom: 0; }
@media (min-width: 992px) {
    .detail-side { position: sticky; top: calc(var(--bt-navbar-height) + 1rem); }
}

/* Progress tracker: Open -> In Progress -> Fixed -> Verification -> Closed */
.lifecycle {
    display: flex;
    gap: 0;
    background: var(--bt-surface);
    border: 1px solid var(--bt-border);
    border-radius: var(--bt-radius);
    padding: 0.9rem 1rem;
    overflow-x: auto;
}
.lifecycle-step {
    flex: 1;
    min-width: 5.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    text-align: center;
}
.lifecycle-step:not(:first-child)::before {        /* connecting line */
    content: "";
    position: absolute;
    top: 0.75rem;
    right: 50%;
    width: 100%;
    height: 3px;
    background: var(--bt-border);
    z-index: 0;
}
.lifecycle-step.is-done:not(:first-child)::before,
.lifecycle-step.is-current:not(:first-child)::before { background: var(--bt-primary); }
.lifecycle-dot {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--bt-surface);
    border: 3px solid var(--bt-border);
    color: #fff;
    font-size: 0.8rem;
}
.lifecycle-step.is-done .lifecycle-dot { background: var(--bt-primary); border-color: var(--bt-primary); }
.lifecycle-step.is-current .lifecycle-dot {
    border-color: var(--bt-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18);
}
.lifecycle-label { font-size: 0.8rem; margin-top: 0.35rem; color: var(--bt-text-muted); }
.lifecycle-step.is-current .lifecycle-label { color: var(--bt-primary); font-weight: 600; }
.lifecycle-step.is-done .lifecycle-label { color: #374151; }

.actions-card { border-color: #c7d2fe; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.08); }
.action-form { background: #f9fafb; border: 1px solid var(--bt-border); border-radius: 0.5rem; padding: 0.75rem; }
.comment-form { border-top: 1px solid var(--bt-border); padding-top: 1rem; }
.chart-box-sm { height: 200px; }

.attachment-thumb {
    width: 3.5rem;
    height: 3.5rem;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid var(--bt-border);
}
.attachment-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.5rem;
    background: #f3f4f6;
    font-size: 1.5rem;
    color: #6b7280;
    flex-shrink: 0;
}

.comment { padding: 0.9rem 0; border-bottom: 1px solid var(--bt-border); }
.comment:first-child { padding-top: 0; }
.comment:last-child { border-bottom: 0; padding-bottom: 0; }
.comment-investigation .text-prewrap { border-left: 3px solid #a78bfa; padding-left: 0.75rem; }
.comment-fix .text-prewrap { border-left: 3px solid #34d399; padding-left: 0.75rem; }

.timeline { position: relative; }
.timeline-item {
    position: relative;
    display: flex;
    gap: 0.9rem;
    padding-bottom: 1.1rem;
}
.timeline-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 0.95rem;
    top: 2rem;
    bottom: 0;
    width: 2px;
    background: var(--bt-border);
}
.timeline-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--bt-primary-soft);
    color: var(--bt-primary);
    font-size: 0.85rem;
}
.timeline-comment {
    background: #f9fafb;
    border-radius: 0.4rem;
    padding: 0.4rem 0.6rem;
    margin-top: 0.3rem;
}

.font-monospace-sm { font-family: var(--bs-font-monospace); font-size: 0.9rem; }
.char-counter { margin-top: 0.15rem; }

/* ----- Phase 6: lists, dashboard ----------------------------------- */
.bug-table td, .bug-table th { white-space: nowrap; }
.bug-table .bug-title-cell { white-space: normal; min-width: 14rem; max-width: 28rem; }
.recent-badge {
    background: var(--bt-primary-soft);
    color: var(--bt-primary);
    font-weight: 500;
    font-size: 0.7rem;
}
.view-tabs .nav-link { color: #374151; }
.view-tabs .nav-link.active { background: var(--bt-primary); color: #fff; }
.mini-bug { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.dashboard-search .form-control { border-left: 0; }
.chart-box { position: relative; height: 260px; }
.chart-table summary { cursor: pointer; color: var(--bt-text-muted); }
.stat-link { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.stat-link:hover, .stat-link:focus-visible {
    border-color: #c7d2fe;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.08);
}
.stat-icon.stat-icon-sm { width: 2rem; height: 2rem; font-size: 1rem; border-radius: 0.5rem; }

/* ----- Stat cards -------------------------------------------------- */
.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-primary { background: var(--bt-primary-soft); color: var(--bt-primary); }
.stat-info    { background: #e0f2fe; color: #0369a1; }
.stat-success { background: #dcfce7; color: #15803d; }
.stat-warning { background: #fef3c7; color: #b45309; }
.stat-danger  { background: #fee2e2; color: #b91c1c; }
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

/* ----- Project picker ---------------------------------------------- */
.project-card {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.project-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.08);
}
.project-card.is-current {
    border-color: var(--bt-primary);
    box-shadow: 0 0 0 1px var(--bt-primary);
}
.project-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.project-switcher {
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- Notifications ----------------------------------------------- */
.bell-badge { top: 2px; right: 0; font-size: 0.65rem; }
.bell-menu { width: 22rem; max-width: calc(100vw - 2rem); }
.bell-item { white-space: normal; }
.bell-item.is-unread { background: var(--bt-primary-soft); }
.notification-item.is-unread { background: #f8f9ff; }
.notification-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--bt-primary-soft);
    color: var(--bt-primary);
}
.notif-reopened, .notif-overdue { background: #fee2e2; color: #b91c1c; }
.notif-pending_verification, .notif-due_soon { background: #fef3c7; color: #b45309; }
.notif-assigned, .notif-project_added, .notif-account_approved { background: #dcfce7; color: #15803d; }
.notif-account_pending { background: #fef3c7; color: #b45309; }
.role-none { background: #f3f4f6; color: #4b5563; }
.pending-row > td { background: #fffbeb; }
.unread-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--bt-primary);
    flex-shrink: 0;
    margin-top: 0.4rem;
}

/* ----- Toasts ------------------------------------------------------ */
/* Below the top bar, so they never cover the user menu */
.app-toasts { top: var(--bt-navbar-height); z-index: 1090; }
.stat-label-row { min-height: 2.6rem; }
.auth-shell, .auth-form-side, .auth-form-inner { min-width: 0; }
.app-toast {
    background: var(--bt-surface);
    border: 1px solid var(--bt-border);
    border-left-width: 4px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}
.app-toast-success { border-left-color: #16a34a; }
.app-toast-success .toast-icon { color: #16a34a; }
.app-toast-danger  { border-left-color: #dc2626; }
.app-toast-danger .toast-icon  { color: #dc2626; }
.app-toast-warning { border-left-color: #d97706; }
.app-toast-warning .toast-icon { color: #d97706; }
.app-toast-info    { border-left-color: var(--bt-primary); }
.app-toast-info .toast-icon    { color: var(--bt-primary); }
