/* Publisher Market Pages Styles */

/* Lazy-load placeholder — ensures IntersectionObserver can detect visibility */
tv-lazy-load {
    display: block;
    min-height: 220px;
}

.market-ticker-tape {
    margin-bottom: 16px;
    height: 46px;
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
}

/* Prevent TradingView ticker tape loading spinner from overflowing */
.market-ticker-tape .tradingview-widget-container__widget {
    overflow: hidden;
    height: 46px;
}

.market-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px;
    clear: both;
    position: relative;
}

.market-page-header {
    padding: 30px 0 20px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 30px;
}

.market-page-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: #111827;
    margin: 0 0 8px;
    line-height: 1.2;
}

.market-subtitle {
    color: #6b7280;
    font-size: 16px;
    margin: 0 0 8px;
    line-height: 1.5;
}

.market-last-updated {
    display: inline-block;
    font-size: 13px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 4px;
}

/* Sections */
.market-section {
    margin-bottom: 36px;
}

.market-section h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
}

/* Index Cards Grid */
.market-index-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.market-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.market-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.market-card.positive {
    border-left: 3px solid #10b981;
}

.market-card.negative {
    border-left: 3px solid #ef4444;
}

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

.market-card-name {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.market-card-symbol {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.market-card-price {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.market-card-change {
    font-size: 13px;
    font-weight: 600;
}

.market-card.positive .market-card-change {
    color: #059669;
}

.market-card.negative .market-card-change {
    color: #dc2626;
}

.change-arrow {
    font-size: 10px;
    margin-right: 2px;
}

.change-percent {
    font-weight: 500;
    margin-left: 4px;
}

/* Mini Charts Row */
.market-mini-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

/* TradingView Widget Containers */
.market-overview-widget,
.market-forex-widget,
.market-crypto-widget {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.market-mini-chart {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

/* Market Table */
.market-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.market-table thead {
    background: #f9fafb;
}

.market-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e5e7eb;
}

.market-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.market-table tr:hover {
    background: #f9fafb;
}

.market-table .idx-name {
    white-space: nowrap;
}

.market-table .idx-symbol {
    color: #9ca3af;
    font-size: 12px;
    margin-left: 4px;
}

.market-table .idx-price {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.market-table tr.positive .idx-change,
.market-table tr.positive .idx-percent {
    color: #059669;
    font-weight: 600;
}

.market-table tr.negative .idx-change,
.market-table tr.negative .idx-percent {
    color: #dc2626;
    font-weight: 600;
}

/* Geo Navigation */
.market-footer-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #e5e7eb;
}

.market-geo-nav h3 {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 12px;
}

.market-geo-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.market-geo-links a {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 13px;
    color: #4b5563;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.market-geo-links a:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
}

.market-geo-links a.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* Attribution */
.market-attribution {
    margin-top: 20px;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.6;
}

.market-attribution a {
    color: #6b7280;
    text-decoration: underline;
}

.market-disclaimer {
    font-style: italic;
    margin-top: 4px;
}

/* Full width for market pages (no sidebar) */
.market-full-width {
    max-width: 100% !important;
    flex: 0 0 100% !important;
    width: 100% !important;
}

/* Mobile Tabs Navigation */
.market-mobile-tabs {
    display: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
    padding: 0;
}

.market-mobile-tabs a {
    display: inline-block;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.market-mobile-tabs a:hover,
.market-mobile-tabs a.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Responsive */
@media (max-width: 768px) {
    .market-page-container {
        padding: 0 12px 30px;
    }

    .market-page-header h1 {
        font-size: 24px;
    }

    .market-subtitle {
        font-size: 14px;
    }

    .market-section h2 {
        font-size: 18px;
    }

    .market-index-cards {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .market-card {
        padding: 12px;
    }

    .market-card-price {
        font-size: 18px;
    }

    .market-mini-charts-row {
        grid-template-columns: 1fr;
    }

    .market-mobile-tabs {
        display: flex;
    }

    .market-table {
        font-size: 13px;
    }

    .market-table th,
    .market-table td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .market-index-cards {
        grid-template-columns: 1fr 1fr;
    }

    .market-card-name {
        font-size: 12px;
    }

    .market-card-price {
        font-size: 16px;
    }

    .market-card-change {
        font-size: 12px;
    }

    .market-geo-links a {
        padding: 4px 10px;
        font-size: 12px;
    }
}

/* Dark Mode Support */
.scheme-dark .market-page-header {
    border-bottom-color: #374151;
}

.scheme-dark .market-page-header h1 {
    color: #f9fafb;
}

.scheme-dark .market-subtitle {
    color: #9ca3af;
}

.scheme-dark .market-last-updated {
    background: #1f2937;
    color: #9ca3af;
}

.scheme-dark .market-section h2 {
    color: #f3f4f6;
    border-bottom-color: #374151;
}

.scheme-dark .market-card {
    background: #1f2937;
    border-color: #374151;
}

.scheme-dark .market-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scheme-dark .market-card-name {
    color: #e5e7eb;
}

.scheme-dark .market-card-price {
    color: #f9fafb;
}

.scheme-dark .market-table thead {
    background: #1f2937;
}

.scheme-dark .market-table th {
    color: #9ca3af;
    border-bottom-color: #374151;
}

.scheme-dark .market-table td {
    color: #d1d5db;
    border-bottom-color: #374151;
}

.scheme-dark .market-table tr:hover {
    background: #111827;
}

.scheme-dark .market-footer-section {
    border-top-color: #374151;
}

.scheme-dark .market-geo-nav h3 {
    color: #d1d5db;
}

.scheme-dark .market-geo-links a {
    border-color: #4b5563;
    color: #9ca3af;
}

.scheme-dark .market-geo-links a:hover {
    background: #374151;
    color: #f3f4f6;
}

.scheme-dark .market-overview-widget,
.scheme-dark .market-forex-widget,
.scheme-dark .market-crypto-widget,
.scheme-dark .market-mini-chart {
    border-color: #374151;
}

/* =========================================================================
   Metal Rates Page Styles
   ========================================================================= */

.metal-rates-container {
    max-width: 1200px;
}

.metal-table th,
.metal-table td {
    padding: 10px 14px;
    text-align: right;
    white-space: nowrap;
}

.metal-table th:first-child,
.metal-table td:first-child {
    text-align: left;
}

.metal-name .metal-symbol {
    font-size: 0.8em;
    color: #6b7280;
    margin-left: 6px;
}

.metal-price-up .metal-change {
    color: #16a34a;
}

.metal-price-down .metal-change {
    color: #dc2626;
}

.metal-price-up {
    background: rgba(22, 163, 74, 0.04);
}

.metal-price-down {
    background: rgba(220, 38, 38, 0.04);
}

.scrap-rates-section {
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.scrap-rates-section h2 {
    color: #92400e;
}

.scrap-rates-section .market-subtitle {
    color: #a16207;
    font-size: 0.9em;
}

.scrap-rates-section .metal-table {
    background: #fff;
}

.market-info-block {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.market-info-block h3 {
    color: #0369a1;
    margin-top: 0;
}

.market-info-block p {
    color: #475569;
    line-height: 1.6;
}

/* Dark mode overrides for metal rates */
.scheme-dark .scrap-rates-section {
    background: #1c1a00;
    border-color: #854d0e;
}

.scheme-dark .scrap-rates-section h2 {
    color: #fbbf24;
}

.scheme-dark .scrap-rates-section .market-subtitle {
    color: #d97706;
}

.scheme-dark .scrap-rates-section .metal-table {
    background: #1f2937;
}

.scheme-dark .market-info-block {
    background: #0c1929;
    border-color: #0369a1;
}

.scheme-dark .market-info-block h3 {
    color: #38bdf8;
}

.scheme-dark .market-info-block p {
    color: #94a3b8;
}

.scheme-dark .metal-name .metal-symbol {
    color: #9ca3af;
}

/* =========================================================================
   Navigation Dropdown (has-submenu)
   ========================================================================= */

li.has-submenu {
    position: relative;
}

li.has-submenu > ul.sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 4px 0;
    z-index: 100;
    list-style: none;
    margin: 0;
}

li.has-submenu:hover > ul.sub-menu,
li.has-submenu:focus-within > ul.sub-menu {
    display: block;
}

li.has-submenu > ul.sub-menu li {
    margin: 0;
}

li.has-submenu > ul.sub-menu li a {
    display: block;
    padding: 8px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 0.9em;
    white-space: nowrap;
}

li.has-submenu > ul.sub-menu li a:hover {
    background: #f3f4f6;
    color: #111827;
}

/* Dark mode dropdown */
.scheme-dark li.has-submenu > ul.sub-menu {
    background: #1f2937;
    border-color: #374151;
}

.scheme-dark li.has-submenu > ul.sub-menu li a {
    color: #d1d5db;
}

.scheme-dark li.has-submenu > ul.sub-menu li a:hover {
    background: #374151;
    color: #f9fafb;
}

/* Responsive: on mobile, show submenu inline */
@media (max-width: 768px) {
    li.has-submenu > ul.sub-menu {
        position: static;
        box-shadow: none;
        border: none;
        padding-left: 16px;
        display: block;
    }

    .metal-table th,
    .metal-table td {
        padding: 8px 8px;
        font-size: 0.85em;
    }

    .metal-table .metal-price-oz {
        display: none;
    }

    .metal-controls {
        flex-direction: column;
        gap: 10px;
    }

    .metal-controls-left,
    .metal-controls-right {
        width: 100%;
        justify-content: space-between;
    }
}

/* Metal Rates Interactive Controls */
.metal-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 16px 0;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.scheme-dark .metal-controls {
    background: #1f2937;
    border-color: #374151;
}

.metal-controls-left,
.metal-controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.metal-controls-left label {
    font-weight: 600;
    font-size: 0.9em;
    color: #374151;
}

.scheme-dark .metal-controls-left label {
    color: #d1d5db;
}

.metal-select {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 0.9em;
    color: #111827;
    cursor: pointer;
}

.scheme-dark .metal-select {
    background: #111827;
    border-color: #4b5563;
    color: #f3f4f6;
}

.metal-exchange-info {
    font-size: 0.85em;
    color: #2563eb;
    font-weight: 600;
    padding: 4px 10px;
    background: #eff6ff;
    border-radius: 4px;
    border: 1px solid #bfdbfe;
}
.scheme-dark .metal-exchange-info {
    color: #93c5fd;
    background: #1e3a5f;
    border-color: #2563eb;
}

.metal-filter-group {
    display: flex;
    gap: 4px;
}

.metal-filter-btn {
    padding: 5px 12px;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 5px;
    font-size: 0.85em;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
}

.scheme-dark .metal-filter-btn {
    background: #111827;
    border-color: #4b5563;
    color: #d1d5db;
}

.metal-filter-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.metal-filter-btn:hover:not(.active) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.scheme-dark .metal-filter-btn:hover:not(.active) {
    background: #1f2937;
}

.metal-refresh-btn {
    padding: 6px 16px;
    background: #059669;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}

.metal-refresh-btn:hover {
    background: #047857;
}

.metal-refresh-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.metal-status {
    display: block;
    font-size: 0.85em;
    color: #6b7280;
    margin-bottom: 8px;
}

.scrap-base-info {
    font-size: 0.9em;
    color: #6b7280;
    margin-bottom: 8px;
    font-style: italic;
}

/* =========================================================================
   Landing Prices Section (Teal theme)
   ========================================================================= */

.landing-prices-section {
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.landing-prices-section h2 {
    color: #115e59;
}

.landing-prices-section .market-subtitle {
    color: #0f766e;
    font-size: 0.9em;
}

.landing-prices-section .metal-table {
    background: #fff;
}

.landing-duty {
    font-size: 0.8em;
    color: #6b7280;
    white-space: normal !important;
    max-width: 160px;
}

.landing-net {
    font-weight: 700;
    color: #115e59;
}

.landing-sub {
    font-size: 0.8em;
    font-weight: 400;
    color: #6b7280;
}

.landing-disclaimer {
    font-size: 0.85em;
    color: #6b7280;
    font-style: italic;
    margin-top: 10px;
}

/* Dark mode for landing prices */
.scheme-dark .landing-prices-section {
    background: #042f2e;
    border-color: #134e4a;
}

.scheme-dark .landing-prices-section h2 {
    color: #5eead4;
}

.scheme-dark .landing-prices-section .market-subtitle {
    color: #2dd4bf;
}

.scheme-dark .landing-prices-section .metal-table {
    background: #1f2937;
}

.scheme-dark .landing-net {
    color: #5eead4;
}

.scheme-dark .landing-duty {
    color: #9ca3af;
}

.scheme-dark .landing-sub {
    color: #9ca3af;
}

.scheme-dark .landing-disclaimer {
    color: #9ca3af;
}

@media (max-width: 768px) {
    .landing-duty {
        font-size: 0.75em;
        max-width: 100px;
    }

    .landing-prices-section {
        padding: 12px;
    }
}

/* =========================================================================
   Scrap BL (Bill of Lading) Rates Section (Orange theme)
   ========================================================================= */

.scrap-bl-section {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.scrap-bl-section h2 {
    color: #9a3412;
}

.scrap-bl-section .market-subtitle {
    color: #c2410c;
    font-size: 0.9em;
}

.scrap-bl-section .metal-table {
    background: #fff;
}

.scrap-bl-group-label {
    font-weight: 700;
    font-size: 0.85em;
    color: #9a3412;
    background: #ffedd5 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 14px !important;
    border-bottom: 2px solid #fed7aa !important;
}

.scrap-bl-discount {
    color: #6b7280;
    font-size: 0.9em;
}

.scrap-bl-duty {
    font-size: 0.8em;
    color: #6b7280;
    white-space: normal !important;
    max-width: 140px;
}

.scrap-bl-price {
    font-weight: 600;
    color: #9a3412;
}

.scrap-bl-disclaimer {
    font-size: 0.85em;
    color: #6b7280;
    font-style: italic;
    margin-top: 10px;
}

/* Dark mode for scrap BL */
.scheme-dark .scrap-bl-section {
    background: #2a1500;
    border-color: #7c2d12;
}

.scheme-dark .scrap-bl-section h2 {
    color: #fb923c;
}

.scheme-dark .scrap-bl-section .market-subtitle {
    color: #f97316;
}

.scheme-dark .scrap-bl-section .metal-table {
    background: #1f2937;
}

.scheme-dark .scrap-bl-group-label {
    color: #fb923c;
    background: #3b1800 !important;
    border-bottom-color: #7c2d12 !important;
}

.scheme-dark .scrap-bl-price {
    color: #fb923c;
}

.scheme-dark .scrap-bl-duty,
.scheme-dark .scrap-bl-discount {
    color: #9ca3af;
}

@media (max-width: 768px) {
    .scrap-bl-section {
        padding: 12px;
    }

    .scrap-bl-duty {
        font-size: 0.75em;
        max-width: 100px;
    }
}
