/* ============================= */
/* Base Layout Settings          */
/* ============================= */

html {
    font-size: 14px;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin: 0;
    transition: background 0.2s ease, color 0.2s ease;
    animation: fadeInPage 0.2s ease;
}

/* ============================= */
/* Theme Variables               */
/* ============================= */

:root {
    --bg: #ffffff;
    --text: #000000; /* darker text in light mode */
    --muted: rgba(0,0,0,0.62);
    --card: #f7f7f7;
    --border: rgba(0,0,0,0.10);
    --link: #0b66c3;
    /* “Modern” tokens */
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-hover: 0 10px 22px rgba(0,0,0,0.10);
}

html[data-theme="dark"] {
    --bg: #0f1115;
    --text: #e9e9ea;
    --muted: rgba(233,233,234,0.72);
    --card: #171a21;
    --border: rgba(255,255,255,0.10);
    --link: #7db4ff;
    --shadow: 0 6px 18px rgba(0,0,0,0.45);
    --shadow-hover: 0 10px 26px rgba(0,0,0,0.55);
}

/* ============================= */
/* Apply Theme Variables         */
/* ============================= */

body {
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--link);
    text-decoration: none;
}

    a:hover {
        opacity: 0.90;
    }

/* ============================= */
/* Typography                    */
/* ============================= */

h1, h2, h3, h4, h5 {
    font-weight: 650;
    letter-spacing: -0.012em;
}

.text-muted {
    color: var(--muted) !important;
}

/* Slightly nicer default line-height */
body, p, li, td, th, input, button {
    line-height: 1.35;
}

/* ============================= */
/* Page spacing                  */
/* ============================= */

.container, .container-fluid {
    padding-top: 18px;
}

/* ============================= */
/* Inputs                        */
/* ============================= */

input, select, textarea, button {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}

    input::placeholder,
    textarea::placeholder {
        color: var(--muted);
    }

    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        box-shadow: 0 0 0 3px rgba(13,110,253,0.14);
        border-color: rgba(13,110,253,0.35);
    }

