/* FIMC Service Desk + member support — mobile-friendly layout */

.ticket-app .ticket-summary-info th[scope='row'] {
    white-space: nowrap;
    width: 1%;
    max-width: 11rem;
    vertical-align: top;
}

/* Super-admin inline edit for conversation/timeline (emoji toggle + compact save) */
.ticket-super-msg-edit {
    display: inline-block;
    margin-left: 4px;
    vertical-align: baseline;
}

.ticket-super-msg-edit > .ticket-super-msg-edit-sum {
    cursor: pointer;
    list-style: none;
    display: inline-block;
    line-height: 1;
    user-select: none;
    font-size: 1em;
    vertical-align: middle;
}

.ticket-super-msg-edit > .ticket-super-msg-edit-sum::-webkit-details-marker {
    display: none;
}

.ticket-super-msg-edit > .ticket-super-msg-edit-sum::marker {
    content: '';
}

.ticket-super-msg-edit-form {
    margin-top: 10px;
    max-width: 100%;
}

.ticket-super-msg-edit-actions {
    margin: 8px 0 0 0;
}

.ticket-super-msg-save {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.15em;
    line-height: 1;
    padding: 2px 4px;
    vertical-align: middle;
}

.ticket-super-msg-save:hover {
    filter: brightness(1.15);
}
/* index_table (2025style) sets overflow:hidden which clips button shadows; ticket pages need visible.
   Do not force width:100% here — that overrides site .index_table (1000px / 98%) and inline max-width on support/KB. */
.ticket-app.index_table {
    min-width: 0;
    overflow: visible !important;
}

/* Narrow screens: theme .index_table uses width:1000px !important + overflow visible lets
   wide tables/shadows widen the document — clip horizontally and fit the viewport. */
@media (max-width: 768px) {
    .ticket-app.index_table {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0;
        margin-right: 0;
        overflow-y: visible !important;
        overflow-x: hidden !important;
        overflow-x: clip !important;
    }

    .ticket-app .ticket-table-scroll table {
        min-width: 0;
        width: 100%;
    }

    .ticket-app .ticket-summary-info th[scope='row'] {
        white-space: normal;
        width: auto;
        max-width: 40%;
    }

    .ticket-app div.w3-border.w3-padding.w3-margin-bottom {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
}

/* 2025style sets div.container { word-break: break-all } — breaks normal prose mid-word on ticket/KB pages */
.ticket-app.container {
    word-break: normal;
    overflow-wrap: break-word;
}

.ticket-app {
    box-sizing: border-box;
    min-width: 0;
    padding: 12px !important;
    overflow-x: hidden;
}

/* Solid, tactile buttons — rounded + shadow (overflow visible on .ticket-app.index_table so shadows show) */
.ticket-app button.w3-button,
.ticket-app a.w3-button,
.ticket-app input[type="submit"].w3-button,
.ticket-app span.w3-button {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px !important;
    -webkit-border-radius: 8px !important;
    border: none !important;
    box-sizing: border-box !important;
    min-height: 40px !important;
    padding: 8px 16px !important;
    font-size: 0.9375rem !important;
    line-height: 1.2 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    text-decoration: none !important;
    vertical-align: middle !important;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.34),
        0 3px 8px rgba(0, 0, 0, 0.22) !important;
    transition: box-shadow 0.15s ease, transform 0.1s ease, filter 0.15s ease;
}

.ticket-app a.w3-button:hover,
.ticket-app button.w3-button:hover:not(:disabled),
.ticket-app input[type="submit"].w3-button:hover:not(:disabled) {
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.38),
        0 4px 14px rgba(0, 0, 0, 0.2) !important;
    filter: brightness(1.05);
}

.ticket-app a.w3-button:active,
.ticket-app button.w3-button:active:not(:disabled),
.ticket-app input[type="submit"].w3-button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28) !important;
}

.ticket-app span.w3-button[style*="cursor:default"] {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22) !important;
    opacity: 0.95;
}

/* Explicit pill class — wins over theme + W3 when combined with .w3-button */
.ticket-app a.ticket-ui-btn.w3-button,
.ticket-app button.ticket-ui-btn.w3-button,
.ticket-app span.ticket-ui-btn.w3-button,
.ticket-app input[type="submit"].ticket-ui-btn.w3-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    border-radius: 8px !important;
    -webkit-border-radius: 8px !important;
    border: none !important;
    box-sizing: border-box !important;
    min-height: 40px !important;
    padding: 8px 16px !important;
    font-size: 0.9375rem !important;
    line-height: 1.2 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    text-decoration: none !important;
    vertical-align: middle !important;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.34),
        0 3px 8px rgba(0, 0, 0, 0.22) !important;
    transition: box-shadow 0.15s ease, transform 0.1s ease, filter 0.15s ease;
}

