/* Market Analysis Page Styling */

#market-container {
    max-width: 1400px;
    margin: 0 auto 40px;
    box-sizing: border-box;
}

.market-header {
    margin-bottom: 20px;
}

.market-header h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: #ffffff;
    margin: 0 0 6px 0;
    letter-spacing: 1px;
}

.market-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
    margin: 0;
}

/* ===== Summary Stats ===== */

.market-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.market-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 16px 20px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.market-stat-card:hover {
    border-color: rgba(192, 80, 16, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.stat-label {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 8px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 600;
    color: #ffffff;
}

.stat-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 4px;
}

/* ===== Toolbar: mode tabs + filters ===== */

.market-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 20px;
}

/* Pill toggle, same recipe as appraisal.css's .appraisal-pill-toggle. */
.market-mode-tabs {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2px;
    gap: 2px;
}

.market-mode-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.market-mode-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.market-mode-btn.is-active {
    color: #ffffff;
    background: rgba(192, 80, 16, 0.7);
    box-shadow: 0 2px 8px rgba(192, 80, 16, 0.3);
}

.market-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.market-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px 10px;
}

.market-filter-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.market-input, .market-select {
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
}

.market-select option {
    background: #11151c;
    color: #ffffff;
}

.market-input[type="number"] {
    width: 60px;
    text-align: right;
}

.market-input[type="text"] {
    width: 160px;
}

/* ===== Data Table ===== */

/* Own scroll region -- same max-height + independent-scroll convention as
   main.css's .data-panel, since this table can grow past a screenful once
   scroll pagination (market.js's loadMarketPage) keeps appending pages. */
.market-table-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    max-height: 65vh;
    overflow-x: auto;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.market-table-container::-webkit-scrollbar {
    width: 8px;
}

.market-table-container::-webkit-scrollbar-track {
    background: transparent;
}

.market-table-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.market-table-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(192, 80, 16, 0.55);
}

.market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.market-table th {
    /* Solid, not translucent -- .market-table-container scrolls rows
       underneath this sticky header, so a see-through background would let
       them show through. */
    background: #0c0d10;
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.market-table th:hover {
    color: rgba(255, 255, 255, 0.85);
}

.market-table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    vertical-align: middle;
}

.market-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

.market-table-message {
    text-align: center;
    padding: 40px !important;
}

.item-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.item-title {
    font-weight: 500;
    color: #ffffff;
    display: block;
}

.item-group {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Palette-only profit/loss coloring -- teal/orange, never raw red/green
   (mirrors main.css's .amount-cell convention). */
.text-positive {
    color: #34a37d;
    font-weight: 500;
}

.text-negative {
    color: #c05010;
}

.text-info {
    color: #4d94d1;
    font-weight: 600;
}

.text-gold {
    color: #e0a52e;
    font-weight: 600;
}

/* Status pills, same recipe as industry.css's .job-status. */
.market-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    border: 1px solid transparent;
}

.market-badge.is-good {
    color: #34a37d;
    border-color: rgba(52, 163, 125, 0.4);
    background: rgba(52, 163, 125, 0.12);
}

.market-badge.is-warning {
    color: #e0a52e;
    border-color: rgba(224, 165, 46, 0.4);
    background: rgba(224, 165, 46, 0.12);
}

.market-badge.is-danger {
    color: #c05010;
    border-color: rgba(192, 80, 16, 0.4);
    background: rgba(192, 80, 16, 0.12);
}

/* Row action button (Breakdown / View Materials), same chrome as
   hr.css's .hr-notes-btn. */
.market-row-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.75);
    font-family: var(--font-body);
    font-size: 0.75rem;
    padding: 4px 10px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.market-row-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(192, 80, 16, 0.6);
    color: #ffffff;
}

/* ===== Item breakdown overlay (uses main.css's .overlay / .overlay-panel) ===== */

.overlay-panel.market-overlay-panel {
    width: 90vw;
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
    background: #11151c;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.market-overlay-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.market-overlay-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: #ffffff;
    margin: 0 0 4px;
}

.market-overlay-sub {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.market-breakdown-list {
    display: flex;
    flex-flow: column nowrap;
    gap: 10px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.market-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
}

.market-breakdown-row .label {
    color: rgba(255, 255, 255, 0.5);
}

.market-breakdown-row.is-total {
    border-bottom: none;
    padding-top: 4px;
    font-size: 1.05rem;
}

.market-breakdown-row.is-total .label {
    color: #ffffff;
    font-weight: 600;
}

.market-breakdown-highlight {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    background: rgba(77, 148, 209, 0.1);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(77, 148, 209, 0.3);
    color: #4d94d1;
    font-weight: 600;
}

.market-overlay-heading {
    font-family: var(--font-heading);
    color: #ffffff;
    margin: 16px 0 8px;
}

/* Materials Tree Table */
.materials-table {
    width: 100%;
    margin-top: 12px;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.materials-table th {
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.materials-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
}

.material-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.material-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
}