/* Bootstrap form controls sometimes override background */
.form-control,
.form-select,
.input-group-text {
    background-color: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* ============================= */
/* Buttons                       */
/* ============================= */

button,
.btn {
    border-radius: var(--radius-sm) !important;
    padding: 7px 14px;
    font-weight: 550;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

    .btn:hover {
        transform: translateY(-1px);
    }

    .btn:active {
        transform: translateY(0px);
    }

.btn-primary {
    box-shadow: 0 2px 8px rgba(13,110,253,0.22);
}

    .btn-primary:hover {
        box-shadow: 0 10px 22px rgba(13,110,253,0.28);
    }

html[data-theme="dark"] .btn-outline-secondary {
    color: var(--text) !important;
    border-color: var(--border) !important;
}

    html[data-theme="dark"] .btn-outline-secondary:hover {
        filter: brightness(1.08);
    }

/* ============================= */
/* Navbar                        */
/* ============================= */

.navbar-theme {
    background: var(--card) !important;
    border-bottom: 1px solid var(--border) !important;
    backdrop-filter: blur(6px);
    position: relative;
    z-index: 1030;
}

.navbar .dropdown-menu {
    z-index: 1031 !important;
}

    .navbar-theme .navbar-brand,
    .navbar-theme .nav-link {
        color: var(--text) !important;
    }

        .navbar-theme .nav-link:hover {
            opacity: 0.90;
        }

/* ============================= */
/* Footer                        */
/* ============================= */

.footer {
    border-top: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    position: static !important;
    height: auto !important;
    padding: 10px 0 !important;
    margin-top: 28px !important;
}

/* ============================= */
/* Cards                         */
/* ============================= */

.card,
.theme-card {
    background: var(--card) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow);
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

    .card:hover,
    .theme-card:hover {
        transform: translateY(-1px);
        box-shadow: var(--shadow-hover);
    }

/* Card header/footer */
.card-header,
.card-footer {
    background: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* ============================= */
/* “Modern stat card” helper     */
/* ============================= */

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

    .stat-card .stat-label {
        color: var(--muted);
        font-weight: 600;
        font-size: 0.92rem;
    }

    .stat-card .stat-value {
        font-size: 2rem;
        font-weight: 750;
        letter-spacing: -0.02em;
    }

/* ============================= */
/* Tables                        */
/* ============================= */

.table {
    color: var(--text) !important;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

    .table th,
    .table td {
        border-color: var(--border) !important;
    }

    .table thead th {
        background: var(--card) !important;
        color: var(--text) !important;
        font-weight: 650;
    }

    .table tbody tr {
        transition: background 0.12s ease;
    }

        .table tbody tr:hover {
            background: rgba(0,0,0,0.03);
        }

html[data-theme="dark"] .table tbody tr:hover {
    background: rgba(255,255,255,0.05);
}

/* Zebra striping for dark mode */
html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: #f1f1f1;
    background-color: rgba(255,255,255,0.04);
}

/* ============================= */
/* List Items                    */
/* ============================= */

.list-group-item,
.theme-list-item {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

    .theme-list-item:hover {
        filter: brightness(0.95);
    }

html[data-theme="dark"] .theme-list-item:hover {
    filter: brightness(1.12);
}

/* Links inside list groups */
.list-group-item a {
    color: var(--link) !important;
}

/* ============================= */
/* Alerts                        */
/* ============================= */

.alert {
    border-radius: var(--radius-sm) !important;
}

html[data-theme="dark"] .alert {
    background-color: rgba(255,255,255,0.06) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* ============================= */
/* Urgent Dashboard Card         */
/* ============================= */

.theme-card-urgent {
    border-left: 4px solid #dc3545 !important;
}

    .theme-card-urgent .display-6 {
        color: #dc3545 !important;
    }

html[data-theme="dark"] .theme-card-urgent {
    border-left: 4px solid #ff5c5c !important;
}

    html[data-theme="dark"] .theme-card-urgent .display-6 {
        color: #ff5c5c !important;
    }

/* ============================= */
/* Critical Ticket Row Styling   */
/* ============================= */

.ticket-critical-row {
    background-color: rgba(220,53,69,0.16) !important;
}

    .ticket-critical-row:hover {
        background-color: rgba(220,53,69,0.25) !important;
    }

html[data-theme="dark"] .ticket-critical-row {
    background-color: rgba(255,92,92,0.18) !important;
}

    html[data-theme="dark"] .ticket-critical-row:hover {
        background-color: rgba(255,92,92,0.30) !important;
    }

/* ============================= */
/* Theme-aware Activity Badges   */
/* ============================= */

.activity-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 650;
    padding: 0.30rem 0.55rem;
    border-radius: 999px;
    border: 1px solid transparent;
    color: #ffffff;
}

.activity-badge-created {
    background: #0d6efd;
}

.activity-badge-updated {
    background: #f59f00;
}

.activity-badge-closed {
    background: #198754;
}

.activity-badge-reopened {
    background: #fd7e14;
}

.activity-badge-assigned {
    background: #0dcaf0;
    color: #000;
}

.activity-badge-unassigned {
    background: #6c757d;
}

.activity-badge-deleted {
    background: #dc3545;
}

/* ============================= */
/* Scrollbars (Dark Mode)        */
/* ============================= */

/* Chrome, Edge, Safari */
html[data-theme="dark"] *::-webkit-scrollbar {
    width: 10px;
}

html[data-theme="dark"] *::-webkit-scrollbar-track {
    background: #1c1f26;
}

html[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background-color: #3a3f4b;
    border-radius: 6px;
    border: 2px solid #1c1f26;
}

    html[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
        background-color: #505768;
    }

/* Firefox */
html[data-theme="dark"] * {
    scrollbar-width: thin;
    scrollbar-color: #3a3f4b #1c1f26;
}

/* ============================= */
/* Dark/Light Bootstrap Overrides*/
/* (fix pages using bg-white etc)*/
/* ============================= */

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light {
    background-color: var(--card) !important;
}

html[data-theme="dark"] .text-dark {
    color: var(--text) !important;
}

/* Bootstrap muted text can be too dim in dark mode */
html[data-theme="dark"] .text-muted {
    color: var(--muted) !important;
}

/* ============================= */
/* Nav Tabs                      */
/* ============================= */

.nav-tabs {
    border-color: var(--border) !important;
}

.nav-tabs .nav-link {
    color: var(--muted) !important;
    border-color: transparent !important;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
}

    .nav-tabs .nav-link:hover {
        color: var(--text) !important;
        border-color: var(--border) var(--border) transparent !important;
    }

    .nav-tabs .nav-link.active {
        color: var(--text) !important;
        background: var(--card) !important;
        border-color: var(--border) var(--border) var(--card) !important;
        font-weight: 600;
    }

/* ============================= */
/* Badge Overrides               */
/* ============================= */

/* Bootstrap's bg-warning (#ffc107) is harsh — use a softer amber */
.badge.bg-warning,
.badge.bg-warning.text-dark {
    background-color: #c47d0e !important;
    color: #fff !important;
}

html[data-theme="dark"] .badge.bg-warning,
html[data-theme="dark"] .badge.bg-warning.text-dark {
    background-color: #9e6208 !important;
    color: #f5f5f5 !important;
}

/* ============================= */
/* Toast Notifications           */
/* ============================= */

#hd-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
    pointer-events: none;
}

.hd-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    pointer-events: all;
    animation: toastSlideIn 0.25s ease forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.hd-toast.hd-toast-hiding {
    opacity: 0;
    transform: translateX(20px);
}

.hd-toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.hd-toast-success .hd-toast-icon { color: #198754; }
.hd-toast-error   .hd-toast-icon { color: #dc3545; }
.hd-toast-info    .hd-toast-icon { color: #0d6efd; }

.hd-toast-success { border-left: 3px solid #198754; }
.hd-toast-error   { border-left: 3px solid #dc3545; }
.hd-toast-info    { border-left: 3px solid #0d6efd; }

.hd-toast-body {
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text);
    flex: 1;
}

.hd-toast-close {
    background: none;
    border: none;
    padding: 0;
    margin-left: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
}

    .hd-toast-close:hover {
        color: var(--text);
    }

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================= */
/* Ticket Comments               */
/* ============================= */

.comment-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s ease;
}

    .comment-item:last-child {
        border-bottom: none;
    }

.comment-internal {
    border-left: 3px solid #c47d0e;
    background: rgba(196, 125, 14, 0.06);
}

html[data-theme="dark"] .comment-internal {
    background: rgba(196, 125, 14, 0.11);
}

.comment-user {
    border-left: 3px solid #0d6efd;
    background: rgba(13, 110, 253, 0.04);
}

html[data-theme="dark"] .comment-user {
    background: rgba(13, 110, 253, 0.09);
}

.comment-tech {
    border-left: 3px solid #198754;
    background: rgba(25, 135, 84, 0.04);
}

html[data-theme="dark"] .comment-tech {
    background: rgba(25, 135, 84, 0.09);
}

.comment-meta {
    font-size: 0.78rem;
    font-weight: 600;
}

.comment-body {
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    margin-top: 4px;
}

.comment-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.comment-type-internal {
    background: rgba(196, 125, 14, 0.18);
    color: #8a5800;
}

html[data-theme="dark"] .comment-type-internal {
    background: rgba(196, 125, 14, 0.25);
    color: #f5c842;
}

.comment-type-tech {
    background: rgba(25, 135, 84, 0.14);
    color: #0d5c38;
}

html[data-theme="dark"] .comment-type-tech {
    background: rgba(25, 135, 84, 0.22);
    color: #5dcea0;
}

.comment-type-user {
    background: rgba(13, 110, 253, 0.12);
    color: #0a4db5;
}

html[data-theme="dark"] .comment-type-user {
    background: rgba(13, 110, 253, 0.20);
    color: #7db4ff;
}

/* ============================= */
/* Portal Progress Stepper       */
/* ============================= */

.portal-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 4px 0;
}

.portal-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}

.portal-step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.portal-step-done .portal-step-circle {
    background: #0d6efd;
    color: #fff;
    border: 2px solid #0d6efd;
}

.portal-step-pending .portal-step-circle {
    background: transparent;
    color: var(--muted);
    border: 2px solid var(--border);
}

.portal-step-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
}

.portal-step-done .portal-step-label {
    color: #0d6efd;
}

.portal-step-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin-bottom: 22px;
    min-width: 30px;
    transition: background 0.2s ease;
}

.portal-step-line-done {
    background: #0d6efd;
}

/* ============================= */
/* Motion                        */
/* ============================= */

@keyframes fadeInPage {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================= */
/* Mobile Polish                 */
/* ============================= */

/* Tighter sidebar cards on small screens */
@media (max-width: 991.98px) {
    .card-body dl.row dt,
    .card-body dl.row dd {
        font-size: 0.85rem;
    }

    /* Assignment checklist: reduce max-height so it doesn't dominate on mobile */
    .card-body [style*="max-height: 220px"] {
        max-height: 140px !important;
    }

    /* Ticket detail header: stack ticket number and title tighter */
    h2.fw-bold {
        font-size: 1.4rem;
    }
}

/* ============================= */
/* Print Styles                  */
/* ============================= */

@media print {
    /* Hide everything except the main content */
    nav,
    footer,
    #hd-toast-container,
    .btn,
    form.d-flex,
    form[asp-action],
    .card[id="activity-card"] .card-body form,
    [class*="col-lg-4"] .card:last-child,   /* Actions card */
    .no-print {
        display: none !important;
    }

    /* Reset page chrome */
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt;
    }

    .container, .container-fluid, main {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Cards look clean without shadow */
    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .card-header {
        background: #f5f5f5 !important;
        color: #000 !important;
        border-bottom: 1px solid #ccc !important;
    }

    /* Make sidebar full-width in print */
    .col-lg-4, .col-lg-8,
    .col-12 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Badges print with color */
    .badge {
        border: 1px solid #999 !important;
        color: #000 !important;
        background: #eee !important;
        print-color-adjust: exact;
    }

    /* Show ticket number prominently */
    h2.fw-bold {
        font-size: 18pt !important;
    }

    /* Print URL after links */
    a[href]:after {
        content: none !important;
    }

    /* Page break hints */
    .card {
        page-break-inside: avoid;
    }
}
