/**
 * Detail Page Shared Components — 2026-04-07
 * Fastorder Canonical Detail Architecture
 *
 * Load order:
 *   1. color-system.css  (colors — MUST load first)
 *   2. detail-tokens.css (layout/spacing — MUST load second)
 *   3. detail-page.css   (this file — shared component classes)
 *   4. ai-workflow.css   (AI-specific, load only on AI-capable pages)
 *
 * ISOLATION WARNING: This file MUST ONLY be loaded on:
 *   - templates/dashboard/market/market_detail.html.twig
 *   - templates/dashboard/content/content_detail.html.twig
 *
 * DO NOT add to base.html.twig or any global layout.
 * Contains bare element selectors (body, table, th, td) and .btn overrides
 * that WILL break other pages if loaded globally.
 */

/* ============================================================
   CONTAINER
   ============================================================ */

.detail-container {
    max-width: var(--fo-detail-max-width);
    margin: 0 auto;
    padding: var(--fo-detail-padding-y) var(--fo-detail-padding-x);
}

.detail-container--narrow { --fo-detail-max-width: var(--fo-detail-max-width-narrow); }
.detail-container--wide   { --fo-detail-max-width: var(--fo-detail-max-width-wide);   }


/* ============================================================
   PAGE BASE
   ============================================================ */

body {
    margin: 0;
    font-family: var(--fo-font-system);
    background: var(--bg-secondary);
    color: var(--text);
}


/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--fo-card-radius);
    padding: var(--fo-card-padding);
    margin-bottom: var(--fo-card-gap);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}


/* ============================================================
   BUTTONS  (canonical sizing: 10px / 20px)
   ============================================================ */

.btn {
    padding: var(--fo-btn-padding-y) var(--fo-btn-padding-x);
    border-radius: var(--fo-btn-radius);
    font-size: var(--fo-btn-font-size);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

/* Link-as-button resets */
a.btn:not(.btn-secondary),
a.btn:not(.btn-secondary):link,
a.btn:not(.btn-secondary):visited,
a.btn:not(.btn-secondary):hover {
    color: var(--text-on-primary) !important;
    text-decoration: none !important;
}

a.btn-secondary,
a.btn-secondary:link,
a.btn-secondary:visited,
a.btn-secondary:hover {
    color: var(--text) !important;
    text-decoration: none !important;
}


/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-block;
    padding: var(--fo-badge-padding-y) var(--fo-badge-padding-x);
    border-radius: var(--fo-badge-radius);
    font-size: var(--fo-badge-font-size);
    font-weight: 600;
}


/* ============================================================
   TABLES  (canonical: sticky headers)
   ============================================================ */

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: var(--fo-table-cell-padding-y) var(--fo-table-cell-padding-x);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: var(--fo-table-header-font-size);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
    letter-spacing: var(--fo-table-header-letter-spacing);
}

td {
    font-size: var(--fo-table-body-font-size);
    color: var(--text);
}

tr:last-child td { border-bottom: none; }
tbody tr:hover   { background: var(--bg-secondary); }


/* ============================================================
   TABLE CARD WRAPPER
   ============================================================ */

.table-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--fo-card-radius);
    overflow: hidden;
}

.table-header {
    padding: 20px var(--fo-card-padding);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.table-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}


/* ============================================================
   INFO GRID
   ============================================================ */

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.info-row {
    display: flex;
    padding: var(--fo-info-row-padding-y) 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: none; }

.info-label {
    width: var(--fo-info-label-width);
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: var(--fo-info-label-font-size);
    padding-right: 12px;
}

.info-value {
    font-size: var(--fo-info-value-font-size);
    word-break: break-word;
}

.info-full { grid-column: 1 / -1; }


/* ============================================================
   EMPTY STATES
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}


/* ============================================================
   SECTION TOGGLE  (config card collapsible sections)
   ============================================================ */

.section-toggle         { cursor: pointer; user-select: none; }
.section-toggle:hover   { opacity: 0.8; }
.section-content        { overflow: hidden; }


/* ============================================================
   TOGGLE SWITCH  (boolean attr display)
   ============================================================ */

.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: var(--fo-toggle-width);
    height: var(--fo-toggle-height);
}

.toggle-switch input         { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: default;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--fo-toggle-off-bg);
    transition: .3s;
    border-radius: var(--fo-toggle-height);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: var(--fo-toggle-knob);
    width: var(--fo-toggle-knob);
    left: 3px;
    bottom: 3px;
    background-color: var(--text-on-primary);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .toggle-slider                  { background-color: var(--fo-toggle-on-bg); }
input:checked + .toggle-slider::before          { transform: translateX(16px); }


/* ============================================================
   MONO / JSON / CONTRACT-K CHIPS
   ============================================================ */

.mono {
    font-family: var(--fo-font-mono);
    font-size: 12px;
}

.json-value {
    font-family: var(--fo-font-mono);
    font-size: 12px;
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
}

.contract-k {
    font-family: var(--fo-font-mono);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}


/* ============================================================
   MODALITY PILL
   ============================================================ */

.modality-pill {
    font-size: 10px;
    padding: 1px 6px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-blue);
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}


/* ============================================================
   MARKET LINK
   ============================================================ */

a.market-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

a.market-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}


/* ============================================================
   SUBCATEGORY ICON CIRCLE  (market-specific, included here for
   single-file convenience — only used in market context)
   ============================================================ */

.sub-icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-primary);
    font-size: 14px;
    vertical-align: middle;
}

.sub-icon-circle img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}


/* ============================================================
   ITEM INFO CARD  (content-specific meta block)
   ============================================================ */

.item-info {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--fo-card-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.item-info h2 { margin: 0 0 10px 0; font-size: 20px; }
.item-info p  { margin: 5px 0; color: var(--text-muted); }


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .info-grid { grid-template-columns: 1fr; }

    .detail-container {
        padding: 16px var(--fo-detail-padding-x);
    }
}
