/* Parts2Profit — Identify Page
   Mobile-first, camera-centric design */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a237e;
    --primary-light: #3949ab;
    --accent: #00c853;
    --accent-dark: #00a844;
    --bg: #f5f5f7;
    --card: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --border: #e5e5ea;
    --success: #34c759;
    --warning: #ff9500;
    --danger: #ff3b30;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Top bar */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
}

.nav-link:hover { color: var(--text); }

.cta-small {
    background: var(--primary);
    color: #fff !important;
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Main container */
.identify-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 2rem;
}

/* Upload area */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    text-align: center;
}

.upload-prompt { width: 100%; }

.camera-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-prompt h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.upload-prompt p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.upload-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: inherit;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-secondary); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text); }

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    width: 100%;
}

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

/* Text divider */
.text-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.text-divider::before,
.text-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Text input form */
.text-input-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.text-input-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.text-input-form input:focus { border-color: var(--primary); }

.btn-submit { white-space: nowrap; }

/* Preview area */
.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
}

.preview-area img {
    width: 100%;
    max-height: 50vh;
    object-fit: contain;
    border-radius: var(--radius);
    background: #000;
}

.preview-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.preview-controls input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}
.preview-controls input:focus { border-color: var(--primary); }

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.loading-sub {
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    color: var(--text-secondary) !important;
}

/* Results */
.results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
}

.result-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

/* Identification */
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.result-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.confidence-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    white-space: nowrap;
}

.confidence-high { background: #dcfce7; color: #15803d; }
.confidence-medium { background: #fef9c3; color: #a16207; }
.confidence-low { background: #fee2e2; color: #dc2626; }

.identification p {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Value summary */
.value-summary h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.value-range {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.value-low, .value-high {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-dark);
}

.value-separator {
    color: var(--text-secondary);
    font-size: 1.25rem;
}

.verdict {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    font-weight: 500;
    padding: 0.75rem;
    background: #f0fdf4;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

/* Parts list */
.parts-list h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.parts-count {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.part-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

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

.part-info {
    flex: 1;
}

.part-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.part-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.part-value {
    font-weight: 700;
    color: var(--accent-dark);
    white-space: nowrap;
    font-size: 0.95rem;
}

.demand-high { color: var(--success); }
.demand-medium { color: var(--warning); }
.demand-low { color: var(--text-secondary); }

/* Difficulty badges */
.difficulty {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.difficulty-easy { background: #dcfce7; color: #15803d; }
.difficulty-moderate { background: #fef9c3; color: #a16207; }
.difficulty-hard { background: #fee2e2; color: #dc2626; }

/* Disassembly */
.disassembly h3 { margin-bottom: 1rem; }

.disassembly h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
}

.disassembly h4:first-child { margin-top: 0; }

.disassembly ul, .disassembly ol {
    padding-left: 1.25rem;
    line-height: 1.8;
    color: var(--text);
}

.disassembly li { font-size: 0.95rem; }

.safety-warning {
    background: #fff3cd;
    border-left: 3px solid var(--warning);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Signup prompt */
.signup-prompt {
    text-align: center;
    background: linear-gradient(135deg, #e8eaf6, #c5cae9);
    border: none;
}
.signup-prompt h3 { margin-bottom: 0.5rem; }
.signup-prompt p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Follow-up */
.followup h3 { margin-bottom: 0.75rem; }

#followup-form {
    display: flex;
    gap: 0.5rem;
}

#followup-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}
#followup-form input:focus { border-color: var(--primary); }

.followup-answer {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    line-height: 1.7;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

/* Live Assist */
.live-assist {
    text-align: center;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border: none;
}
.live-assist h3 { margin-bottom: 0.5rem; }
.live-assist p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* Marketplace */
.marketplace h3 { margin-bottom: 0.75rem; }

.connected-badge {
    display: inline-block;
    background: #dcfce7;
    color: #15803d;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 0.75rem;
}

.marketplace-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

#listing-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.listing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

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

.listing-part-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
}

.listing-price {
    font-weight: 600;
    color: var(--accent-dark);
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-list {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.btn-list:hover { background: var(--primary-light); }
.btn-list:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-list-all {
    margin-top: 0.5rem;
}

/* New scan */
.new-scan {
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 480px) {
    .upload-prompt h1 { font-size: 1.5rem; }
    .upload-buttons { flex-direction: column; }
    .upload-buttons .btn { width: 100%; }
    .text-input-form { flex-direction: column; }
    .text-input-form .btn { width: 100%; }
    .value-low, .value-high { font-size: 1.5rem; }
    #followup-form { flex-direction: column; }
}
