/* ============================================================
   UsedAlert Dashboard — app.css
   Amazon-inspired dark nav, orange accents, clean tables
   ============================================================ */

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: #f5f5f5;
    color: #1a1a1a;
}

/* ----- Typography ------------------------------------------ */
h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ----- Navigation Bar -------------------------------------- */
.navbar {
    background: #232f3e;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.nav-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 54px;
}

a.nav-logo,
.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ff9900;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-tab {
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.nav-tab:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.nav-tab.active {
    color: #fff;
    background: rgba(255,153,0,0.18);
    border-bottom: 2px solid #ff9900;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.nav-email {
    color: #aaa;
    font-size: 0.82rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- Main Content ---------------------------------------- */
.main-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ----- Cards ----------------------------------------------- */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
    padding: 20px 24px;
}

.section-title {
    margin-bottom: 14px;
    color: #232f3e;
}

/* ----- Auth View ------------------------------------------- */
#auth-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    padding: 24px 16px;
}

.auth-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: 36px 40px 32px;
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ff9900;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.auth-tagline {
    text-align: center;
    color: #666;
    font-size: 0.88rem;
    margin-bottom: 24px;
}

.form-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 18px;
    color: #232f3e;
}

.field-group {
    margin-bottom: 14px;
}

.field-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #444;
    margin-bottom: 5px;
}

.field-group input {
    width: 100%;
    padding: 9px 12px;
    font-size: 16px; /* prevents iOS zoom */
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-group input:focus {
    border-color: #ff9900;
    box-shadow: 0 0 0 2px rgba(255,153,0,0.20);
}

.auth-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 0.875rem;
    margin-bottom: 12px;
    display: none;
}

.auth-error.visible {
    display: block;
}

.auth-toggle {
    text-align: center;
    margin-top: 14px;
    font-size: 0.875rem;
    color: #555;
}

.auth-toggle a {
    color: #0073bb;
    text-decoration: none;
    font-weight: 500;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* ----- Buttons --------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: filter 0.15s, opacity 0.15s;
    white-space: nowrap;
}

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

.btn:not(:disabled):hover {
    filter: brightness(0.93);
}

.btn:not(:disabled):active {
    filter: brightness(0.85);
}

.btn-primary {
    background: #ff9900;
    color: #111;
}

.btn-add {
    background: #38a169;
    color: #fff;
}

.btn-remove {
    background: #e53e3e;
    color: #fff;
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-dismiss {
    background: none;
    border: 1px solid #e2e8f0;
    color: #a0aec0;
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 8px;
    cursor: pointer;
    border-radius: 4px;
}
.btn-dismiss:hover {
    color: #e53e3e;
    border-color: #fed7d7;
}

.btn-edit {
    background: #3182ce;
    color: #fff;
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-save {
    background: #38a169;
    color: #fff;
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-cancel {
    background: #e2e8f0;
    color: #444;
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-logout {
    background: transparent;
    color: #ccc;
    border: 1px solid #555;
    padding: 5px 12px;
    font-size: 0.82rem;
    font-weight: 500;
}

.btn-logout:not(:disabled):hover {
    color: #fff;
    border-color: #aaa;
    filter: none;
    background: rgba(255,255,255,0.08);
}

.btn-block {
    width: 100%;
    padding: 11px;
    font-size: 1rem;
}

/* ----- Lookup Row ------------------------------------------ */
.lookup-row {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}

.lookup-row input {
    flex: 1;
    padding: 9px 12px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.lookup-row input:focus {
    border-color: #ff9900;
    box-shadow: 0 0 0 2px rgba(255,153,0,0.20);
}

/* ----- Preview Card ---------------------------------------- */
.preview-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #eee;
}

.preview-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #eee;
    flex-shrink: 0;
    background: #fafafa;
}

.preview-details {
    flex: 1;
    min-width: 0;
}

.preview-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: #1a1a1a;
    line-height: 1.3;
}

.preview-asin-label {
    font-size: 0.78rem;
    color: #888;
    margin-bottom: 12px;
}

.chips-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

/* ----- Condition Chips ------------------------------------- */
.condition-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid transparent;
    transition: opacity 0.15s, background 0.15s;
    background: #e2e8f0;
    color: #555;
}

/* Active states */
.chip-likenew.active {
    background: #bee3f8;
    border-color: #3182ce;
    color: #1a365d;
}

.chip-verygood.active {
    background: #c6f6d5;
    border-color: #38a169;
    color: #1c4532;
}

.chip-good.active {
    background: #fefcbf;
    border-color: #d69e2e;
    color: #744210;
}

.chip-acceptable.active {
    background: #e2e8f0;
    border-color: #a0aec0;
    color: #2d3748;
}

/* Inactive (all chips share same inactive style) */
.chip:not(.active) {
    background: #f7fafc;
    border-color: transparent;
    color: #a0aec0;
    text-decoration: line-through;
}

/* Read-only chip badges in table */
.chip-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid transparent;
    margin: 2px 2px 2px 0;
}

