/* ============================================================
   it.coranto.sifterapp - application styles
   Loaded last, after the Vuesy theme (it.coranto.vuesy.static).

   The brand lives ONLY in the variables below: change them to
   restyle the whole application. Default: the Vuesy primary colour.
   ============================================================ */
:root {
    --sa-brand: #776acf;
    --sa-brand-rgb: 119, 106, 207;
    --sa-brand-hover: #6457b8;
    --sa-brand-soft: #ebe9f8;
    --sa-brand-border: #c9c3ee;
    --sa-text: #3c3c3c;
    --sa-text-muted: #74788d;

    --bs-primary: var(--sa-brand);
    --bs-primary-rgb: var(--sa-brand-rgb);
    --bs-link-color: var(--sa-brand);
    --bs-link-color-rgb: var(--sa-brand-rgb);
    --bs-link-hover-color: var(--sa-brand-hover);
    --bs-sidebar-menu-item-active-color: var(--sa-brand);
    --bs-sidebar-menu-item-active-bg-color: var(--sa-brand-soft);
    --bs-sidebar-menu-item-hover-color: var(--sa-brand);
    --bs-input-focus-border: var(--sa-brand);
}

/* ------------------------------------------------------------
   Primary colour on the components the theme compiles with a
   fixed value instead of the variable
   ------------------------------------------------------------ */
.btn-primary {
    background-color: var(--sa-brand) !important;
    border-color: var(--sa-brand) !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--sa-brand-hover) !important;
    border-color: var(--sa-brand-hover) !important;
}
.btn-outline-primary {
    color: var(--sa-brand) !important;
    border-color: var(--sa-brand) !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    background-color: var(--sa-brand) !important;
    border-color: var(--sa-brand) !important;
    color: #fff !important;
}
.text-primary   { color: var(--sa-brand) !important; }
.bg-primary     { background-color: var(--sa-brand) !important; }
.border-primary { border-color: var(--sa-brand) !important; }

a { color: var(--sa-brand); }
a:hover, a:focus { color: var(--sa-brand-hover); }

.form-control:focus,
.form-select:focus {
    border-color: var(--sa-brand);
    box-shadow: 0 0 0 0.2rem rgba(var(--sa-brand-rgb), 0.25);
}

.page-title-box h4,
.card-title,
h1, h2, h3, h4, h5, h6 {
    color: var(--sa-text) !important;
}

/* ------------------------------------------------------------
   Left bar, "brand" variant (body data-sidebar="brand")
   The theme paints it with a fixed dark colour and assumes white
   text: here white background, brand border, dark text.
   ------------------------------------------------------------ */
body[data-sidebar="brand"] .vertical-menu {
    background-color: #ffffff !important;
    border-right: 2px solid var(--sa-brand) !important;
}
body[data-sidebar="brand"] .vertical-menu::before {
    display: none;
}
body[data-sidebar="brand"] .vertical-menu .vertical-menu-btn {
    color: var(--sa-text) !important;
}
/* the theme has an extra-specific [data-topbar=light] variant for the brand box */
body[data-sidebar="brand"] .navbar-brand-box,
body[data-sidebar="brand"][data-topbar="light"] .navbar-brand-box {
    background-color: #ffffff !important;
    border-bottom: 0 !important;
}

/* Text logo: full in the open bar, short in the icon rail */
body[data-sidebar="brand"] .logo-txt {
    color: var(--sa-brand) !important;
    font-weight: 700;
    text-decoration: none;
}
body[data-sidebar="brand"] .logo-lg .logo-txt { font-size: 26px; }
body[data-sidebar="brand"] .logo-sm .logo-txt { font-size: 20px; }
body[data-sidebar="brand"][data-sidebar-size="sm"] .navbar-brand-box {
    padding: 0 !important;
    text-align: center;
}

/* Login page logo */
.login-logo-txt {
    display: inline-block;
    font-weight: 700;
    font-size: 48px;
    color: var(--sa-brand);
    text-decoration: none;
    line-height: 1;
}

body[data-sidebar="brand"] #sidebar-menu ul li.menu-title { color: #5a5a5a !important; }
body[data-sidebar="brand"] #sidebar-menu ul li a,
body[data-sidebar="brand"] #sidebar-menu ul li a .nav-icon { color: var(--sa-text) !important; }
body[data-sidebar="brand"] #sidebar-menu ul li a:hover,
body[data-sidebar="brand"] #sidebar-menu ul li a:hover .nav-icon { color: var(--sa-brand) !important; }
body[data-sidebar="brand"] #sidebar-menu ul li ul.sub-menu li a { color: #6b6b6b !important; }
body[data-sidebar="brand"] #sidebar-menu ul li ul.sub-menu li a:hover { color: var(--sa-brand) !important; }

