/* ============================================================
   WMC Operations Ticketing System — Styles
   ============================================================ */

:root {
    --wmc-primary: #1a237e;
    --wmc-primary-light: #534bae;
    --wmc-accent: #ff6f00;
    --wmc-success: #4caf50;
    --wmc-warning: #ff9800;
    --wmc-danger: #f44336;
    --wmc-muted: #607d8b;
    --wmc-bg: #f5f5f5;
    --wmc-card-bg: #ffffff;
    --wmc-border: #e0e0e0;
    --wmc-text: #212121;
    --wmc-text-secondary: #757575;
    --wmc-radius: 6px;
    --wmc-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
}

/* ---- Layout ---- */
.ticket-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--wmc-primary);
}

.ticket-header h1 {
    font-size: 24px;
    color: var(--wmc-primary);
    margin: 0;
}

/* ---- Choose One Landing ---- */
.choose-one-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 800px;
    margin: 40px auto;
}

.choose-card {
    background: var(--wmc-card-bg);
    border: 2px solid var(--wmc-border);
    border-radius: var(--wmc-radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--wmc-shadow);
}

.choose-card:hover {
    border-color: var(--wmc-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    text-decoration: none;
}

.choose-card:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

.choose-card h2 {
    font-size: 20px;
    color: var(--wmc-primary);
    margin-bottom: 12px;
}

.choose-card p {
    color: var(--wmc-text-secondary);
    font-size: 14px;
    margin: 0;
}

/* ---- Step Indicators ---- */
.step-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--wmc-bg);
    color: var(--wmc-text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.step-indicator.active {
    background: var(--wmc-primary);
    color: #fff;
}

.step-indicator.completed {
    background: var(--wmc-success);
    color: #fff;
}

.step-panel { display: none; }
.step-panel.active { display: block; }

/* ---- Search Bar ---- */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
    padding: 10px 16px;
    font-size: 15px;
    border: 2px solid var(--wmc-border);
    border-radius: var(--wmc-radius);
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--wmc-primary);
}

.search-bar input:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

/* ---- Filter Panel ---- */
.filter-panel {
    background: var(--wmc-card-bg);
    border: 1px solid var(--wmc-border);
    border-radius: var(--wmc-radius);
    padding: 16px;
    margin-bottom: 16px;
    transition: max-height 0.3s ease;
}

.filter-panel.collapsed {
    max-height: 0;
    padding: 0 16px;
    overflow: hidden;
    border: none;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--wmc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--wmc-border);
    border-radius: 4px;
    background: #fff;
}

/* ---- Results Table ---- */
.results-wrapper {
    display: flex;
    gap: 16px;
}

.results-main {
    flex: 1;
    overflow-x: auto;
    max-width: 100%;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    -webkit-overflow-scrolling: touch;
}

.results-main .results-table {
    min-width: 1200px;
}

.results-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--wmc-card-bg);
    border-radius: var(--wmc-radius);
    overflow: hidden;
    box-shadow: var(--wmc-shadow);
}

.results-table thead th {
    background: var(--wmc-primary);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: default;
    white-space: nowrap;
    user-select: none;
}

.results-table thead th[data-sort-column] {
    cursor: pointer;
}

.results-table thead th:hover {
    background: var(--wmc-primary-light);
}

.results-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--wmc-border);
    white-space: nowrap;
}

.results-table tbody tr:hover {
    background: #e3f2fd;
}

.results-table tbody tr.selected {
    background: #c8e6c9;
}

.item-row .item-no {
    font-weight: 600;
    color: var(--wmc-primary);
}

.btn-expand {
    background: none;
    border: 1px solid var(--wmc-border);
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wmc-text-secondary);
}

.btn-expand:hover {
    background: var(--wmc-bg);
    color: var(--wmc-primary);
}

.btn-expand:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

/* ---- Subgrid ---- */
.subgrid-row td {
    padding: 0 !important;
    background: #fafafa;
}

.subgrid-container {
    padding: 12px 24px;
}

.subgrid-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--wmc-border);
    padding-bottom: 4px;
}

.subgrid-tab {
    padding: 6px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--wmc-text-secondary);
    border-radius: 4px 4px 0 0;
    transition: all 0.15s;
}

.subgrid-tab:hover {
    background: var(--wmc-bg);
    color: var(--wmc-text);
}

