/* stylelint-disable no-descending-specificity */
/**
 * ITSM Helpdesk — Portal styles.
 *
 * Standalone stylesheet (not loaded via wp_enqueue). Bypasses theme entirely.
 * Design tokens aligned with the auth screen visual language.
 * Layout and component styling handled via inline Tailwind utilities;
 * this file covers resets, complex components (table, badges, conversation,
 * doc nav), and shared patterns (notices).
 */

/* -------------------------------------------------------------------------
   Custom properties.
   ------------------------------------------------------------------------- */

:root {
    --itsm-primary: #3f4afb;
    --itsm-primary-hover: #3339d6;
    --itsm-success: #00a32a;
    --itsm-danger: #d63638;
    --itsm-warning: #dba617;
    --itsm-info: #72aee6;
    --itsm-text: #111827;
    --itsm-text-light: #475467;
    --itsm-bg: #f2f2f4;
    --itsm-card-bg: #ffffff;
    --itsm-border: #d0d5dd;
    --itsm-border-light: #e5e7eb;
    --itsm-radius: 8px;
    --itsm-radius-lg: 12px;
    --itsm-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}

/* -------------------------------------------------------------------------
   Reset.
   ------------------------------------------------------------------------- */

*, *::before, *::after {
    box-sizing: border-box;
}

/* -------------------------------------------------------------------------
   Auth screen (canvas + dvh).
   ------------------------------------------------------------------------- */

body.itsm-portal-auth {
    min-height: 100vh;
    overflow: hidden;
    background: #f2f2f4;
}
@supports (min-height: 100dvh) {
    body.itsm-portal-auth {
        min-height: 100dvh;
    }
}

.itsm-portal-auth #wave-scene-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* -------------------------------------------------------------------------
   Notices.
   ------------------------------------------------------------------------- */

.itsm-notice {
    padding: 12px 16px;
    border-radius: var(--itsm-radius);
    margin-bottom: 16px;
    font-size: 14px;
    border-left: 4px solid;
}
.itsm-notice-error {
    background: #fcf0f1;
    border-color: var(--itsm-danger);
    color: #8a1a1d;
}
.itsm-notice-success {
    background: #edfaef;
    border-color: var(--itsm-success);
    color: #005c12;
}
.itsm-notice-info {
    background: #f0f6fc;
    border-color: var(--itsm-info);
    color: #1d4ed8;
}

/* -------------------------------------------------------------------------
   Ticket table.
   ------------------------------------------------------------------------- */

.itsm-ticket-control-grid:not(.hidden) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.itsm-ticket-control-grid > * {
    min-width: 0;
}
.itsm-ticket-control-grid input,
.itsm-ticket-control-grid select {
    width: 100%;
    min-width: 0;
}

.itsm-portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.itsm-portal-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f9fafb;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--itsm-text-light);
    border-bottom: 1px solid var(--itsm-border-light);
}
.itsm-portal-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--itsm-border-light);
    color: var(--itsm-text);
}
.itsm-portal-table tr:last-child td {
    border-bottom: none;
}
.itsm-portal-table tr:hover td {
    background: #f9fafb;
}
.itsm-portal-table a {
    color: var(--itsm-primary);
    text-decoration: none;
    font-weight: 500;
}
.itsm-portal-table a:hover {
    text-decoration: underline;
}

/* -------------------------------------------------------------------------
   Badges (status, priority).
   ------------------------------------------------------------------------- */