.ticket-app a.ticket-ui-btn.w3-button:hover,
.ticket-app button.ticket-ui-btn.w3-button:hover:not(:disabled),
.ticket-app span.ticket-ui-btn.w3-button:hover:not([style*="cursor:default"]) {
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.38),
        0 4px 14px rgba(0, 0, 0, 0.2) !important;
    filter: brightness(1.05);
}

.ticket-app .ticket-support-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.ticket-app .ticket-support-btn-row .ticket-ui-btn.w3-button {
    width: 100% !important;
    max-width: none !important;
}

.ticket-app .ticket-support-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin: 16px 0;
    width: 100%;
}

@media (max-width: 480px) {
    .ticket-app .ticket-support-btn-row {
        grid-template-columns: 1fr;
    }
}

/* Default fill when no W3 color class (should be rare after markup pass) */
.ticket-app .w3-button.w3-light-grey,
.ticket-app .w3-button.w3-grey {
    color: #fff !important;
}

.ticket-app .w3-input,
.ticket-app .w3-select,
.ticket-app input[type="text"],
.ticket-app input[type="search"],
.ticket-app input[type="number"],
.ticket-app input[type="date"],
.ticket-app input[type="email"],
.ticket-app input[type="url"],
.ticket-app textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ticket-app input[type="file"] {
    max-width: 100%;
    box-sizing: border-box;
}

/* Member ticket view: file row + primary actions share height and full width */
.ticket-app .ticket-action-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    margin-top: 12px;
}

.ticket-app .ticket-action-stack > form {
    margin: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ticket-app .ticket-file-row {
    margin: 10px 0 0 0;
    width: 100%;
}

.ticket-app .ticket-file-label {
    display: block;
    margin-bottom: 4px;
}

.ticket-app .ticket-file-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 2.75rem;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    line-height: 1.35;
    border: 1px solid rgba(160, 160, 160, 0.55);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.ticket-app .ticket-file-input:hover {
    border-color: rgba(200, 200, 200, 0.65);
}

.ticket-app .ticket-file-input:focus {
    outline: 2px solid rgba(100, 160, 255, 0.45);
    outline-offset: 1px;
}

.ticket-app .ticket-file-input::file-selector-button {
    min-height: 2rem;
    margin-right: 0.75rem;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    background: #e0e0e0;
    color: #222;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.ticket-app .ticket-file-input::file-selector-button:hover {
    filter: brightness(1.06);
}

.ticket-app .ticket-file-input::-webkit-file-upload-button {
    min-height: 2rem;
    margin-right: 0.75rem;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    background: #e0e0e0;
    color: #222;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Match stacked buttons to .ticket-file-input rhythm (full width, tactile) */
.ticket-app .ticket-btn-block.w3-button,
.ticket-app .ticket-action-stack button.ticket-btn-block.w3-button,
.ticket-app .ticket-action-stack a.ticket-btn-block.w3-button {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box !important;
    min-height: 2.75rem !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.9375rem !important;
    line-height: 1.35 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    margin: 0 !important;
    border-radius: 8px !important;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.34),
        0 3px 8px rgba(0, 0, 0, 0.22) !important;
}

.ticket-app .ticket-action-stack .w3-orange {
    color: #1a1a1a !important;
    font-weight: 600;
}

.ticket-app form {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
}

.ticket-app form.w3-padding {
    padding: 10px !important;
}

.ticket-app form > p {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

.ticket-app a {
    overflow-wrap: break-word;
    word-break: normal;
}

/* Admin ticket view: meta form grid without horizontal overflow */
.ticket-meta-grid {
    display: grid;
    /* One column on phones — two×200px min columns overflow ~360px viewports */
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ticket-meta-grid > label {
    display: block;
    min-width: 0;
    max-width: 100%;
}

.ticket-app .ticket-meta-grid select.w3-select {
    min-height: 40px;
    box-sizing: border-box;
    border-radius: 8px;
}

@media (min-width: 640px) {
    .ticket-meta-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    }
}

.ticket-app h1 {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    word-break: break-word;
}

.ticket-nav-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.ticket-nav-bar a {
    word-break: normal;
    overflow-wrap: break-word;
}

/* Timeline bodies: nl2br() only — do not combine with pre-wrap (double line breaks). */
.ticket-app .ticket-message-body {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.ticket-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    max-width: 100%;
}

.ticket-search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.ticket-search-row .ticket-search-type {
    flex: 1 1 140px;
    min-width: 0;
}

.ticket-search-row .ticket-search-input {
    flex: 2 1 200px;
    min-width: 0;
}

.ticket-search-row .ticket-search-actions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ticket-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    width: 100%;
}

.ticket-filters-row label {
    flex: 1 1 140px;
    min-width: 0;
    font-size: 0.85rem;
}

.ticket-filters-row select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ticket-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
}