.chip-badge-likenew {
    background: #bee3f8;
    border-color: #3182ce;
    color: #1a365d;
}

.chip-badge-verygood {
    background: #c6f6d5;
    border-color: #38a169;
    color: #1c4532;
}

.chip-badge-good {
    background: #fefcbf;
    border-color: #d69e2e;
    color: #744210;
}

.chip-badge-acceptable {
    background: #e2e8f0;
    border-color: #a0aec0;
    color: #2d3748;
}

/* ----- Price Row ------------------------------------------- */
.price-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.price-row label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #444;
    white-space: nowrap;
}

.price-row input,
.edit-price-input {
    width: 120px;
    padding: 7px 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.price-row input:focus,
.edit-price-input:focus {
    border-color: #ff9900;
    box-shadow: 0 0 0 2px rgba(255,153,0,0.20);
}

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

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

.data-table thead {
    background: #f7f8fa;
    border-bottom: 2px solid #e8e8e8;
}

.data-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #fafbfc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.col-img {
    width: 56px;
    padding-right: 4px !important;
}

.product-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 3px;
    border: 1px solid #eee;
    background: #fafafa;
    display: block;
}

.product-name-cell {
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.35;
    max-width: 220px;
}

.product-asin {
    font-size: 0.75rem;
    color: #999;
    display: block;
    margin-top: 2px;
}

.price-cell {
    font-weight: 600;
    color: #232f3e;
    white-space: nowrap;
}

.date-cell {
    font-size: 0.82rem;
    color: #888;
    white-space: nowrap;
}

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    align-items: center;
}

.alert-link {
    color: #0073bb;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.alert-link:hover {
    text-decoration: underline;
}

/* Edit row inline state */
.edit-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.edit-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ----- Empty States ---------------------------------------- */
.empty-state {
    padding: 28px 0 8px;
    text-align: center;
    color: #999;
    font-size: 0.92rem;
}

/* ----- Add Section ----------------------------------------- */
.add-section .section-title {
    margin-bottom: 14px;
}

/* ----- Loading spinner ------------------------------------- */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.btn-primary.loading::after,
.btn-add.loading::after {
    border-top-color: #232f3e;
    border-color: rgba(0,0,0,0.2);
    border-top-color: #333;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ----- Responsive (mobile) --------------------------------- */
@media (max-width: 600px) {
    .auth-card {
        padding: 28px 20px 24px;
    }

    .nav-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 12px;
        gap: 8px;
    }

    .nav-logo {
        font-size: 1.1rem;
    }

    .nav-tabs {
        order: 3;
        width: 100%;
    }

    .nav-user {
        margin-left: auto;
    }

    .nav-email {
        display: none;
    }

    .main-content {
        padding: 14px 10px 40px;
    }

    .card {
        padding: 16px 14px;
    }

    .lookup-row {
        flex-direction: column;
    }

    .lookup-row input {
        width: 100%;
    }

    .preview-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .preview-img {
        width: 100px;
        height: 100px;
    }

    .condition-chips {
        justify-content: center;
    }

    .price-row {
        justify-content: center;
    }

    .data-table th,
    .data-table td {
        padding: 8px 8px;
    }

    .product-name-cell {
        max-width: 140px;
    }

    .actions-cell {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .btn-edit,
    .btn-remove,
    .btn-save,
    .btn-cancel {
        font-size: 0.78rem;
        padding: 4px 8px;
    }
}