.itsm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    line-height: 1;
}
.itsm-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status badges */
.itsm-badge-new { background: #dbeafe; color: #1d4ed8; }
.itsm-badge-new .itsm-badge-dot { background: #3b82f6; }

.itsm-badge-in-progress { background: #fef9c3; color: #854d0e; }
.itsm-badge-in-progress .itsm-badge-dot { background: #eab308; }

.itsm-badge-awaiting-customer { background: #fce7f3; color: #be185d; }
.itsm-badge-awaiting-customer .itsm-badge-dot { background: #ec4899; }

.itsm-badge-awaiting-third-party { background: #e0e7ff; color: #4338ca; }
.itsm-badge-awaiting-third-party .itsm-badge-dot { background: #6366f1; }

.itsm-badge-resolved { background: #dcfce7; color: #15803d; }
.itsm-badge-resolved .itsm-badge-dot { background: #22c55e; }

.itsm-badge-closed { background: #f3f4f6; color: #4b5563; }
.itsm-badge-closed .itsm-badge-dot { background: #9ca3af; }

/* Priority badges */
.itsm-badge-p1 { background: #fee2e2; color: #b91c1c; }
.itsm-badge-p1 .itsm-badge-dot { background: #ef4444; }

.itsm-badge-p2 { background: #fef9c3; color: #854d0e; }
.itsm-badge-p2 .itsm-badge-dot { background: #eab308; }

.itsm-badge-p3 { background: #dbeafe; color: #1d4ed8; }
.itsm-badge-p3 .itsm-badge-dot { background: #3b82f6; }

.itsm-badge-p4 { background: #f3f4f6; color: #4b5563; }
.itsm-badge-p4 .itsm-badge-dot { background: #9ca3af; }

/* -------------------------------------------------------------------------
   Content area links (user-generated HTML in replies, docs, notices).
   ------------------------------------------------------------------------- */

.itsm-reply-body a,
.itsm-doc-content a,
.itsm-notice a {
    color: var(--itsm-primary);
    text-decoration: underline;
}
.itsm-reply-body a:hover,
.itsm-doc-content a:hover,
.itsm-notice a:hover {
    color: var(--itsm-primary-hover);
}

/* -------------------------------------------------------------------------
   Rich text editor.
   ------------------------------------------------------------------------- */

.itsm-rich-editor {
    overflow: hidden;
}
.itsm-rich-editor .wp-editor-wrap {
    border: 0;
}
.itsm-rich-editor .wp-editor-tools {
    padding: 8px 8px 0;
    background: #f9fafb;
}
.itsm-rich-editor .wp-editor-container {
    border: 0;
}
.itsm-rich-editor .mce-toolbar-grp,
.itsm-rich-editor .quicktags-toolbar {
    border-right: 0;
    border-left: 0;
}
.itsm-rich-editor textarea.wp-editor-area {
    width: 100%;
    border: 0;
    padding: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--itsm-text);
    outline: none;
}

/* -------------------------------------------------------------------------
   Conversation thread.
   ------------------------------------------------------------------------- */

.itsm-reply {
    background: var(--itsm-card-bg);
    border: 1px solid var(--itsm-border-light);
    border-radius: var(--itsm-radius);
    padding: 16px 20px;
    margin-bottom: 12px;
}
.itsm-reply:last-child {
    margin-bottom: 0;
}
.itsm-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    font-size: 14px;
}
.itsm-reply-header strong {
    font-size: 14px;
    color: var(--itsm-text);
}
.itsm-reply-date {
    color: var(--itsm-text-light);
    font-size: 13px;
}
.itsm-reply-body {
    font-size: 15px;
    line-height: 1.65;
    color: var(--itsm-text);
}
.itsm-reply-body p {
    margin: 0 0 8px;
}
.itsm-reply-body p:last-child {
    margin-bottom: 0;
}
.itsm-reply-body ul,
.itsm-reply-body ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}
.itsm-reply-body ul {
    list-style: disc;
}
.itsm-reply-body ol {
    list-style: decimal;
}
.itsm-reply-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--itsm-radius);
}
.itsm-reply-body figure {
    margin: 1em 0;
}
.itsm-reply-body iframe,
.itsm-reply-body video {
    max-width: 100%;
}

/* Reply type indicators */
.itsm-reply-description {
    border-left: 3px solid var(--itsm-border);
}
.itsm-reply-customer {
    border-left: 3px solid var(--itsm-primary);
}
.itsm-reply-analyst {
    border-left: 3px solid var(--itsm-success);
}

.itsm-ticket-discussion {
    margin-top: 24px;
}
.itsm-discussion-composer {
    margin-bottom: 16px;
}
.itsm-discussion-composer form {
    margin: 0;
}
.itsm-discussion-thread .itsm-reply:last-child {
    margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   Documentation layout (sidebar + main).
   ------------------------------------------------------------------------- */

.itsm-docs-layout {
    display: flex;
    gap: 32px;
}
.itsm-docs-sidebar {
    width: 240px;
    flex-shrink: 0;
}

/* Doc nav tree */
.itsm-doc-nav-root {
    list-style: none;
    padding: 0;
    margin: 0;
}
.itsm-doc-nav-list {
    list-style: none;
    padding-left: 14px;
    margin: 2px 0;
}
.itsm-doc-nav-list li {
    padding: 4px 0;
    font-size: 14px;
}
.itsm-doc-nav-list li a {
    color: var(--itsm-text);
    text-decoration: none;
    transition: color 0.15s;
}
.itsm-doc-nav-list li a:hover {
    color: var(--itsm-primary);
}
.itsm-doc-nav-active > a {
    color: var(--itsm-primary);
    font-weight: 600;
}

/* Doc content — prose resets to counteract Tailwind Preflight stripping
   heading sizes, list bullets, and block spacing from user-generated HTML. */
.itsm-doc-content {
    background: var(--itsm-card-bg);
    border: 1px solid var(--itsm-border-light);
    border-radius: var(--itsm-radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    line-height: 1.7;
}
.itsm-doc-content h1 {
    font-size: 1.75em;
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
.itsm-doc-content h2 {
    font-size: 1.375em;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
.itsm-doc-content h3 {
    font-size: 1.125em;
    font-weight: 600;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
.itsm-doc-content h1:first-child,
.itsm-doc-content h2:first-child,
.itsm-doc-content h3:first-child {
    margin-top: 0;
}
.itsm-doc-content p {
    margin: 0 0 0.75em;
}
.itsm-doc-content p:last-child {
    margin-bottom: 0;
}
.itsm-doc-content ul,
.itsm-doc-content ol {
    padding-left: 1.5em;
    margin: 0.75em 0;
}
.itsm-doc-content ul {
    list-style: disc;
}
.itsm-doc-content ol {
    list-style: decimal;
}
.itsm-doc-content blockquote {
    border-left: 3px solid var(--itsm-border);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--itsm-text-light);
}
.itsm-doc-content pre {
    background: #f9fafb;
    padding: 1em;
    border-radius: var(--itsm-radius);
    overflow-x: auto;
    font-family: monospace;
}
.itsm-doc-content code {
    font-family: monospace;
}
.itsm-doc-content img {
    max-width: 100%;
    height: auto;
}
.itsm-doc-content table {
    width: 100%;
    border-collapse: collapse;
}
.itsm-doc-content table th,
.itsm-doc-content table td {
    padding: 0.5em 0.75em;
    border: 1px solid var(--itsm-border-light);
    text-align: left;
}

/* -------------------------------------------------------------------------
   Responsive.
   ------------------------------------------------------------------------- */

@media (max-width: 640px) {
    body.itsm-portal-auth {
        overflow-y: auto;
    }
    .itsm-ticket-control-grid:not(.hidden) {
        grid-template-columns: 1fr;
    }
    .itsm-portal-table {
        font-size: 13px;
    }
    .itsm-portal-table th,
    .itsm-portal-table td {
        padding: 10px 12px;
    }
    .itsm-docs-layout {
        flex-direction: column;
    }
    .itsm-docs-sidebar {
        width: 100%;
    }
}

/* -------------------------------------------------------------------------
   Tabs.
   ------------------------------------------------------------------------- */

.itsm-tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--itsm-text-light);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.itsm-tab:hover {
    color: var(--itsm-text);
}
.itsm-tab-active {
    color: var(--itsm-primary);
    border-bottom-color: var(--itsm-primary);
}
.itsm-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    margin-left: 4px;
    background: #e9ecef;
    color: #495057;
}
.itsm-tab-active .itsm-tab-count {
    background: #e7f0ff;
    color: var(--itsm-primary);
}

/* -------------------------------------------------------------------------
   Ticket table — clickable rows & search spinner.
   ------------------------------------------------------------------------- */

.itsm-portal-table tbody tr[data-href] {
    cursor: pointer;
}

@keyframes itsm-spin {
    to { transform: rotate(360deg); }
}
.itsm-search-loading {
    animation: itsm-spin 1s linear infinite;
}