.subgrid-tab.active {
    background: var(--wmc-primary);
    color: #fff;
}

.subgrid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.subgrid-table th,
.subgrid-table td {
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--wmc-border);
}

.subgrid-table th {
    background: #eceff1;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

.subgrid-table .label-cell {
    font-weight: 600;
    color: var(--wmc-text-secondary);
    width: 220px;
}

.subgrid-summary {
    padding: 8px 0;
    font-size: 13px;
    color: var(--wmc-text-secondary);
}

/* ---- Selection Cart / Sidebar ---- */
.selection-cart {
    width: 280px;
    min-width: 280px;
    background: var(--wmc-card-bg);
    border: 1px solid var(--wmc-border);
    border-radius: var(--wmc-radius);
    padding: 16px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 80px;
    box-shadow: var(--wmc-shadow);
}

.selection-cart h3 {
    font-size: 14px;
    color: var(--wmc-primary);
    margin: 0 0 12px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-count-badge {
    background: var(--wmc-accent);
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--wmc-border);
    font-size: 12px;
}

.cart-item-no {
    font-weight: 600;
    color: var(--wmc-primary);
    min-width: 70px;
}

.cart-item-desc {
    flex: 1;
    color: var(--wmc-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-remove {
    background: none;
    border: none;
    color: #b91c1c;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    padding: 0 4px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cart-remove:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

.cart-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ---- Pagination ---- */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 8px 0;
}

.results-count {
    font-size: 13px;
    color: var(--wmc-text-secondary);
}

.pagination {
    display: flex;
    gap: 4px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--wmc-border);
    background: var(--wmc-card-bg);
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.15s;
}

.page-btn:hover:not([disabled]) {
    background: var(--wmc-primary);
    color: #fff;
    border-color: var(--wmc-primary);
}

.page-btn.active {
    background: var(--wmc-primary);
    color: #fff;
    border-color: var(--wmc-primary);
}

.page-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-ellipsis {
    padding: 6px 8px;
    color: var(--wmc-text-secondary);
}

/* ---- Action Type Grid ---- */
.action-category {
    margin-bottom: 20px;
}

.category-title {
    font-size: 14px;
    color: var(--wmc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--wmc-border);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
}

.action-type-btn {
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    border: 1px solid var(--wmc-border);
    border-radius: var(--wmc-radius);
    background: var(--wmc-card-bg);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
    font-size: 13px;
}

.action-type-btn:hover {
    border-color: var(--wmc-primary);
    background: #e8eaf6;
}

.action-type-btn.selected {
    border-color: var(--wmc-primary);
    background: #c5cae9;
}

.action-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--wmc-text);
}

.action-group {
    font-size: 11px;
    color: #616161;
    margin-top: 2px;
}

/* ---- Form Elements ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--wmc-text);
    margin-bottom: 4px;
}

.form-group textarea,
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--wmc-border);
    border-radius: 4px;
    font-size: 14px;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* ---- Buttons (wmc- prefix to avoid Bootstrap collision) ----
   WCAG AA: all combos tested ≥ 4.5:1 contrast ratio
   Primary  #1a237e on #fff = 12.5:1
   Success  #1b6d21 on #fff =  6.5:1
   Danger   #b91c1c on #fff =  5.9:1
   Secondary #212121 on #f5f5f5 = 14.5:1
   ------------------------------------------------------------ */