.ticket-table-scroll table {
    min-width: 520px;
}

.ticket-table-scroll td,
.ticket-table-scroll th {
    word-break: normal;
    overflow-wrap: break-word;
    vertical-align: top;
}

.ticket-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 12px 0;
}

.ticket-actions-row .w3-button {
    margin: 0;
}

@media (max-width: 600px) {
    .ticket-search-row {
        flex-direction: column;
    }

    .ticket-search-row .ticket-search-type,
    .ticket-search-row .ticket-search-input,
    .ticket-search-row .ticket-search-actions {
        flex: 1 1 100%;
        width: 100%;
    }

    .ticket-search-row .w3-button {
        width: 100%;
    }
}

/* Compact actions — same visual language, slightly denser */
.ticket-app .w3-button.ticket-btn-compact {
    min-height: 32px !important;
    padding: 6px 14px !important;
    font-size: 0.875rem !important;
    line-height: 1.25 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.32),
        0 2px 6px rgba(0, 0, 0, 0.18) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* W3 default buttons are tall — tighten on small screens (not full-width ticket reply stack) */
@media (max-width: 639px) {
    .ticket-app .w3-button:not(.ticket-btn-block):not(.ticket-btn-compact):not(.ticket-ui-btn) {
        padding: 0.35rem 0.75rem !important;
        font-size: 0.8125rem !important;
        line-height: 1.25 !important;
    }
}

.ticket-app .w3-button.ticket-btn-compact:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ticket-ownership-bar {
    margin-bottom: 12px;
}

.ticket-ownership-bar .ticket-ownership-label {
    margin: 0 0 6px 0;
    font-size: 0.9rem;
}

.ticket-ownership-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ticket-ownership-actions form {
    margin: 0;
}

/* Admin ticket view — audit JSON and action codes */
.ticket-app .ticket-audit-log {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ticket-app .ticket-audit-log code {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Admin queue: unassigned rows — yellow text (links inherit theme blue otherwise) */
.ticket-queue-table tr.ticket-queue-row-unassigned,
.ticket-queue-table tr.ticket-queue-row-unassigned td {
    color: #ffeb3b !important;
}

.ticket-queue-table tr.ticket-queue-row-unassigned a.ticket-queue-ticket-link {
    color: #ffeb3b !important;
}

/* Queue age (SLA): fixed colors; thresholds from Ticket settings */
.ticket-queue-age {
    font-weight: 700;
    white-space: nowrap;
}

.ticket-queue-age-green {
    color: #2e7d32 !important;
}

.ticket-queue-age-yellow {
    color: #f9a825 !important;
}

.ticket-queue-age-orange {
    color: #ef6c00 !important;
}

.ticket-queue-age-red {
    color: #d32f2f !important;
}

@keyframes ticket-queue-sla-blink {
    0%,
    100% {
        opacity: 1;
        color: #d32f2f;
    }

    50% {
        opacity: 0.35;
        color: #ff1744;
    }
}

.ticket-queue-age-blink {
    animation: ticket-queue-sla-blink 1s ease-in-out infinite;
}

.ticket-queue-table tr.ticket-queue-row-unassigned .ticket-queue-age-green {
    color: #2e7d32 !important;
}

.ticket-queue-table tr.ticket-queue-row-unassigned .ticket-queue-age-yellow {
    color: #f9a825 !important;
}

.ticket-queue-table tr.ticket-queue-row-unassigned .ticket-queue-age-orange {
    color: #ef6c00 !important;
}

.ticket-queue-table tr.ticket-queue-row-unassigned .ticket-queue-age-red {
    color: #d32f2f !important;
}

.ticket-queue-table tr.ticket-queue-row-unassigned .ticket-queue-age-blink {
    animation: ticket-queue-sla-blink 1s ease-in-out infinite;
}

/* KB: category filters (admin list + member KB + article) */
.ticket-app .kb-category-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 12px 0 16px 0;
}

.ticket-app .kb-category-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 153, 51, 0.55);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.2;
    color: inherit;
    box-sizing: border-box;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: normal;
}

.ticket-app .kb-category-pill:hover {
    border-color: rgba(255, 180, 120, 0.9);
    filter: brightness(1.08);
}

.ticket-app .kb-category-pill.kb-category-active {
    background: rgba(255, 153, 51, 0.25);
    border-color: rgba(255, 180, 120, 1);
    font-weight: 600;
}

.ticket-app .kb-admin-list th,
.ticket-app .kb-admin-list td {
    vertical-align: top;
}
