/* ============================================================
   SeeEveryPart — Global Stylesheet
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --blue:        #1d6fe8;
    --blue-dark:   #1558c0;
    --blue-light:  #e8f0fd;
    --dark:        #111827;
    --dark-mid:    #1f2937;
    --gray:        #6b7280;
    --gray-light:  #f3f4f6;
    --border:      #e5e7eb;
    --white:       #ffffff;
    --red:         #dc2626;
    --green:       #16a34a;
    --radius:      8px;
    --shadow:      0 4px 24px rgba(0,0,0,.10);
    --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--dark);
    color: var(--dark);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Utility ── */
.hidden {
    display: none !important;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============================================================
   Login Page
   ============================================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d1b2a 0%, #1a2f4e 50%, #0f2240 100%);
    padding: 1.5rem;
}

.login-card {
    background: var(--white);
    border-radius: 14px;
    box-shadow: 0 8px 48px rgba(0,0,0,.35);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* ── Logo / brand mark ── */
.login-card .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-bottom: .5rem;
}

.login-card .logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.5px;
}

.login-card h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray);
    margin-bottom: 1.75rem;
}

/* ── Form ── */
.login-form .form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.login-form label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .35rem;
}

.login-form input {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--dark);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    -webkit-appearance: none;
}

.login-form input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29,111,232,.15);
}

.login-form input::placeholder {
    color: #9ca3af;
}

/* ── Error message ── */
.error-message {
    margin-top: 1rem;
    padding: .65rem .85rem;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    color: var(--red);
    font-size: .875rem;
    text-align: left;
}

/* ── Inline loading ── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    margin-top: 1rem;
    color: var(--gray);
    font-size: .9rem;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.2rem;
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, opacity .15s, transform .1s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(.98);
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--blue);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--blue-dark);
    text-decoration: none;
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-light);
    color: #374151;
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
    text-decoration: none;
}

.btn-large {
    width: 100%;
    padding: .85rem 1.5rem;
    font-size: 1.05rem;
}

/* ============================================================
   Spinners
   ============================================================ */

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(29,111,232,.25);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

.spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(29,111,232,.2);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 1.5rem;
}

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

/* ============================================================
   Beta Badge
   ============================================================ */

.beta-badge {
    display: inline-block;
    background: var(--blue);
    color: var(--white);
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .08em;
    padding: .15em .45em;
    border-radius: 4px;
    vertical-align: middle;
    line-height: 1.6;
}

/* ============================================================
   App Page — Header
   ============================================================ */

body.app-body {
    background: var(--gray-light);
    color: var(--dark);
}

/* The app.html body doesn't have class="app-body", so we style
   based on the header element being present */
.header {
    background: var(--dark-mid);
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    max-width: 1100px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    gap: 1rem;
}

.header .logo {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.header .logo h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -0.3px;
}

.nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-wrap: wrap;
}

.nav-link {
    color: #9ca3af;
    font-size: .875rem;
    font-weight: 500;
    padding: .35rem .65rem;
    border-radius: 6px;
    transition: color .15s, background .15s;
}

.nav-link:hover {
    color: var(--white);
    background: rgba(255,255,255,.08);
    text-decoration: none;
}

/* ============================================================
   App Page — Main layout
   ============================================================ */

.main {
    padding: 2rem 0 4rem;
    background: var(--gray-light);
    min-height: calc(100vh - 60px - 60px);
}

.main .container {
    max-width: 860px;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

section {
    background: var(--white);
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: .25rem;
}

.section-subtitle {
    font-size: .875rem;
    color: var(--gray);
    margin-bottom: 1.25rem;
}

/* ============================================================
   Upload Section
   ============================================================ */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    margin-bottom: 1.25rem;
    background: var(--gray-light);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--blue);
    background: var(--blue-light);
}

.upload-icon {
    font-size: 2.25rem;
    margin-bottom: .5rem;
}

.upload-zone p {
    color: #374151;
    font-size: .95rem;
    margin-bottom: .25rem;
}

.upload-hint {
    font-size: .8rem !important;
    color: var(--gray) !important;
}

/* Mobile upload buttons — hidden on desktop */
.mobile-upload-buttons {
    display: none;
    gap: .75rem;
    margin-bottom: 1rem;
}

.btn-upload-option {
    flex: 1;
    padding: .75rem .5rem;
    font-size: .95rem;
}

/* Desktop drop zone — hidden on mobile */
.desktop-only {
    display: block;
}

/* Uploaded image previews */
.uploaded-images {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    margin-bottom: 1rem;
}

.uploaded-images img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid var(--border);
}

/* Form fields */
.form-fields {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.equipment-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.form-group label {
    font-size: .85rem;
    font-weight: 600;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    color: var(--dark);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29,111,232,.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9ca3af;
}

/* ============================================================
   Loading Section
   ============================================================ */

.loading-section {
    text-align: center;
    padding: 3rem 1.5rem;
}

.loading-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: .5rem;
    color: var(--dark);
}

.loading-content p {
    color: var(--gray);
    margin-bottom: 1.5rem;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: 320px;
    margin: 1.5rem auto;
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem .9rem;
    border-radius: var(--radius);
    font-size: .9rem;
    color: var(--gray);
    background: var(--gray-light);
    transition: background .3s, color .3s;
}