/* Active entry: brand text on a soft ground. The theme uses white text
   for active entries, unreadable on a light background. */
body[data-sidebar="brand"] #sidebar-menu ul li.mm-active > a,
body[data-sidebar="brand"] #sidebar-menu ul li.mm-active > a .nav-icon,
body[data-sidebar="brand"] #sidebar-menu ul li.mm-active > a:before,
body[data-sidebar="brand"] #sidebar-menu ul li ul.sub-menu li.mm-active > a,
body[data-sidebar="brand"] #sidebar-menu ul li ul.sub-menu li > a.active {
    background: var(--sa-brand-soft) !important;
    color: var(--sa-brand) !important;
}
body[data-sidebar="brand"] #sidebar-menu ul li.mm-active > a,
body[data-sidebar="brand"] #sidebar-menu ul li ul.sub-menu li.mm-active > a {
    border-radius: 0.25rem;
}
/* sub-entries indented from their parent, so the hierarchy reads */
body[data-sidebar="brand"] #sidebar-menu ul li ul.sub-menu li > a {
    margin-left: 1rem;
    padding-left: 2.5rem;
}

/* ------------------------------------------------------------
   Collapsed left bar (icon rail, data-sidebar-size="sm")
   ------------------------------------------------------------ */
/* The theme gives the icon min-width 50px, exactly the room in the rail:
   the icon shrinks by the padding added to the anchor, so it stays inside. */
body[data-sidebar="brand"][data-sidebar-size="sm"] .vertical-menu #sidebar-menu > ul > li > a {
    padding: 15px 4px;
}
body[data-sidebar="brand"][data-sidebar-size="sm"] .vertical-menu #sidebar-menu > ul > li > a i {
    min-width: 42px !important;
}
body[data-sidebar="brand"][data-sidebar-size="sm"] .vertical-menu #sidebar-menu > ul > li:hover > a,
body[data-sidebar="brand"][data-sidebar-size="sm"] .vertical-menu #sidebar-menu > ul > li:hover > a .nav-icon {
    background-color: var(--sa-brand-soft) !important;
    color: var(--sa-brand) !important;
}
/* The anchor is wider than the rail (the theme widens it for the flyout):
   the highlight stays on the icon box only. */
body[data-sidebar="brand"][data-sidebar-size="sm"] #sidebar-menu ul li.mm-active > a,
body[data-sidebar="brand"][data-sidebar-size="sm"] #sidebar-menu ul li.mm-active > a:before {
    background: transparent !important;
}
body[data-sidebar="brand"][data-sidebar-size="sm"] #sidebar-menu ul li.mm-active > a .nav-icon {
    background: var(--sa-brand-soft) !important;
    border-radius: 0.375rem;
}
/* Sub-entries only in the hover flyout, without the indent meant for the wide bar */
body[data-sidebar-size="sm"] #sidebar-menu ul li ul.sub-menu,
body[data-sidebar-size="sm"] #sidebar-menu ul li ul.sub-menu.mm-show {
    display: none;
}
body[data-sidebar-size="sm"] #sidebar-menu > ul > li:hover > ul.sub-menu,
body[data-sidebar-size="sm"] #sidebar-menu > ul > li:hover > ul.sub-menu.mm-show {
    display: block;
}
body[data-sidebar="brand"][data-sidebar-size="sm"] #sidebar-menu ul li ul.sub-menu li > a {
    margin-left: 0;
    padding-left: 1rem;
    padding-right: 1rem;
}
/* Collapsed, the theme switches the bar to position:absolute and it scrolls away */
body[data-sidebar="brand"][data-sidebar-size="sm"] .vertical-menu {
    position: fixed !important;
}

/* ------------------------------------------------------------
   Mobile (below 992px)
   ------------------------------------------------------------ */
@media (max-width: 991.98px) {
    html, body { overflow-x: hidden; }

    table th,
    table td:not(.small) { font-size: 0.8rem; }

    /* The theme switches to the short logo inline in the top bar: there is room for the full one */
    body[data-sidebar="brand"]:not([data-sidebar-size="sm"]) .logo span.logo-lg { display: inline-block; }
    body[data-sidebar="brand"]:not([data-sidebar-size="sm"]) .logo span.logo-sm { display: none; }

    body[data-sidebar="brand"] #page-topbar .navbar-header .vertical-menu-btn {
        background: #ffffff !important;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    body[data-sidebar="brand"] #page-topbar .navbar-header .vertical-menu-btn,
    body[data-sidebar="brand"] #page-topbar .navbar-header .vertical-menu-btn i {
        color: var(--sa-text) !important;
    }

    /* The bar starts at the top behind the header, with the header height as inner
       spacing: no empty band above it once the header scrolls away. */
    body[data-sidebar="brand"] .vertical-menu {
        top: 0 !important;
        padding-top: 85px;
        z-index: 1001 !important;
    }
    body[data-sidebar="brand"][data-sidebar-size="sm"] #page-topbar { margin-left: 0 !important; }
    body[data-sidebar="brand"][data-sidebar-size="sm"] .navbar-brand-box {
        width: auto !important;
        text-align: left !important;
        padding: 0 1.5rem !important;
    }

    /* top bar above the bar, so the user menu is not covered */
    #page-topbar { z-index: 1006; }
    #page-header-user-dropdown {
        height: auto !important;
        width: fit-content !important;
        padding: 0.25rem !important;
    }
    .navbar-header .dropdown-menu {
        right: 0 !important;
        left: auto !important;
    }
}

