/* ============================================
   V3 PRODUCTION LAYOUT
   Quote-to-Offer Workflow
   ============================================ */

/* Hide V3 by default, show when body has v3-layout class */
.v3-app {
    display: none;
}

body.v3-layout .v3-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #0a0a0a;
}

body.v3-layout .grid-container {
    display: none !important;
}

/* ── V3 Header ─────────────────────────────── */
.v3-header {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: #0a0a0a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.v3-header .v3-logo {
    height: 28px;
    width: auto;
}

.v3-header .v3-title {
    font-family: 'RZA', 'Haffer', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #fafafa;
    white-space: nowrap;
}

.v3-header .v3-header-spacer {
    flex: 1;
}

/* V3 uses unified header styles from modules.css */

/* ── V3 Main ───────────────────────────────── */
.v3-main {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ── Empty State ───────────────────────────── */
.v3-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
}

.v3-empty-state h2 {
    font-size: 24px;
    color: #fafafa;
    margin: 0 0 8px 0;
}

.v3-empty-state p {
    color: #808080;
    margin: 0 0 24px 0;
}

.v3-load-quote {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.v3-load-quote .v3-input {
    width: 280px;
    height: 44px;
    padding: 0 14px;
    font-size: 14px;
}

.v3-load-quote .v3-btn {
    height: 44px;
    padding: 0 24px;
    white-space: nowrap;
}

/* ── Common Elements ───────────────────────── */
.v3-input, .v3-select, .v3-textarea {
    background: #252525;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px 12px;
    color: #fafafa;
    font-size: 14px;
    width: 100%;
}

.v3-input:focus, .v3-select:focus, .v3-textarea:focus {
    outline: none;
    border-color: #ff575f;
}

.v3-textarea {
    resize: vertical;
    min-height: 80px;
}

.v3-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.v3-btn-primary {
    background: #ff575f;
    color: #fff;
}

.v3-btn-primary:hover {
    background: #ff3d47;
}

.v3-btn-secondary {
    background: #2a2a2a;
    color: #fafafa;
}

.v3-btn-secondary:hover {
    background: #333;
}

.v3-btn-large {
    padding: 16px 48px;
    font-size: 16px;
}

/* ── Sections ──────────────────────────────── */
.v3-section {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.v3-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #3a3a3a;
}

.v3-section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #fafafa;
    margin: 0;
}

.v3-quote-id, .v3-count {
    font-size: 12px;
    color: #808080;
}

.v3-customer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #808080;
}

.v3-customer-info .v3-info-sep {
    color: #404040;
}

.v3-customer-info a.v3-quote-id {
    color: #ff575f;
    text-decoration: none;
}

.v3-customer-info a.v3-quote-id:hover {
    text-decoration: underline;
}

/* ── Quote Details Section ─────────────────── */

/* Two-column layout: Form left, Price Range right */
.v3-details-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 16px;
}

/* Left column: Form fields */
.v3-form-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.v3-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.v3-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.v3-form-group label {
    font-size: 12px;
    color: #808080;
    font-weight: 500;
}

/* Right column: Price Range */
.v3-price-column {
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.v3-price-subheader {
    font-size: 14px;
    font-weight: 600;
    color: #fafafa;
    padding-bottom: 8px;
    border-bottom: 1px solid #444;
}

/* Photos Grid - 3 columns below form */
.v3-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.v3-photo {
    background: #242424;
    border-radius: 8px;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    border: 1px solid #3a3a3a;
}

.v3-photo:hover {
    border-color: #ff575f;
}

.v3-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.v3-photo-placeholder {
    color: #606060;
    font-size: 12px;
}

.v3-photo::after {
    content: attr(data-label);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: #808080;
    font-size: 10px;
    padding: 4px 8px;
    text-align: center;
}

/* ── Price Range Section ───────────────────── */

/* Customer Range - prominent box at top */
.v3-customer-range-box {
    background: #1a1a1a;
    border: 1px solid #34d399;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.v3-customer-range-label {
    color: #808080;
    font-size: 12px;
    font-weight: 500;
}

.v3-customer-range-value {
    color: #34d399;
    font-size: 16px;
    font-weight: 700;
}

/* RRP Source selector */
.v3-rrp-source {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.v3-rrp-source-label {
    color: #808080;
    font-size: 12px;
    font-weight: 500;
}

.v3-rrp-source-buttons {
    display: flex;
    gap: 0;
}

.v3-toggle-btn {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #444;
    background: #1a1a1a;
    color: #808080;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.v3-toggle-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.v3-toggle-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.v3-toggle-btn:not(:first-child) {
    border-left: none;
}

.v3-toggle-btn.active {
    background: #ff575f;
    border-color: #ff575f;
    color: #fff;
}

.v3-custom-rrp {
    margin-top: 8px;
}

/* Price rows - full width */
.v3-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a1a;
    border-radius: 6px;
    padding: 12px 16px;
}

.v3-price-row-label {
    color: #808080;
    font-size: 13px;
    font-weight: 500;
}

.v3-price-row-value {
    color: #fafafa;
    font-size: 18px;
    font-weight: 700;
}

/* ── Market Data Section (Two-Column) ─────── */
.v3-market-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.v3-market-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.v3-market-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #3a3a3a;
}

