/* Base CSS Variables - Moto Parts Theme */
:root {
    /* Color Palette */
    --bg-main: #121212;
    /* deep black for app background */
    --bg-card: #242424;
    /* card background */
    --bg-elevated: #333333;
    /* elevated elements */

    --text-main: #e0e0e0;
    /* off-white for main text */
    --text-muted: #9e9e9e;
    /* gray for secondary text */

    --accent: #ff5722;
    /* motorcycle orange/red accent */
    --accent-hover: #e64a19;

    --border: #3d3d3d;
    --danger: #f44336;
    --amazon: #ff9900;
    /* Amazon color for buy button */

    /* Typography */
    --font-heading: 'Teko', sans-serif;
    --font-body: 'Roboto', sans-serif;

    /* Layout */
    --radius: 12px;
    --radius-sm: 6px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: none;
    max-width: 600px;
    /* Smartphone app width constraint on desktop */
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Header */
.app-header {
    background-color: var(--bg-card);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-main);
    /* Metallic effect gradient */
    background: linear-gradient(to bottom, #fff 0%, #b0b0b0 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-icon:active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Main Area */
.app-main {
    padding-bottom: 80px;
    /* space for FAB */
    min-height: calc(100vh - 60px);
}

/* Horizontal Scroll Categories */
.category-scroll {
    overflow-x: auto;
    white-space: nowrap;
    padding: 12px 16px;
    background-color: var(--bg-main);
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
    position: sticky;
    top: 60px;
    z-index: 9;
    border-bottom: 1px solid var(--border);
}

.category-scroll::-webkit-scrollbar {
    display: none;
}

.category-chips {
    display: inline-flex;
    gap: 10px;
}

.chip {
    background-color: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chip.active {
    background-color: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Parts List */
.parts-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.part-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border-left: 4px solid var(--border);
    /* Default left border */
}

/* Category Colors */
.part-card.cat-engine {
    border-left-color: #ef4444;
}

/* Red */
.part-card.cat-exterior {
    border-left-color: #3b82f6;
}

/* Blue */
.part-card.cat-under {
    border-left-color: #10b981;
}

/* Green */
.part-card.cat-elec {
    border-left-color: #eab308;
}

/* Yellow */
.part-card.cat-consumable {
    border-left-color: #a855f7;
}

/* Purple */

.part-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.part-category {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background-color: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 4px;
}

.part-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.part-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
    background-color: var(--bg-main);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item .label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-item .val {
    font-size: 15px;
    font-family: monospace;
    color: var(--accent);
}

.part-notes {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.part-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
}

.part-edit-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-buy {
    background-color: rgba(255, 153, 0, 0.1);
    color: var(--amazon);
    border: 1px solid var(--amazon);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

.btn-buy:active {
    background-color: rgba(255, 153, 0, 0.2);
}

.amazon-bg {
    background-color: var(--amazon);
    color: #111;
    border-color: var(--amazon);
}

.amazon-bg:active {
    background-color: #e68a00;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    right: max(24px, calc(50% - 276px));
    /* Keeps it within the 600px container */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(255, 87, 34, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    z-index: 100;
}

.fab:active {
    transform: scale(0.95);
    background-color: var(--accent-hover);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    /* Bottom sheet style on mobile */
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 600px;
    /* Match body constraint */
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(100%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.spacer {
    flex: 1;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-group.half {
    flex: 1;
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 16px;
    /* Prevents iOS auto-zoom */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.help-text {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-text {
    background: none;
    border: none;
    font-size: 15px;
    padding: 14px 20px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-danger {
    color: var(--danger);
}

.hidden {
    display: none !important;
}

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

/* SEO Article Section */
.seo-article {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1rem;
    color: var(--text-main);
}

.seo-article h2 {
    font-size: 1.25rem;
    color: var(--primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
    letter-spacing: 1px;
}

.seo-article p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.seo-article ul,
.seo-article dl {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
    color: var(--text-muted);
}

.seo-article li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.seo-article dt {
    font-weight: bold;
    margin-top: 1rem;
    color: var(--text-main);
}

.seo-article dd {
    margin-left: 0;
    margin-bottom: 1rem;
    line-height: 1.5;
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
}

/* Footer & Footer Links */
.footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-links {
    margin-bottom: 1rem;
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #ffb84d;
    text-decoration: underline;
}

.footer-links .separator {
    color: var(--border);
    margin: 0 0.5rem;
}

.footer p {
    margin: 0.5rem 0;
}

.disclaimer {
    font-size: 0.8rem;
    opacity: 0.7;
}