/* ------------------------------------------------------------
   Sticky footer: at the bottom of the screen when the page is short,
   after the content when it is long (the theme footer is absolute).
   ------------------------------------------------------------ */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
#layout-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    width: 100%;
}
#layout-wrapper .main-content {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
}
#layout-wrapper .main-content .page-content { flex: 1 0 auto; }
#layout-wrapper .main-content .footer {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
}

/* User avatar in the top bar: an icon, so no image file is needed */
.sa-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--sa-brand-soft);
    color: var(--sa-brand);
    font-size: 1.2rem;
}

/* ============================================================
   Tickets
   ============================================================ */

/* ---- Status badges ---- */
.ticket-badge-open     { background-color: #34c38f; color: #fff; }
.ticket-badge-progress { background-color: #f1b44c; color: #212529; }
.ticket-badge-pending  { background-color: #50a5f1; color: #fff; }
.ticket-badge-closed   { background-color: #74788d; color: #fff; }

/* ---- Priority badges ---- */
.ticket-priority-low      { background-color: #34c38f; color: #fff; }
.ticket-priority-medium   { background-color: #f1b44c; color: #212529; }
.ticket-priority-high     { background-color: #f46a6a; color: #fff; }
.ticket-priority-critical { background-color: #343a40; color: #fff; }

/* ---- Conversation thread ---- */
.ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.ticket-message {
    display: flex;
    gap: 0.75rem;
}
.ticket-message.is-admin { flex-direction: row-reverse; }
.ticket-message .message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.ticket-message .message-avatar.user-avatar {
    background-color: var(--sa-brand-soft);
    color: var(--sa-brand);
}
.ticket-message .message-avatar.admin-avatar {
    background-color: var(--sa-brand);
    color: #fff;
}
.ticket-message .message-body { max-width: 75%; }
.ticket-message .message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    word-break: break-word;
}
.ticket-message.is-user .message-bubble {
    background-color: var(--sa-brand-soft);
    border: 1px solid var(--sa-brand-border);
    color: #1a1823;
}
.ticket-message.is-admin .message-bubble {
    background-color: var(--sa-brand);
    color: #fff;
}
.ticket-message .message-meta {
    font-size: 0.75rem;
    color: var(--sa-text-muted);
    margin-top: 0.25rem;
}
.ticket-message.is-admin .message-meta { text-align: right; }

/* ---- List table ---- */
.ticket-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sa-text-muted);
    border-bottom: 2px solid #eff2f7;
}

/* ---- New ticket form ---- */
.ticket-form-card {
    max-width: 720px;
    margin: 0 auto;
}
.ticket-form-card .card-header {
    background: linear-gradient(135deg, var(--sa-brand) 0%, var(--sa-brand-hover) 100%);
    color: #fff;
    border-radius: 0.5rem 0.5rem 0 0;
}
.ticket-form-card .card-header h5 {
    color: #fff !important;
    margin-bottom: 0;
}

/* ---- Reply box ---- */
.ticket-reply-box {
    border: 1px solid #eff2f7;
    border-radius: 0.5rem;
    padding: 1rem;
    background: #fafbfc;
}
.ticket-reply-box textarea {
    border: none;
    background: transparent;
    resize: vertical;
    min-height: 100px;
    width: 100%;
}
.ticket-reply-box textarea:focus {
    outline: none;
    box-shadow: none;
}

/* ---- Pagination ---- */
.ticket-pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ---- Empty state ---- */
.ticket-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--sa-text-muted);
}
.ticket-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    color: #ced4da;
}

@media (max-width: 576px) {
    .ticket-message .message-body { max-width: 90%; }
}

/* ---- Clickable card on mobile ---- */
.ticket-card-link {
    cursor: pointer;
    transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
    -webkit-tap-highlight-color: transparent;
}
.ticket-card-link:hover,
.ticket-card-link:focus-visible {
    box-shadow: 0 0.25rem 0.75rem rgba(18, 38, 63, 0.12);
}
.ticket-card-link:focus-visible {
    outline: 2px solid var(--sa-brand);
    outline-offset: 2px;
}
.ticket-card-link:active { transform: scale(0.995); }