.v3-market-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #fafafa;
    margin: 0;
}

.v3-market-stats {
    display: flex;
    gap: 12px;
}

.v3-stat {
    flex: 1;
    background: #242424;
    border-radius: 6px;
    padding: 10px 12px;
    text-align: center;
}

.v3-stat-label {
    display: block;
    font-size: 10px;
    color: #808080;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.v3-stat-value {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #fafafa;
}

/* AI Filter Info */
.v3-ai-filter-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 12px;
    flex-wrap: wrap;
}

.v3-ai-filter-text {
    color: #f0a500;
}

.v3-ai-filter-text strong {
    color: #34d399;
}

.v3-btn-small {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.v3-reset-ai-btn {
    background: rgba(240, 165, 0, 0.15);
    border: 1px solid #f0a500;
    color: #f0a500;
}

.v3-reset-ai-btn:hover {
    background: rgba(240, 165, 0, 0.25);
}

.v3-recalc-btn {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid #34d399;
    color: #34d399;
}

.v3-recalc-btn:hover {
    background: rgba(52, 211, 153, 0.25);
}

/* Excluded rows */
.v3-row-excluded {
    opacity: 0.5;
}

.v3-row-excluded td {
    color: #606060 !important;
}

.v3-excluded-tag {
    display: inline-block;
    background: rgba(240, 165, 0, 0.2);
    color: #f0a500;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 4px;
    text-transform: uppercase;
}

/* ── Tables ────────────────────────────────── */
.v3-table-wrapper {
    overflow-x: auto;
    max-height: 250px;
    overflow-y: auto;
}

.v3-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.v3-table th {
    text-align: left;
    padding: 10px 12px;
    background: #1a1a1a;
    color: #808080;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.v3-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #2a2a2a;
    color: #fafafa;
}

.v3-table td.v3-title-cell {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3-table tbody tr:hover {
    background: rgba(255, 87, 95, 0.05);
}

.v3-empty-row {
    text-align: center;
    color: #606060;
    padding: 24px !important;
}

/* Include checkbox */
.v3-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ── Send Quote Section ────────────────────── */

/* Pricing Context Bar */
.v3-pricing-context {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    background: #0a0a0a;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #252525;
}

.v3-context-item {
    flex: 1;
    text-align: center;
    padding: 0 12px;
    border-right: 1px solid #333;
}

.v3-context-item:last-child {
    border-right: none;
}

.v3-context-label {
    display: block;
    font-size: 10px;
    color: #606060;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.v3-context-value {
    display: block;
    font-size: 12px;
    color: #a0a0a0;
    font-weight: 500;
}

.v3-send-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.v3-pricing-panel,
.v3-actions-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Sell Price Row */
.v3-sell-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.1), rgba(52, 211, 153, 0.05));
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 8px;
}

.v3-sell-price-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.v3-sell-price-label {
    color: #34d399;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.v3-sell-price-hint {
    color: #808080;
    font-size: 11px;
}

.v3-sell-price-value {
    color: #34d399;
    font-size: 24px;
    font-weight: 700;
}

.v3-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #1a1a1a;
    border-radius: 8px;
}

.v3-price-label {
    color: #808080;
    font-size: 13px;
}

.v3-price-value {
    color: #fafafa;
    font-size: 18px;
    font-weight: 600;
}

/* Tier Selector */
.v3-price-tiers {
    display: flex;
    gap: 8px;
}