.step.active {
    background: var(--blue-light);
    color: var(--blue-dark);
    font-weight: 600;
}

.step.done {
    color: var(--green);
    background: #f0fdf4;
}

.step-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.loading-tagline {
    font-size: .85rem;
    color: #9ca3af;
    margin-top: 1.5rem;
    font-style: italic;
}

/* ============================================================
   Results Section
   ============================================================ */

.results-section {
    /* inherits section styles */
}

.identified-object {
    background: var(--blue-light);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.identified-object h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--blue-dark);
    margin-bottom: .4rem;
}

.identified-object p {
    font-size: .9rem;
    color: #374151;
}

/* Parts list */
.parts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.part-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    transition: box-shadow .2s;
}

.part-card:hover {
    box-shadow: var(--shadow);
}

.part-card h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
}

.part-card .part-description {
    font-size: .875rem;
    color: var(--gray);
}

.part-card .part-number {
    font-size: .8rem;
    color: #6b7280;
    font-family: monospace;
}

.purchase-links {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .25rem;
}

.purchase-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .75rem;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: #374151;
    background: var(--white);
    transition: background .15s, border-color .15s;
    text-decoration: none;
}

.purchase-link:hover {
    background: var(--gray-light);
    border-color: var(--blue);
    color: var(--blue);
    text-decoration: none;
}

/* ============================================================
   History Section
   ============================================================ */

.history-list {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.no-history {
    color: var(--gray);
    font-size: .9rem;
    text-align: center;
    padding: 1.5rem 0;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    cursor: pointer;
    transition: box-shadow .2s, border-color .2s;
}

.history-item:hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-sm);
}

.history-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--gray-light);
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-info strong {
    display: block;
    font-size: .9rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-info span {
    font-size: .8rem;
    color: var(--gray);
}

/* ============================================================
   Exploded View Section
   ============================================================ */

.exploded-section .form-group {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: .65rem;
    margin-bottom: 1rem;
}

.exploded-section .form-group label {
    white-space: nowrap;
}

.exploded-section .form-group input {
    flex: 1;
    min-width: 160px;
}

#exploded-view-container {
    border-radius: 10px;
    overflow: hidden;
    background: #f9fafb;
    border: 1px solid var(--border) !important;
}

#exploded-view-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================================
   Feedback Section
   ============================================================ */

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.feedback-success {
    color: var(--green);
    font-size: .9rem;
    font-weight: 600;
    margin-top: .25rem;
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    background: var(--dark-mid);
    padding: 1.25rem 0;
    text-align: center;
}

.footer p {
    font-size: .8rem;
    color: #6b7280;
    margin-bottom: .15rem;
}

.footer-link {
    color: #9ca3af;
    font-size: .8rem;
}

.footer-link:hover {
    color: var(--white);
}

/* ============================================================
   Error Modal
   ============================================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1.5rem;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
    text-align: center;
}

.modal-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: .75rem;
}

.modal-content p {
    font-size: .9rem;
    color: #374151;
    margin-bottom: 1.25rem;
}

/* ============================================================
   Interactive Exploded View (keep original)
   ============================================================ */

.illustration-wrapper {
    position: relative;
}

.illustration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.part-hotspot {
    fill: rgba(0, 123, 255, 0.2);
    stroke: rgba(0, 123, 255, 0.7);
    stroke-width: 2px;
    cursor: pointer;
    transition: fill 0.2s ease-in-out, stroke 0.2s ease-in-out;
}

.part-hotspot:hover {
    fill: rgba(0, 123, 255, 0.4);
    stroke: rgba(0, 123, 255, 1);
}

.part-card.highlight {
    background-color: #007bff;
    transition: background-color 0.5s ease-in-out;
}

/* ============================================================
   Responsive — Mobile (<= 640px)
   ============================================================ */

@media (max-width: 640px) {
    /* Login */
    .login-card {
        padding: 2rem 1.25rem;
    }

    /* App header */
    .header-content {
        height: auto;
        padding: .65rem 0;
        flex-wrap: wrap;
        gap: .5rem;
    }

    .nav {
        width: 100%;
        justify-content: flex-end;
        gap: .15rem;
    }

    .nav-link {
        font-size: .8rem;
        padding: .3rem .5rem;
    }

    /* Show mobile upload buttons, hide desktop zone */
    .mobile-upload-buttons {
        display: flex;
    }

    .desktop-only {
        display: none;
    }

    /* Equipment row → stacked */
    .equipment-info-row {
        grid-template-columns: 1fr;
    }

    /* Sections */
    section {
        padding: 1.25rem 1rem;
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid var(--border);
    }

    .main .container {
        gap: 0;
        padding: 0;
    }

    .main {
        padding: 0;
    }

    /* Progress steps */
    .progress-steps {
        max-width: 100%;
    }

    /* Exploded section input row */
    .exploded-section .form-group {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 400px) {
    .login-card .logo h1 {
        font-size: 1.35rem;
    }

    .header .logo h1 {
        font-size: 1.05rem;
    }
}
