/* Portal tokens + components shared by customer/dashboard.html,
   support-portal.html and app/login.html. Page layout stays inline. */
:root {
    --c-primary: #1565C0;
    --c-primary-hover: #0D47A1;
    --c-text: #1E293B;
    --c-text-muted: #64748B;
    --c-bg: #F8FAFC;
    --c-surface: #FFFFFF;
    --c-border: #E2E8F0;
    --c-border-input: #7D8BA0;
    --c-focus-ring: rgba(21, 101, 192, 0.2);
    --radius: 12px;
    --mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    min-height: 100vh;
    line-height: 1.5;
}

[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.skip-link {
    position: absolute; top: -40px; left: 0;
    background: var(--c-primary); color: white;
    padding: 8px 16px; text-decoration: none;
    border-radius: 0 0 4px 0; z-index: 100;
}
.skip-link:focus { top: 0; }

/* Top bar */
.topbar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 16px 24px;
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand img { height: 32px; display: block; }
.topbar-brand-text { font-size: 15px; font-weight: 600; color: var(--c-text-muted); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 10px 20px;
    border-radius: var(--radius); border: 1px solid transparent;
    font: inherit; font-size: 15px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--c-primary); color: white; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-primary:disabled { background: #CBD5E1; color: #475569; cursor: not-allowed; }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-input); }
.btn-secondary:hover { background: var(--c-bg); }
.btn-small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* Tabs */
.tabs {
    display: flex; gap: 4px; padding: 4px; margin-bottom: 16px;
    background: #EEF2F7; border-radius: var(--radius);
}
.tab {
    flex: 1; min-height: 44px;
    border: none; border-radius: 9px; background: transparent;
    font: inherit; font-size: 15px; font-weight: 600; color: var(--c-text-muted);
    cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--c-surface); color: var(--c-primary); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1); }

/* Cards */
.card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); padding: 32px; margin-bottom: 20px;
}
.card-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; overflow-wrap: anywhere; }
.card-intro { font-size: 14px; color: var(--c-text-muted); margin-bottom: 24px; }

/* Form controls */
.field { margin-bottom: 20px; }
.field-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.field-optional { font-weight: 400; color: var(--c-text-muted); }
.field-help { font-size: 13px; color: var(--c-text-muted); margin-top: 6px; }
.input {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--c-border-input); border-radius: var(--radius);
    font: inherit; font-size: 16px; color: var(--c-text); background: var(--c-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-focus-ring); }
.input::placeholder { color: var(--c-text-muted); }
textarea.input { min-height: 160px; resize: vertical; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert.error { background: #FEE2E2; color: #7F1D1D; border: 1px solid #FCA5A5; }
.alert.success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }

/* Status badges — text label always present, color is reinforcement only */
.status-badge {
    display: inline-block; white-space: nowrap;
    padding: 4px 12px; border-radius: 999px;
    font-size: 13px; font-weight: 600;
}
.status-badge.received    { background: #F1F5F9; color: #334155; }
.status-badge.queued      { background: #FEF3C7; color: #92400E; }
.status-badge.in-progress { background: #DBEAFE; color: #1E40AF; }
.status-badge.in-review   { background: #EDE9FE; color: #5B21B6; }
.status-badge.done        { background: #D1FAE5; color: #065F46; }
.status-badge.needs-reply { background: #FFEDD5; color: #9A3412; box-shadow: inset 0 0 0 1px #FDBA74; }

/* Ticket metadata */
.meta-field { display: flex; flex-direction: column; gap: 4px; }
.meta-label { font-size: 12px; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.meta-value { font-size: 14px; font-weight: 500; text-transform: capitalize; }

/* Rich text (sanitized ticket/message HTML) */
.rich-text { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.rich-text p, .rich-text ul, .rich-text ol, .rich-text pre, .rich-text blockquote { margin-bottom: 10px; }
.rich-text p:last-child { margin-bottom: 0; }
.rich-text ul, .rich-text ol { padding-left: 24px; }
.rich-text a { color: var(--c-primary); }
.rich-text.plain { white-space: pre-wrap; }

/* Conversation */
.message-list { display: flex; flex-direction: column; gap: 12px; }
.message { padding: 16px; border-radius: var(--radius); border: 1px solid var(--c-border); }
.message.from-support { background: #EFF6FF; border-color: #BFDBFE; }
.message.from-customer { background: var(--c-surface); margin-left: 32px; }
.message-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.message-sender { font-size: 13px; font-weight: 700; }
.message.from-support .message-sender { color: #1E40AF; }
.message-time { font-size: 12px; color: var(--c-text-muted); }
.message .rich-text { font-size: 14px; }

.muted { color: var(--c-text-muted); font-size: 14px; }

@media (max-width: 768px) {
    .topbar { padding: 12px 16px; }
    .card { padding: 24px 16px; }
    .message.from-customer { margin-left: 0; }
}