.wmc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: var(--wmc-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.wmc-btn:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

.wmc-btn-primary {
    background: #1a237e;
    color: #fff;
    border-color: #1a237e;
}
.wmc-btn-primary:hover { background: #283593; border-color: #283593; color: #fff; }
.wmc-btn-primary:active { background: #0d1559; }

.wmc-btn-secondary {
    background: #f5f5f5;
    color: #212121;
    border-color: #bdbdbd;
}
.wmc-btn-secondary:hover { background: #e0e0e0; border-color: #9e9e9e; color: #212121; }
.wmc-btn-secondary:active { background: #d5d5d5; }

.wmc-btn-success {
    background: #1b6d21;
    color: #fff;
    border-color: #1b6d21;
}
.wmc-btn-success:hover { background: #237a29; border-color: #237a29; color: #fff; }
.wmc-btn-success:active { background: #145418; }

.wmc-btn-danger {
    background: #b91c1c;
    color: #fff;
    border-color: #b91c1c;
}
.wmc-btn-danger:hover { background: #d32f2f; border-color: #d32f2f; color: #fff; }
.wmc-btn-danger:active { background: #991b1b; }

.wmc-btn:disabled,
.wmc-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Landing page cards */
.wmc-landing-cards {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}
.wmc-landing-card {
    display: block;
    padding: 30px;
    border-radius: 8px;
    text-decoration: none;
    min-width: 200px;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
}
.wmc-landing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.wmc-landing-card:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}
.wmc-landing-card h3 { margin: 0 0 8px 0; color: #fff; }
.wmc-landing-card p { margin: 0; opacity: 0.85; }
/* Card variants — all white text, WCAG AA compliant backgrounds
   #1a237e on #fff = 12.5:1, #1e40af on #fff = 7.3:1, #374151 on #fff = 10.3:1 */
.wmc-landing-card--submit { background: #1a237e; color: #fff; }
.wmc-landing-card--submit:hover { background: #283593; }
.wmc-landing-card--tickets { background: #1e40af; color: #fff; }
.wmc-landing-card--tickets:hover { background: #1e3a8a; }
.wmc-landing-card--backend { background: #374151; color: #fff; }
.wmc-landing-card--backend:hover { background: #4b5563; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff3e0; color: #bf360c; } /* was #e65100 (4.2:1 fail), now #bf360c (6.1:1 pass) */
.badge-danger { background: #ffebee; color: #c62828; }
.badge-muted { background: #eceff1; color: #546e7a; }
.badge-info { background: #e3f2fd; color: #1565c0; }

/* ---- Loading Overlay ---- */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    text-align: center;
    color: var(--wmc-primary);
    font-size: 14px;
}

/* ---- Error Message ---- */
.error-message {
    display: none;
    background: #ffebee;
    color: #c62828;
    padding: 12px 16px;
    border-radius: var(--wmc-radius);
    margin-bottom: 16px;
    font-size: 14px;
}

/* ---- Success Panel ---- */
.success-panel {
    text-align: center;
    padding: 40px;
}

.success-panel h2 {
    color: #2e7d32; /* was #4caf50 (3.0:1 fail), now #2e7d32 (5.0:1 pass) */
    font-size: 24px;
}

/* ---- Focus visible for all interactive elements ---- */
.subgrid-tab:focus-visible,
.page-btn:focus-visible,
.action-type-btn:focus-visible,
.queue-tab:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

.form-group textarea:focus-visible,
.form-group input:focus-visible,
.form-group select:focus-visible,
.filter-group select:focus-visible,
.filter-group input:focus-visible {
    outline: 3px solid #2563EB;
    outline-offset: 2px;
}

/* ---- Missing class definitions ---- */
.shopify-light { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.shopify-green { background: #2e7d32; }
.shopify-yellow { background: #f9a825; }
.shopify-red { background: #c62828; }

.ticket-count { display: inline-block; font-weight: 600; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.ticket-count.has-open { background: #ffebee; color: #c62828; cursor: pointer; }
.ticket-count.no-open { color: #9e9e9e; }

/* ---- Item Ticket Badges ---- */
.tkt-item-badge { display:inline-block; padding:2px 8px; border-radius:12px; font-size:11px; font-weight:600; cursor:pointer; transition:opacity 0.15s; }
.tkt-item-badge:hover { opacity:0.8; }
.tkt-item-badge:focus-visible { outline:3px solid #2563EB; outline-offset:2px; }
.tkt-item-open { background:#ff5252; color:#fff; }
.tkt-item-closed { background:#e0e0e0; color:#757575; }

/* ---- Item Ticket Timeline ---- */
.item-timeline { padding:16px 24px; background:#fafafa; }
.timeline-ticket-card { background:#fff; border:1px solid #e0e0e0; border-radius:6px; padding:12px 16px; margin-bottom:12px; }
.timeline-ticket-header { display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-bottom:8px; font-size:13px; }
.timeline-ticket-number { font-weight:700; color:#1a237e; }
.timeline-ticket-action { color:#424242; }
.timeline-ticket-status { font-weight:600; }
.timeline-ticket-date { color:#757575; font-size:12px; margin-left:auto; }
.timeline-comments { border-top:1px solid #f0f0f0; padding-top:8px; }
.timeline-comment { padding:6px 0; border-bottom:1px solid #f5f5f5; }
.timeline-comment-author { font-weight:600; font-size:12px; color:#1a237e; }
.timeline-comment-date { font-size:11px; color:#9e9e9e; margin-left:8px; }
.timeline-comment p { margin:4px 0 0 0; font-size:13px; color:#424242; }
.timeline-divider { border:none; border-top:1px dashed #e0e0e0; margin:4px 0; }
.timeline-close-btn { float:right; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---- Responsive: Tablet (768px) ---- */
@media (max-width: 768px) {
    .ticket-container { padding: 12px; }
    .ticket-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .ticket-header h1 { font-size: 20px; }
    .choose-one-grid { grid-template-columns: 1fr; }
    .results-wrapper { flex-direction: column; }
    .selection-cart { width: 100%; position: static; max-height: 300px; }
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .action-grid { grid-template-columns: 1fr 1fr; }
    .search-bar { flex-direction: column; gap: 8px; }
    .search-bar input { width: 100%; }
    .step-indicators { flex-wrap: wrap; justify-content: center; }
    .step-indicator { font-size: 12px; padding: 6px 12px; }
    .cart-actions { flex-direction: column; }
    .results-main { -webkit-overflow-scrolling: touch; max-height: 400px; }
    /* Backend dashboard tabs */
    .queue-tabs { flex-wrap: wrap; gap: 4px; }
    .queue-tab { font-size: 11px; padding: 6px 10px; }
    /* Admin panel tabs */
    .admin-tabs { flex-wrap: wrap; gap: 4px; }
    .admin-tab { font-size: 11px; padding: 6px 10px; }
    /* Ticket detail */
    .tkt-detail-layout { flex-direction: column; }
    .tkt-detail-main { width: 100%; }
    .tkt-detail-sidebar { width: 100%; }
    /* List It */
    .li-layout { grid-template-columns: 1fr; }
    .li-row { grid-template-columns: 1fr; }
}

/* ---- Responsive: Mobile (480px) ---- */
@media (max-width: 480px) {
    .ticket-container { padding: 8px; }
    .ticket-header h1 { font-size: 18px; }
    .wmc-landing-cards { flex-direction: column; }
    .wmc-landing-card { min-width: 100%; }
    .filter-grid { grid-template-columns: 1fr; }
    .action-grid { grid-template-columns: 1fr; }
    .action-type-btn { font-size: 12px; padding: 10px; }
    /* Quick lookup fields stack vertically — override inline styles */
    .search-quick-lookup { flex-direction: column !important; gap: 8px !important; }
    .search-quick-lookup > div { min-width: 100% !important; flex: none !important; }
    /* Also handle item-ticket-form inline-styled quick lookup container */
    #item-sku-input, #item-model-input, #item-mfr-input { font-size: 13px !important; }
    [style*="min-width:120px"] { min-width: 100% !important; flex: none !important; }
    [style*="min-width:150px"] { min-width: 100% !important; flex: none !important; }
    /* Subnav wraps */
    .wmc-subnav { border-radius: 4px; }
    .wmc-subnav-link { padding: 8px 12px; font-size: 11px; }
    /* Buttons */
    .wmc-btn { padding: 6px 14px; font-size: 13px; }
    .wmc-btn-sm { padding: 4px 8px; font-size: 11px; }
    /* Grid - reduce min-width for better scroll */
    .results-main .results-table { min-width: 800px; }
    /* Ticket list cards */
    .ticket-card { padding: 10px; }
    .ticket-meta { flex-direction: column; gap: 4px; }
    /* Backend tabs */
    .queue-tab { font-size: 10px; padding: 5px 8px; }
    /* Comment area */
    .tkt-comment-form textarea { font-size: 13px; }
    /* My tickets list */
    .my-ticket-row { padding: 10px; }
    /* Item info bar on history page */
    .item-info { flex-direction: column; gap: 8px; padding: 12px; }
    /* History cards */
    .history-meta { flex-direction: column; gap: 4px; }
    /* Report tables */
    .report-table { font-size: 11px; }
    .report-table th, .report-table td { padding: 6px 8px; }
    /* Admin form */
    .admin-form-row { flex-direction: column; }
    .admin-form-group { width: 100%; }
    /* Pagination */
    .pagination { flex-wrap: wrap; gap: 4px; }
    .pagination a, .pagination span { padding: 6px 10px; font-size: 12px; }
}
