/* Material Exchange Styles */

/* Override blueprint variables to remove borders */
:root {
    --bp-border-color: transparent;
}

/* Unified status pills (used on lists, admin, detail) */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.2px;
    text-transform: none;
}

.status-badge .status-icon {
    color: inherit;
    font-size: 0.9rem;
}

/* New workflow statuses */
.status-badge.status-awaiting_validation {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #b45309;
}

.status-badge.status-validated {
    background: #e0f2fe;
    border-color: #38bdf8;
    color: #075985;
}

.status-badge.status-accepted {
    background: #e0f2fe;
    border-color: #60a5fa;
    color: #1d4ed8;
}

.status-badge.status-completed {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.status-badge.status-draft {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #475569;
}

.status-badge.status-rejected {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.status-badge.status-cancelled {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #475569;
}

/* Legacy statuses kept for compatibility */
.status-pending {
    background-color: #ffc107;
    color: var(--indy-text-primary, #000);
}

html[data-theme="darkly"] .status-pending {
    color: #222;
}

.status-approved {
    background-color: #17a2b8;
    color: #fff;
}

/* Stock table styles for buy.html and sell.html */
.stock-table th {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-table tbody tr {
    transition: all 0.2s ease;
}

.stock-table tbody tr:hover {
    border-left: 3px solid;
}

.item-icon {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    padding: 4px;
}

.qty-input {
    max-width: 120px;
}

.qty-input.is-invalid {
    border-color: var(--bs-danger);
}

.qty-error {
    color: var(--bs-danger);
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: none;
}

.invoice-panel {
    position: sticky;
    top: 20px;
}

.invoice-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(var(--bs-border-color-rgb), 0.5);
}

.invoice-item:last-child {
    border-bottom: none;
}

/* Buy.html specific */
html[data-theme="darkly"] .stock-table th {
    background: rgba(var(--bs-primary-rgb), 0.1);
}

html[data-theme="darkly"] .stock-table tbody tr:hover {
    background: rgba(var(--bs-primary-rgb), 0.03);
}

html[data-theme="darkly"] .stock-table tbody tr.selected {
    background: rgba(var(--bs-primary-rgb), 0.08);
    border-left-color: var(--bs-primary);
}

html[data-theme="darkly"] .item-icon {
    background: rgba(var(--bs-primary-rgb), 0.05);
}

/* Sell.html specific */
html[data-theme="darkly"] .material-exchange.sell .stock-table th {
    background: rgba(var(--bs-success-rgb), 0.1);
}

html[data-theme="darkly"] .material-exchange.sell .stock-table tbody tr:hover {
    background: rgba(var(--bs-success-rgb), 0.03);
}

html[data-theme="darkly"] .material-exchange.sell .stock-table tbody tr.selected {
    background: rgba(var(--bs-success-rgb), 0.08);
    border-left-color: var(--bs-success);
}

html[data-theme="darkly"] .material-exchange.sell .item-icon {
    background: rgba(var(--bs-success-rgb), 0.05);
}

/* Detail card styles - used in sell.html line 294 */
.detail-card {
    padding: 1rem;
    border-radius: 0.375rem;
    border-left: 3px solid var(--bs-info);
}

.detail-value {
    font-size: 1.1rem;
    margin-top: 0.5rem;
    color: var(--bs-body-color);
}

.items-list .item-row {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(var(--bs-border-color-rgb), 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.items-list .item-row:last-child {
    border-bottom: none;
}

.items-list .item-name {
    font-weight: 500;
}

.items-list .item-qty {
    color: var(--bs-info);
    font-weight: 500;
}

html[data-theme="darkly"] .detail-card {
    background: rgba(var(--bs-info-rgb), 0.08);
}

/* Invoice styles for buy.html and sell.html */
.invoice-total {
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.empty-invoice {
    text-align: center;
    padding: 2rem;
    color: var(--bs-secondary);
}

.invoice-total {
    background: linear-gradient(135deg, rgba(var(--bs-success-rgb), 0.1), rgba(var(--bs-info-rgb), 0.1));
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

html[data-theme="darkly"] .invoice-total {
    background: linear-gradient(135deg, rgba(var(--bs-success-rgb), 0.08), rgba(var(--bs-info-rgb), 0.08));
}

.empty-invoice {
    text-align: center;
    padding: 2rem;
    color: var(--bs-secondary);
}

html[data-theme="darkly"] .empty-invoice {
    color: var(--bs-secondary);
}

/* Admin ledger layout */
.admin-ledger {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: linear-gradient(120deg, #f8fafc, #eef2ff);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

html[data-theme="darkly"] .admin-ledger {
    border-color: rgba(148, 163, 184, 0.25);
    background: linear-gradient(120deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.admin-ledger .ledger-head {
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

html[data-theme="darkly"] .admin-ledger .ledger-head {
    background: rgba(148, 163, 184, 0.12);
}

.ledger-head .title {
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #0f172a;
}

html[data-theme="darkly"] .ledger-head .title {
    color: #f8fafc;
}

.ledger-list {
    padding: 6px 0;
}

.ledger-row {
    display: grid;
    grid-template-columns: 260px 1fr 260px;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    transition: background 0.2s ease, transform 0.2s ease;
}

html[data-theme="darkly"] .ledger-row {
    border-top-color: rgba(148, 163, 184, 0.18);
}

.ledger-row:first-of-type {
    border-top: 0;
}

.ledger-row:hover {
    background: rgba(79, 70, 229, 0.06);
    transform: translateY(-1px);
}

html[data-theme="darkly"] .ledger-row:hover {
    background: rgba(99, 102, 241, 0.18);
}

.ledger-row .ref {
    font-weight: 800;
    color: #0f172a;
}

html[data-theme="darkly"] .ledger-row .ref {
    color: #e2e8f0;
}

.ledger-row .identity {
    color: #334155;
    font-size: 13px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

html[data-theme="darkly"] .ledger-row .identity {
    color: rgba(226, 232, 240, 0.82);
}

.ledger-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.stat-chip {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.65);
}

html[data-theme="darkly"] .stat-chip {
    border-color: rgba(148, 163, 184, 0.25);
    background: rgba(30, 41, 59, 0.75);
}

.stat-chip .label {
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

html[data-theme="darkly"] .stat-chip .label {
    color: rgba(226, 232, 240, 0.7);
}

.stat-chip .value {
    color: #0f172a;
    font-weight: 700;
}

html[data-theme="darkly"] .stat-chip .value {
    color: #f8fafc;
}

.preview {
    color: #1f2937;
    font-size: 13px;
}

html[data-theme="darkly"] .preview {
    color: rgba(226, 232, 240, 0.82);
}

.ledger-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-rail {
    width: 6px;
    height: 100%;
    border-radius: 10px;
    background: #cbd5e1;
}

html[data-theme="darkly"] .status-rail {
    background: rgba(148, 163, 184, 0.6);
}

.ledger-row.status-draft .status-rail {
    background: #cbd5e1;
}

.ledger-row.status-awaiting_validation .status-rail {
    background: #f59e0b;
}

.ledger-row.status-validated .status-rail {
    background: #38bdf8;
}

.ledger-row.status-completed .status-rail {
    background: #22c55e;
}

.ledger-row.status-rejected .status-rail {
    background: #ef4444;
}

.ledger-row.status-cancelled .status-rail {
    background: #94a3b8;
}

@media (max-width: 992px) {
    .ledger-row {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }
    .ledger-actions {
        justify-content: flex-start;
    }
}

/* Remove glass-panel borders for cleaner look - override blueprints.css */
.glass-panel {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

.col-md-3 .glass-panel,
.row .glass-panel {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Page header divider chip on admin section */
.admin-divider-line {
    border-color: rgba(15, 23, 42, 0.12) !important;
}

html[data-theme="darkly"] .admin-divider-line {
    border-color: rgba(148, 163, 184, 0.35) !important;
}

.admin-divider-chip {
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.12);
}

html[data-theme="darkly"] .admin-divider-chip {
    background: rgba(148, 163, 184, 0.14);
    border-color: rgba(148, 163, 184, 0.35);
    color: #f8fafc;
}

/* Info panels icon + body flex handling */
.info-icon-fixed {
    flex-shrink: 0;
}

.info-body-flex {
    flex: 1;
}

/* Stock table fixed column widths */
.stock-col-icon {
    width: 60px;
}

.stock-col-qty {
    width: 140px;
}

/* Modal lists and reference tag styling */
.modal-items-list {
    max-height: 200px;
    overflow-y: auto;
}

.contract-ref-tag {
    word-break: break-all;
    background: rgba(var(--bs-warning-rgb), 0.1);
    padding: 0.75rem;
    border-radius: 0.375rem;
}

/* Config refresh progress visuals */
.refresh-status {
    display: none;
}

.refresh-progress {
    height: 25px;
    display: none;
}

.refresh-progress-bar {
    width: 0%;
}

/* Bootstrap utility classes overrides */
html[data-theme="darkly"] .bg-body-tertiary,
html[data-theme="darkly"] .bg-body-secondary,
html[data-theme="darkly"] .bg-light,
html[data-theme="darkly"] .bg-white {
    background-color: #303030 !important;
}

html[data-theme="darkly"] [class*="subtle"] {
    background-color: #303030 !important;
}
