/* Decca Helpdesk styling */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #222; background: #f7f8fa; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
a { color: var(--primary, #0b5394); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { background: #fff; border-bottom: 1px solid #e1e4e8; padding: .75rem 0; }
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar .brand { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: #222; }
.topbar .brand img { height: 28px; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav .who { color: #666; font-size: .9em; margin-left: .5rem; padding-left: 1rem; border-left: 1px solid #e1e4e8; }
.linkbtn { background: none; border: none; color: var(--primary, #0b5394); cursor: pointer; padding: 0; font: inherit; }

main { padding: 1.5rem 0 3rem; min-height: 60vh; }

.footer { border-top: 1px solid #e1e4e8; padding: 1rem 0; color: #888; }

h1 { margin-top: 0; }
h1, h2, h3 { color: #222; }

.card { background: #fff; border: 1px solid #e1e4e8; border-radius: 6px; padding: 1.25rem; margin-bottom: 1rem; }

label { display: block; margin: .75rem 0 .25rem; font-weight: 600; font-size: .9em; }
input[type=text], input[type=email], input[type=password], select, textarea {
    width: 100%; padding: .55rem .65rem; border: 1px solid #c8cdd3; border-radius: 4px; font: inherit;
}
textarea { min-height: 8rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary, #0b5394); outline-offset: -1px; border-color: transparent; }

button, .btn { display: inline-block; padding: .55rem 1rem; background: var(--primary, #0b5394); color: #fff; border: none; border-radius: 4px; font: inherit; cursor: pointer; text-decoration: none; }
button.secondary, .btn.secondary { background: #fff; color: #222; border: 1px solid #c8cdd3; }
button.danger, .btn.danger { background: #c53030; }
button.small, .btn.small { padding: .25rem .6rem; font-size: .85em; }
button:hover, .btn:hover { opacity: .9; text-decoration: none; }

.flash { background: #e6f4ea; border: 1px solid #b7dbc1; color: #1b6b34; padding: .75rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.error { background: #fdecea; border: 1px solid #f3b9b3; color: #a82a1f; padding: .75rem 1rem; border-radius: 4px; margin-bottom: 1rem; }

/* Honeypot — invisible to humans, visible to bots */
.honeypot { position: absolute; left: -9999px; top: -9999px; height: 0; width: 0; overflow: hidden; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid #eaecef; }
th { background: #fafbfc; font-size: .85em; text-transform: uppercase; letter-spacing: .03em; color: #555; }
tr:hover td { background: #fafbfc; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8em; font-weight: 600; }
.badge.open      { background: #e6f0fa; color: #0b5394; }
.badge.pending   { background: #fff4ce; color: #806600; }
.badge.waiting   { background: #fde8ce; color: #ad5b00; }
.badge.thirdparty{ background: #fde8ce; color: #ad5b00; }
.badge.resolved  { background: #e6f4ea; color: #1b6b34; }
.badge.closed    { background: #eaecef; color: #444; }

.badge.priority-low      { background: #eaecef; color: #444; }
.badge.priority-normal   { background: #e6f0fa; color: #0b5394; }
.badge.priority-high     { background: #fff4ce; color: #806600; }
.badge.priority-urgent   { background: #fdecea; color: #a82a1f; }

.layout-2col { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; }
@media (max-width: 800px) { .layout-2col { grid-template-columns: 1fr; } }

.thread .msg { background: #fff; border: 1px solid #e1e4e8; border-radius: 6px; padding: 1rem; margin-bottom: 1rem; }
.thread .msg.private { background: #fff8e1; border-color: #ffe7a0; }
.thread .msg.system { background: #f0f3f7; border-color: #d6dde6; color: #555; font-style: italic; }
.thread .meta { font-size: .85em; color: #666; margin-bottom: .5rem; }
.thread .body { white-space: pre-wrap; word-wrap: break-word; }

.sidebar .row { margin-bottom: .75rem; }
.sidebar .label { font-size: .8em; text-transform: uppercase; letter-spacing: .03em; color: #666; }
.sidebar .value { font-weight: 600; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin-top: .5rem; }
.status-grid button { font-size: .85em; padding: .35rem .5rem; }

.pagination { display: flex; gap: .5rem; align-items: center; margin: 1rem 0; }
.pagination a, .pagination .current { padding: .25rem .55rem; border: 1px solid #c8cdd3; border-radius: 3px; color: #222; background: #fff; }
.pagination .current { background: var(--primary, #0b5394); color: #fff; border-color: transparent; }

.dropzone { border: 2px dashed #c8cdd3; border-radius: 6px; padding: 1.5rem; text-align: center; color: #666; }
.dropzone.over { border-color: var(--primary, #0b5394); background: #f0f6ff; }

.attachments-list { list-style: none; padding: 0; }
.attachments-list li { padding: .5rem 0; border-bottom: 1px solid #eaecef; display: flex; gap: .75rem; align-items: center; }
.attachments-list .scan { font-size: .8em; padding: .1rem .5rem; border-radius: 999px; }
.attachments-list .scan.clean   { background: #e6f4ea; color: #1b6b34; }
.attachments-list .scan.pending { background: #fff4ce; color: #806600; }
.attachments-list .scan.infected{ background: #fdecea; color: #a82a1f; }
.attachments-list .scan.error   { background: #eaecef; color: #444; }

/* ============================================================
   Public portal chrome (Freshdesk-style) — scoped to body.public
   so the agent UI keeps its own light header.
   ============================================================ */
body.public { background: #f4f5f7; }

/* Dark top bar with logo + agent login */
body.public .topbar { background: #2f3033; border-bottom: none; padding: 0; }
body.public .topbar .container { display: flex; align-items: center; justify-content: space-between; min-height: 58px; }
body.public .topbar .brand { color: #fff; font-weight: 600; font-size: 1.15rem; gap: .6rem; }
body.public .topbar .brand img { height: 34px; }
body.public .topbar-actions { display: flex; gap: 1.25rem; align-items: center; }
body.public .topbar-actions a { color: #cfd2d6; font-size: .88rem; }
body.public .topbar-actions a:hover { color: #fff; text-decoration: none; }

/* Brand-colored secondary nav with tabs */
.subnav { background: var(--primary, #0b5394); }
.subnav .container { display: flex; gap: 0; }
.subnav a {
    color: rgba(255,255,255,.82); padding: .8rem 1.25rem; font-size: .92rem;
    border-bottom: 3px solid transparent;
}
.subnav a:hover { color: #fff; text-decoration: none; background: rgba(0,0,0,.08); }
.subnav a.active { color: #fff; background: rgba(0,0,0,.12); border-bottom-color: rgba(255,255,255,.9); font-weight: 600; }

body.public main { padding: 1.75rem 0 2.5rem; }

/* Two-column portal: form left, helper aside right */
.portal { display: grid; grid-template-columns: 1fr 300px; gap: 2.5rem; align-items: start; }
@media (max-width: 820px) { .portal { grid-template-columns: 1fr; gap: 1.5rem; } }
.portal-title { font-size: 1.4rem; font-weight: 600; margin: 0 0 1.25rem; }
.portal-aside { color: #555; font-size: .9rem; }
.portal-aside h2 { font-size: 1rem; margin-top: 0; }

/* Ticket form */
.ticket-form .field { margin-bottom: 1.1rem; }
.ticket-form label { font-weight: 600; font-size: .85rem; color: #444; margin: 0 0 .35rem; }
.ticket-form .required { color: #d64545; font-weight: 700; }
.ticket-form input:focus, .ticket-form select:focus { outline: 2px solid var(--primary, #0b5394); outline-offset: -1px; border-color: transparent; }
.muted { color: #888; }
.form-actions { margin-top: 1.5rem; display: flex; gap: .6rem; align-items: center; }

/* Lightweight rich-text editor (contenteditable + toolbar) */
.rte { border: 1px solid #c8cdd3; border-radius: 4px; background: #fff; overflow: hidden; }
.rte:focus-within { outline: 2px solid var(--primary, #0b5394); outline-offset: -1px; border-color: transparent; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .15rem; padding: .35rem; background: #fafbfc; border-bottom: 1px solid #e1e4e8; }
.rte-toolbar button {
    background: none; border: 1px solid transparent; color: #444;
    min-width: 30px; height: 28px; padding: 0 .3rem; border-radius: 3px;
    font-size: .9rem; line-height: 1; cursor: pointer;
}
.rte-toolbar button:hover { background: #eceef1; border-color: #dfe2e6; opacity: 1; }
.rte-editor { min-height: 9rem; padding: .6rem .65rem; outline: none; font: inherit; }
.rte-editor:empty:before { content: attr(data-placeholder); color: #aaa; }

/* Attach-a-file disclosure link */
.attach-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--primary, #0b5394); cursor: pointer; font-weight: 600; font-size: .9rem; }
.attach-link:hover { text-decoration: underline; }
.attach-files input[type=file] { display: block; margin: .5rem 0 .25rem; }

/* Public footer with link groups */
body.public .footer { background: #fff; border-top: 1px solid #e1e4e8; margin-top: 2rem; }
body.public .footer .container { display: flex; align-items: center; justify-content: flex-start; gap: 2rem; }
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { color: #666; font-size: .85rem; }
.footer-copy { color: #999; }

/* ============================================================
   Responsive layout — ticket-list filter/bulk bars + mobile nav
   ============================================================ */

/* Ticket-list filter row (was an inline 5-col grid) and bulk-action bar.
   Defined as classes so the media queries below can reflow them. */
.filter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; align-items: end; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }

/* Hamburger toggle — hidden on desktop, revealed at the mobile breakpoint.
   Overrides the global filled-button styling so it reads as an icon button. */
.nav-toggle {
    display: none; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 36px; padding: 7px; background: none; border: 1px solid transparent;
    border-radius: 4px; color: #333; cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: currentColor; border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.nav-toggle:hover { background: rgba(0,0,0,.06); opacity: 1; }
.nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
body.public .nav-toggle { color: #fff; }
body.public .nav-toggle:hover { background: rgba(255,255,255,.14); }

/* Links shown only inside the collapsed mobile menu (e.g. Agent login). */
.mobile-only { display: none; }

@media (max-width: 1000px) {
    .filter-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
    .container { padding: 0 1rem; }

    .nav-toggle { display: flex; }
    .mobile-only { display: block; }

    /* --- Agent topbar: nav collapses behind the hamburger --- */
    .topbar .container { flex-wrap: wrap; }
    .topbar nav {
        display: none; flex-direction: column; align-items: stretch;
        width: 100%; gap: 0; padding: .25rem 0 .35rem;
    }
    .topbar nav.open { display: flex; }
    .topbar nav a, .topbar nav .who { padding: .6rem .25rem; width: 100%; }
    .topbar nav .who { color: #888; font-size: .85em; border-top: 1px solid #eaecef; border-left: none; margin-left: 0; }
    .topbar nav form { width: 100%; }
    .topbar nav .linkbtn { padding: .6rem .25rem; text-align: left; }

    /* --- Public topbar + subnav act as one collapsible menu --- */
    body.public .topbar .container { min-height: 0; padding: .55rem 0; }
    body.public .topbar .brand { font-size: 1.05rem; }
    body.public .topbar-actions { display: none; }   /* surfaced inside the menu instead */

    .subnav { display: none; }
    .subnav.open { display: block; }
    .subnav .container { flex-direction: column; padding: 0; }
    .subnav a {
        width: 100%; padding: .8rem 1.25rem; border-bottom: 3px solid transparent;
        border-left: 3px solid transparent; border-top: 1px solid rgba(255,255,255,.1);
    }
    .subnav a.active { border-bottom-color: transparent; border-left-color: rgba(255,255,255,.9); }

    /* Filter form collapses to a single column. */
    .filter-grid { grid-template-columns: 1fr; }

    .form-actions, .pagination { flex-wrap: wrap; }

    /* Wide data tables scroll horizontally instead of overflowing the page. */
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }

    /* Public footer stacks links over copyright. */
    body.public .footer .container { flex-direction: column; align-items: flex-start; gap: .75rem; }
    .footer-links { flex-wrap: wrap; gap: .5rem 1.25rem; }
}

@media (max-width: 460px) {
    h1 { font-size: 1.5rem; }
    .card { padding: 1rem; }
    .rte-editor { min-height: 7rem; }
    .status-grid { grid-template-columns: 1fr; }
}