.v3-tier {
    flex: 1;
    padding: 12px 8px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.v3-tier:hover {
    border-color: #ff575f;
}

.v3-tier.v3-tier-selected {
    border-color: #ff575f;
    background: rgba(255, 87, 95, 0.1);
}

.v3-tier-label {
    display: block;
    font-size: 10px;
    color: #808080;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.v3-tier-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #fafafa;
    margin-bottom: 4px;
}

.v3-tier-margin {
    display: block;
    font-size: 10px;
    color: #606060;
}

.v3-tier.v3-tier-selected .v3-tier-value {
    color: #ff575f;
}

.v3-tier.v3-tier-selected .v3-tier-margin {
    color: #ff575f;
}

/* RRP-Based Range Box */
.v3-rrp-range-box {
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 14px 16px;
}

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

.v3-rrp-range-title {
    font-size: 12px;
    font-weight: 600;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.v3-rrp-range-value {
    font-size: 16px;
    font-weight: 700;
    color: #fafafa;
}

.v3-rrp-range-explainer {
    font-size: 11px;
    color: #606060;
    line-height: 1.4;
}

/* Override + Validation Row (2-column) */
.v3-override-validation-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.v3-override-box {
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 14px 16px;
}

.v3-override-box label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.v3-override-input-wrap {
    display: flex;
    align-items: center;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    overflow: hidden;
}

.v3-override-currency {
    padding: 10px 12px;
    background: #0a0a0a;
    color: #808080;
    font-size: 14px;
    font-weight: 500;
    border-right: 1px solid #444;
}

.v3-override-input-wrap .v3-input {
    border: none;
    border-radius: 0;
    background: transparent;
    flex: 1;
}

/* Price Validation in grid */
.v3-override-validation-row .v3-price-validation {
    margin-top: 0;
    display: flex;
    align-items: center;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 13px;
    color: #606060;
}

.v3-override-validation-row .v3-price-validation.v3-validation-within,
.v3-override-validation-row .v3-price-validation.v3-validation-below,
.v3-override-validation-row .v3-price-validation.v3-validation-above {
    display: flex;
}

/* Final Prices - Stacked in Right Column */
.v3-final-prices-stacked {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.v3-final-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-radius: 8px;
}

.v3-final-buy {
    background: #fbbf24;
}

.v3-final-voucher {
    background: #34d399;
}

.v3-final-label {
    color: rgba(0, 0, 0, 0.7);
    font-size: 13px;
    font-weight: 500;
}

.v3-final-value {
    color: #000;
    font-size: 24px;
    font-weight: 700;
}

.v3-send-btn {
    width: 100%;
}

/* Discount Section */
.v3-discount-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.v3-discount-section label {
    font-size: 12px;
    color: #808080;
}

.v3-discount-desc {
    font-size: 11px;
    color: #606060;
    margin: -8px 0 0 0;
    line-height: 1.4;
}

.v3-discount-buttons {
    display: flex;
    gap: 8px;
}

.v3-discount-btn {
    padding: 10px 20px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    color: #fafafa;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.v3-discount-btn:hover {
    border-color: #ff575f;
}

.v3-discount-btn.active {
    background: #ff575f;
    border-color: #ff575f;
}

/* Notes Section */
.v3-notes-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.v3-notes-section label {
    font-size: 12px;
    color: #808080;
}

/* Send Actions */
.v3-send-actions {
    display: flex;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid #2a2a2a;
}

/* ── Photo Modal ───────────────────────────── */
.v3-photo-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

.v3-photo-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.v3-photo-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
}

.v3-photo-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.v3-photo-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.v3-photo-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
}

/* ── Loading Spinner ───────────────────────── */
.v3-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #404040;
    border-top-color: #ff575f;
    border-radius: 50%;
    animation: v3-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes v3-spin {
    to { transform: rotate(360deg); }
}

/* ── Compact AI Filter ─────────────────────── */
.v3-ai-filter-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 11px;
    flex-wrap: nowrap;
}

.v3-ai-filter-text {
    white-space: nowrap;
}

/* ── Stock Info (matches AI filter height) ─── */
.v3-stock-info {
    display: flex;
    align-items: center;
    padding: 6px 0;
    font-size: 11px;
    color: #808080;
}

/* ── Stock Column Flex Height ──────────────── */
.v3-stock-column {
    display: flex;
    flex-direction: column;
}

.v3-stock-table-wrapper {
    max-height: 250px;
    overflow-y: auto;
}

/* ── Price Validation Messages ─────────────── */
/* Validation state colors (applied via JS) */
.v3-price-validation.v3-validation-within {
    background: rgba(52, 211, 153, 0.1) !important;
    border-color: rgba(52, 211, 153, 0.3) !important;
    color: #34d399 !important;
}

.v3-price-validation.v3-validation-below {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #ef4444 !important;
}

.v3-price-validation.v3-validation-above {
    background: rgba(251, 191, 36, 0.1) !important;
    border-color: rgba(251, 191, 36, 0.3) !important;
    color: #fbbf24 !important;
}

.v3-price-validation .validation-icon {
    margin-right: 8px;
}

/* ── Info Icon Tooltips ───────────────────── */
.v3-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: #333;
    border-radius: 50%;
    font-size: 9px;
    font-style: normal;
    font-weight: 600;
    color: #808080;
    cursor: help;
    margin-left: 4px;
    position: relative;
    vertical-align: middle;
}

.v3-info-icon:hover {
    background: #444;
    color: #fafafa;
}

.v3-info-icon::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 400;
    color: #a0a0a0;
    white-space: normal;
    width: 200px;
    text-align: left;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.v3-info-icon:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tooltip arrow */
.v3-info-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 101;
}

.v3-info-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Adjust tooltip position for items in pricing context bar */
.v3-context-label .v3-info-icon::after {
    left: auto;
    right: -10px;
    transform: none;
}

.v3-context-label .v3-info-icon::before {
    left: auto;
    right: 2px;
    transform: none;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 900px) {
    .v3-details-grid,
    .v3-send-grid {
        grid-template-columns: 1fr;
    }

    .v3-photos-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
