/* ========================================================
   ORB Touch UI - iPad-first card intake experience
   Optimized for iPad portrait (768px) and landscape (1024px)
   ======================================================== */

/* Alpine.js cloak - prevent flash of unstyled content */
[x-cloak] { display: none !important; }

/* -------------------------------------------------------
   Step Navigation Bar
   ------------------------------------------------------- */
.step-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.75rem 1rem;
    background: var(--orb-gray-800, #202020);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: sticky;
    top: 0;
    z-index: 30;
}

.step-nav__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    min-height: 48px;
    min-width: 48px;
    border: none;
    background: transparent;
    color: var(--orb-gray-400, #9ca3af);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: color 0.2s, background 0.2s;
    touch-action: manipulation;
    position: relative;
}

.step-nav__item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.step-nav__item--active {
    color: #fff;
    background: rgba(242, 107, 58, 0.15);
}

.step-nav__item--active .step-nav__icon {
    color: var(--orb-orange, #f26b3a);
}

.step-nav__item--done {
    color: var(--orb-green, #22c55e);
}

.step-nav__icon {
    display: flex;
    align-items: center;
}

.step-nav__label {
    font-family: var(--orb-font-sans);
}

.step-nav__badge {
    background: var(--orb-orange, #f26b3a);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.step-nav__connector {
    width: 32px;
    height: 2px;
    background: var(--orb-gray-700, #2c2c2c);
    flex-shrink: 0;
}

.step-nav__connector--done {
    background: var(--orb-green, #22c55e);
}

/* -------------------------------------------------------
   Intake Shell
   ------------------------------------------------------- */
.intake-shell {
    max-width: 960px;
    margin: 0 auto;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.step-content {
    padding: 1rem;
}

/* -------------------------------------------------------
   Scan Page
   ------------------------------------------------------- */
.scan-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scan-toggle-row {
    display: flex;
    justify-content: center;
    padding-top: 0.25rem;
}

/* Pill Toggle (Raw / Graded) */
.pill-toggle {
    display: inline-flex;
    background: var(--orb-gray-800, #202020);
    border-radius: 999px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.1);
}

.pill-toggle__btn {
    padding: 0.625rem 1.5rem;
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--orb-gray-400, #9ca3af);
    font-size: 1rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.pill-toggle__btn--active {
    background: var(--orb-orange, #f26b3a);
    color: #fff;
    box-shadow: 0 2px 8px rgba(242, 107, 58, 0.3);
}

/* Game Selector */
.game-selector {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.25rem 0;
}

.game-selector::-webkit-scrollbar { display: none; }

.game-chip {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    min-height: 44px;
    border: 1px solid rgba(255,255,255,0.12);
    background: var(--orb-gray-800, #202020);
    color: var(--orb-gray-300, #d1d5db);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
}

.game-chip--active {
    background: var(--orb-orange, #f26b3a);
    border-color: var(--orb-orange, #f26b3a);
    color: #fff;
}

/* Capture Area */
.capture-area {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.capture-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 220px;
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: var(--orb-radius-lg, 1.25rem);
    background: var(--orb-gray-800, #202020);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    touch-action: manipulation;
}

.capture-zone:active {
    background: rgba(242, 107, 58, 0.08);
    border-color: var(--orb-orange, #f26b3a);
}

.capture-zone__icon {
    width: 48px;
    height: 48px;
    color: var(--orb-gray-400, #9ca3af);
}

.capture-zone__text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--orb-gray-300, #d1d5db);
}

.capture-zone__hint {
    font-size: 0.85rem;
    color: var(--orb-gray-500, #6b7280);
}

.capture-zone__input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
}

.capture-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    min-height: 44px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--orb-gray-400, #9ca3af);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    touch-action: manipulation;
}

.capture-fallback:active {
    background: rgba(255,255,255,0.05);
}

/* Thumbnail Strip */
.thumb-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.5rem 0;
}

.thumb-strip::-webkit-scrollbar { display: none; }

.thumb-strip__item {
    position: relative;
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.1);
}

.thumb-strip__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-strip__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

/* Analyze Button */
.btn-analyze {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    min-height: 56px;
    border: none;
    border-radius: var(--orb-radius-md, 0.75rem);
    background: linear-gradient(135deg, var(--orb-orange, #f26b3a), var(--orb-orange-dark, #d2572d));
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    touch-action: manipulation;
    text-decoration: none;
}

.btn-analyze:active {
    transform: scale(0.98);
}

.btn-analyze:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-analyze__spinner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Spinner Dot */
.spinner-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

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

/* Progress Panel */
.progress-panel {
    background: var(--orb-gray-800, #202020);
    border-radius: var(--orb-radius-md, 0.75rem);
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.08);
}

.progress-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--orb-gray-200, #e5e7eb);
    margin-bottom: 0.75rem;
}

.progress-panel__count {
    font-variant-numeric: tabular-nums;
    color: var(--orb-orange, #f26b3a);
}

.progress-panel__bar-track {
    height: 6px;
    background: var(--orb-gray-700, #2c2c2c);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-panel__bar-fill {
    height: 100%;
    background: var(--orb-orange, #f26b3a);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.progress-panel__current {
    font-size: 0.85rem;
    color: var(--orb-gray-400, #9ca3af);
    margin-bottom: 0.5rem;
}

.progress-panel__results {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: 200px;
    overflow-y: auto;
}

.progress-panel__done {
    margin-top: 1rem;
}

.progress-card-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.progress-card-mini__img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
}

.progress-card-mini__name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--orb-gray-200, #e5e7eb);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-card-mini__price {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--orb-green, #22c55e);
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------
   Review Page
   ------------------------------------------------------- */
.review-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.review-header__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.review-header__count {
    background: var(--orb-gray-700, #2c2c2c);
    color: var(--orb-gray-300, #d1d5db);
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.review-header__info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-pill {
    padding: 0.625rem 1.25rem;
    min-height: 44px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    border: none;
    transition: all 0.15s;
}

.btn-pill--outline {
    background: transparent;
    color: var(--orb-orange, #f26b3a);
    border: 1px solid var(--orb-orange, #f26b3a);
}

.btn-pill--outline:active {
    background: rgba(242, 107, 58, 0.1);
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card-grid__loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--orb-gray-400, #9ca3af);
}

/* Card Tile */
.card-tile {
    background: var(--orb-gray-800, #202020);
    border-radius: var(--orb-radius-md, 0.75rem);
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}

.card-tile__badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.card-tile__badge--high { background: var(--orb-green, #22c55e); }
.card-tile__badge--med  { background: #eab308; color: #000; }
.card-tile__badge--low  { background: #ef4444; }

.card-tile__img-wrap {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--orb-gray-900, #181818);
}

.card-tile__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-tile__img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--orb-gray-500, #6b7280);
    font-size: 0.9rem;
}

.card-tile__info {
    padding: 0.75rem 0.75rem 0;
}

.card-tile__name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tile__meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--orb-gray-400, #9ca3af);
    margin-top: 0.25rem;
}

.card-tile__variant {
    display: inline-block;
    margin-top: 0.375rem;
    padding: 0.125rem 0.5rem;
    background: rgba(242, 107, 58, 0.15);
    color: var(--orb-orange, #f26b3a);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Condition Pills */
.condition-pills {
    display: flex;
    gap: 0.375rem;
    padding: 0.625rem 0.75rem;
}

.condition-pill {
    flex: 1;
    min-height: 36px;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: var(--orb-gray-400, #9ca3af);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
    padding: 0;
}

.condition-pill--active {
    background: var(--orb-orange, #f26b3a);
    border-color: var(--orb-orange, #f26b3a);
    color: #fff;
}

/* Price Row */
.card-tile__price {
    padding: 0 0.75rem;
}

.card-tile__price-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--orb-green, #22c55e);
    font-variant-numeric: tabular-nums;
}

.card-tile__price-value--missing {
    color: var(--orb-gray-500, #6b7280);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Card Actions */
.card-tile__actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
}

.card-tile__approve {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 0.5rem;
    background: var(--orb-green, #22c55e);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: opacity 0.15s;
}

.card-tile__approve:active { opacity: 0.8; }

.card-tile__reject {
    min-height: 44px;
    min-width: 44px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--orb-gray-400, #9ca3af);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.card-tile__reject:active { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* HTMX Swap Animation */
.card-tile.htmx-swapping {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s, transform 0.2s;
}

/* -------------------------------------------------------
   Offer Page
   ------------------------------------------------------- */
.offer-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.offer-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.offer-summary__stat {
    background: var(--orb-gray-800, #202020);
    border-radius: var(--orb-radius-md, 0.75rem);
    padding: 1rem;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.08);
}

.offer-summary__stat--highlight {
    border-color: var(--orb-orange, #f26b3a);
    background: rgba(242, 107, 58, 0.08);
}

.offer-summary__label {
    display: block;
    font-size: 0.8rem;
    color: var(--orb-gray-400, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.offer-summary__value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.offer-summary__value--market { color: var(--orb-gray-200, #e5e7eb); }
.offer-summary__value--offer  { color: var(--orb-orange, #f26b3a); }

/* Rate Toggle */
.rate-toggle {
    display: flex;
    gap: 0.5rem;
}

.rate-toggle__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    min-height: 48px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.5rem;
    background: var(--orb-gray-800, #202020);
    color: var(--orb-gray-400, #9ca3af);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    touch-action: manipulation;
}

.rate-toggle__btn--active {
    border-color: var(--orb-orange, #f26b3a);
    background: rgba(242, 107, 58, 0.1);
    color: #fff;
}

.rate-toggle__pct {
    font-weight: 700;
    color: var(--orb-orange, #f26b3a);
}

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

.offer-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.offer-table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--orb-gray-400, #9ca3af);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.offer-table__th--num { text-align: right; }

.offer-row td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--orb-gray-200, #e5e7eb);
    vertical-align: middle;
}

.offer-row__card-inner {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.offer-row__thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.offer-row__name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.offer-row__set {
    font-size: 0.8rem;
    color: var(--orb-gray-400, #9ca3af);
}

.offer-row__market,
.offer-row__offer {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.offer-row__offer {
    font-weight: 700;
    color: var(--orb-orange, #f26b3a);
}

.offer-table__total td {
    padding: 0.875rem 0.75rem;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    border-top: 2px solid rgba(255,255,255,0.12);
}

.offer-table__loading {
    text-align: center;
    padding: 2rem;
    color: var(--orb-gray-500, #6b7280);
}

/* Action Buttons Row */
.offer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    min-height: 52px;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: opacity 0.15s;
}

.btn-action:active { opacity: 0.8; }

.btn-action--customer {
    background: var(--orb-blue, #2c7be5);
    color: #fff;
    grid-column: 1 / -1;
}

.btn-action--print {
    background: var(--orb-gray-700, #2c2c2c);
    color: var(--orb-gray-200, #e5e7eb);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-action--shopify {
    background: #96bf48;
    color: #fff;
}

/* Customer Fullscreen Modal */
.customer-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--orb-gray-900, #181818);
    display: flex;
    align-items: center;
    justify-content: center;
}

.customer-modal__content {
    text-align: center;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
}

.customer-modal__logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
}

.customer-modal__title {
    font-size: 1.5rem;
    color: var(--orb-gray-400, #9ca3af);
    font-weight: 400;
    margin: 0 0 2rem;
}

.customer-modal__label {
    display: block;
    font-size: 1.25rem;
    color: var(--orb-gray-400, #9ca3af);
    margin-bottom: 0.5rem;
}

.customer-modal__price {
    display: block;
    font-size: 4rem;
    font-weight: 900;
    color: var(--orb-orange, #f26b3a);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin-bottom: 1.5rem;
}

.customer-modal__details {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.1rem;
    color: var(--orb-gray-400, #9ca3af);
    margin-bottom: 2rem;
}

.customer-modal__close {
    padding: 0.75rem 2rem;
    min-height: 48px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--orb-gray-300, #d1d5db);
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
}

/* -------------------------------------------------------
   HTMX indicator
   ------------------------------------------------------- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* -------------------------------------------------------
   iPad Breakpoints
   ------------------------------------------------------- */

/* iPad Portrait (768px) */
@media (min-width: 768px) {
    .step-content {
        padding: 1.5rem 2rem;
    }

    .capture-zone {
        min-height: 280px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .offer-summary__value {
        font-size: 2rem;
    }
}

/* iPad Landscape (1024px) */
@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Safe area insets for iPad home indicator */
@supports (padding: env(safe-area-inset-bottom)) {
    .offer-actions {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* -------------------------------------------------------
   Global touch optimizations
   ------------------------------------------------------- */
@media (hover: none) and (pointer: coarse) {
    button, select, input, a {
        touch-action: manipulation;
    }

    /* Prevent text selection on interactive elements */
    .pill-toggle__btn,
    .game-chip,
    .condition-pill,
    .step-nav__item,
    .btn-action,
    .btn-analyze,
    .btn-pill {
        -webkit-user-select: none;
        user-select: none;
    }
}
