/* MHS Ticket System - admin shell + shared components */

:root {
    --mhs-sidebar-width: 250px;
    --mhs-header-height: 60px;
    --mhs-sidebar-bg: #1e293b;
    --mhs-sidebar-hover: #334155;
    --mhs-sidebar-active: #2563eb;
    --mhs-sidebar-text: #cbd5e1;
    --mhs-body-bg: #f1f5f9;
    --mhs-border: #e2e8f0;
}

body {
    background-color: var(--mhs-body-bg);
    font-size: 0.925rem;
    color: #1e293b;
}

/* ------------------------------------------------------------------ shell */

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

.mhs-sidebar .mhs-brand {
    height: var(--mhs-header-height);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.1rem;
    color: #fff;
    font-weight: 600;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    text-decoration: none;
    flex-shrink: 0;
}

.mhs-sidebar .mhs-brand:hover { color: #fff; }

.mhs-sidebar .mhs-brand .bi { font-size: 1.35rem; color: #60a5fa; }

.mhs-nav {
    padding: .85rem .6rem;
    list-style: none;
    margin: 0;
    flex: 1;
}

.mhs-nav .mhs-nav-heading {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #64748b;
    padding: .9rem .75rem .4rem;
    font-weight: 600;
}

.mhs-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .75rem;
    margin-bottom: .15rem;
    border-radius: .4rem;
    color: var(--mhs-sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    transition: background .15s, color .15s;
}

.mhs-nav a:hover { background: var(--mhs-sidebar-hover); color: #fff; }

.mhs-nav a.active {
    background: var(--mhs-sidebar-active);
    color: #fff;
    font-weight: 500;
}

.mhs-nav a .bi { font-size: 1rem; width: 1.15rem; text-align: center; }

.mhs-nav a .badge { margin-left: auto; }

.mhs-sidebar-footer {
    padding: .8rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .75rem;
    color: #64748b;
    flex-shrink: 0;
}

.mhs-main {
    margin-left: var(--mhs-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Without this a wide table or chart inside a flex child can stretch the
       whole shell past the viewport and push the header off screen. */
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.mhs-content > .row,
.mhs-content .card,
.mhs-content .card-body,
.mhs-content .col,
.mhs-content [class^="col-"],
.mhs-content [class*=" col-"] { min-width: 0; }

/* A wide grid must scroll inside its own card, never widen the page.
   .card-body is a flex item, so it needs an explicit max-width or it
   grows to fit the table. */
.table-responsive {
    overflow-x: auto;
    max-width: 100%;
}

.grid-view.table-responsive { width: 100%; }

.mhs-header {
    min-height: var(--mhs-header-height);
    background: #fff;
    border-bottom: 1px solid var(--mhs-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.mhs-header .mhs-page-title {
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0;
    color: #0f172a;
    /* Truncate a long ticket subject rather than shoving the avatar away. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.mhs-header > .ms-auto { flex-shrink: 0; }

.mhs-content { padding: 1.35rem; flex: 1; min-width: 0; }

.mhs-footer {
    padding: .9rem 1.35rem;
    border-top: 1px solid var(--mhs-border);
    background: #fff;
    font-size: .8rem;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.mhs-sidebar-toggle { display: none; }

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

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

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

/* ---- phones -------------------------------------------------------- */
@media (max-width: 575.98px) {
    body { font-size: .9rem; }

    .mhs-header { padding: 0 .85rem; gap: .6rem; }
    .mhs-header .mhs-page-title { font-size: .95rem; }

    .mhs-content { padding: .85rem; }

    .card-header { padding: .7rem .85rem; font-size: .88rem; }
    .card-body { padding: .85rem; }

    /* Stat cards read better stacked vertically when only half a screen wide */
    .mhs-stat-card .card-body {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .45rem !important;
        padding: .8rem !important;
    }
    .mhs-stat-card .mhs-stat-value { font-size: 1.45rem; }
    .mhs-stat-card .mhs-stat-icon { width: 32px; height: 32px; font-size: 1rem; }

    /* Page-level action rows stack instead of squeezing */
    .mhs-content > .d-flex.justify-content-between > .d-flex { width: 100%; }
    .mhs-content > .d-flex.justify-content-between .btn { flex: 1 1 auto; }

    .mhs-table-card .grid-view .summary,
    .mhs-table-card .grid-view .pagination-wrap { padding: .6rem .85rem; }

    .mhs-timeline { padding-left: 1.5rem; }

    .modal-dialog { margin: .6rem; }
}

/* Charts must not dictate the page width */
.mhs-chart-box { position: relative; width: 100%; min-width: 0; }

/* ------------------------------------------------------------------ cards */

.card { border: 1px solid var(--mhs-border); border-radius: .55rem; }

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--mhs-border);
    font-weight: 600;
    padding: .8rem 1rem;
    font-size: .93rem;
}

.mhs-stat-card { position: relative; overflow: hidden; }

.mhs-stat-card .mhs-stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    color: #0f172a;
}

.mhs-stat-card .mhs-stat-label {
    font-size: .7rem;
    line-height: 1.25;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
}

/* Keep the seven status cards the same height once labels wrap. */
.row-cols-xl-7 .mhs-stat-card .card-body { min-height: 74px; }

.mhs-stat-card .mhs-stat-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.mhs-stat-card a.stretched-link { text-decoration: none; }

/* Bootstrap ships row-cols-1..6; the dashboard needs a 7-up row for the
   total + six statuses. */
@media (min-width: 1200px) {
    .row-cols-xl-7 > * {
        flex: 0 0 auto;
        width: 14.2857142857%;
    }
}

/* ----------------------------------------------------------------- badges */

.mhs-badge {
    font-size: .74rem;
    font-weight: 600;
    padding: .3em .6em;
    border-radius: .3rem;
    display: inline-block;
    white-space: nowrap;
}

.mhs-status-open           { background: #dbeafe; color: #1d4ed8; }
.mhs-status-assigned       { background: #e0e7ff; color: #4338ca; }
.mhs-status-in_progress    { background: #fef3c7; color: #b45309; }
.mhs-status-on_hold        { background: #fee2e2; color: #b91c1c; }
.mhs-status-resolved       { background: #d1fae5; color: #047857; }
.mhs-status-closed         { background: #e2e8f0; color: #475569; }

.mhs-priority-low      { background: #f1f5f9; color: #475569; }
.mhs-priority-medium   { background: #dbeafe; color: #1d4ed8; }
.mhs-priority-high     { background: #ffedd5; color: #c2410c; }
.mhs-priority-critical { background: #fee2e2; color: #b91c1c; }

/* --------------------------------------------------------------- timeline */

.mhs-timeline { position: relative; padding-left: 1.75rem; margin: 0; list-style: none; }

.mhs-timeline::before {
    content: '';
    position: absolute;
    left: .5rem;
    top: .35rem;
    bottom: .35rem;
    width: 2px;
    background: var(--mhs-border);
}

.mhs-timeline-item { position: relative; padding-bottom: 1.1rem; }

.mhs-timeline-item:last-child { padding-bottom: 0; }

.mhs-timeline-item::before {
    content: '';
    position: absolute;
    left: -1.42rem;
    top: .3rem;
    width: .65rem;
    height: .65rem;
    border-radius: 50%;
    background: #94a3b8;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--mhs-border);
}

.mhs-timeline-item.is-created::before  { background: #2563eb; }
.mhs-timeline-item.is-assigned::before { background: #4f46e5; }
.mhs-timeline-item.is-status::before   { background: #d97706; }
.mhs-timeline-item.is-resolved::before { background: #059669; }
.mhs-timeline-item.is-closed::before   { background: #475569; }

.mhs-timeline-time { font-size: .75rem; color: #64748b; }

.mhs-timeline-text { font-size: .875rem; }

/* --------------------------------------------------------------- comments */

.mhs-comment {
    border: 1px solid var(--mhs-border);
    border-radius: .5rem;
    padding: .75rem .9rem;
    margin-bottom: .7rem;
    background: #fff;
}

.mhs-comment.is-internal {
    background: #fffbeb;
    border-color: #fcd34d;
}

.mhs-comment-meta { font-size: .78rem; color: #64748b; }

.mhs-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    background: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
    color: #475569;
    flex-shrink: 0;
}

.mhs-avatar-lg { width: 96px; height: 96px; font-size: 1.9rem; }

/* ---------------------------------------------------------------- gridview */

.grid-view { margin-bottom: 0; }

.grid-view table { font-size: .875rem; margin-bottom: 0; }

.grid-view thead th {
    background: #f8fafc;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #475569;
    white-space: nowrap;
    border-bottom: 1px solid var(--mhs-border);
}

.grid-view td { vertical-align: middle; }

.grid-view .filters td { padding: .35rem; }

.grid-view .summary { font-size: .8rem; color: #64748b; padding: .6rem 0; }

.mhs-table-card .card-body { padding: 0; }

.mhs-table-card .grid-view .summary,
.mhs-table-card .grid-view .pagination-wrap { padding: .6rem 1rem; }

/* ------------------------------------------------------------------- auth */

.mhs-auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
}

.mhs-auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: .7rem;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .28);
    border: none;
}

.mhs-auth-card .card-body { padding: 2rem; }

.mhs-auth-logo { font-size: 2rem; color: #2563eb; }

/* ------------------------------------------------------------------ misc */

.mhs-detail-list dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; }

.mhs-detail-list dd { margin-bottom: .85rem; font-size: .9rem; }

.required-star { color: #dc2626; }

.mhs-description-box { white-space: pre-wrap; word-break: break-word; }

@media print {
    .mhs-sidebar, .mhs-header, .mhs-footer, .no-print { display: none !important; }
    .mhs-main { margin-left: 0; }
}
