:root {
    --primary: #10B981;
    /* Emerald Green for badges */
    --primary-dark: #059669;
    /* Teal Green for headings */
    --secondary: #64748b;
    --accent-yellow: #FFDC52;
    /* Header Yellow */
    --bg-light: #F5F6F8;
    /* Body Background */
    --card-bg: #ffffff;
    --text-main: #1A1A2E;
    /* Dark Navy for text/logo */
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: rgba(0, 0, 0, 0.08) 0px 4px 12px 0px;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 220, 82, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-yellow);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ffcf11;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 90px;
    /* Space for sticky footer */
}

header {
    background: var(--accent-yellow);
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin: 3px;
}

.logo-section {
    display: flex;
    align-items: center;
}

.site-logo {
    height: 30px;
    width: auto;
    display: block;
}

@media (max-width: 480px) {
    header {
        padding: 0.3rem 1rem;
    }

    .site-logo {
        height: 24px;
    }
}

.date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

main {
    flex: 1;
    margin-top: 0.5em;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 3px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 0.6rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

h2 {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1.25rem;
    color: var(--primary-dark);
    letter-spacing: -0.3px;
}

.input-group {
    margin-bottom: 0.7rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-yellow);
    box-shadow: 0 0 0 3px rgba(255, 220, 82, 0.2);
}

select:disabled {
    background-color: #f1f5f9;
    cursor: not-allowed;
    color: var(--text-muted);
}

.select-wrapper {
    position: relative;
}

/* Searchable Select Styles */
.searchable-select-wrapper {
    position: relative;
    width: 100%;
}

#customer-search,
#item-category-search,
#item-brand-search {
    width: 100%;
    padding-right: 2.5rem;
    /* Space for a possible icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
}

.results-container {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 250px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow-y: auto;
    display: none;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: background 0.15s;
    border-bottom: 1px solid #f1f5f9;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

.result-item.no-results {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.result-item.no-results:hover {
    background: transparent;
}

.result-item.create-new-customer {
    background: #f0fdf4;
    color: var(--primary);
    font-weight: 500;
    border-top: 1px solid #d1fae5;
    padding: 0.9rem 1rem;
}

.result-item.create-new-customer:hover {
    background: #dcfce7;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 2px solid var(--accent-yellow);
    opacity: 0.3;
}

.divider span {
    padding: 0 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin-bottom: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:active {
    background: #059669;
    transform: scale(0.98);
}

.btn-primary:hover:not(:disabled) {
    background: #0d9488;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.15);
}

.btn-primary:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
}

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

.items-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.item-card {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary-dark);
    /* Branding accent */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.item-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.item-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.confirm-badge {
    background: var(--primary);
    color: var(--navy);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 800;
    text-transform: uppercase;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 212, 255, 0.2);
}

.item-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.edit-item {
    background: #e0f2fe;
    color: #0ea5e9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.edit-item:hover {
    background: #bae6fd;
}

.remove-item {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.remove-item:hover {
    background: #fecaca;
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 10;
    max-width: 600px;
    margin: 0 auto;
    border-top: 1px solid var(--border);
}

.summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 1rem;
    padding: 0;
    color: var(--text-main);
}

/* Checkbox Styling */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 30px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    user-select: none;
    font-weight: 500;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: #f1f5f9;
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s;
}

.checkbox-container:hover input~.checkmark {
    border-color: var(--primary);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 0;
    padding: 0;
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    box-shadow: none;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary);
    padding: 0.5rem;
    flex-shrink: 0;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.3rem;
    padding-bottom: 2rem;
    -webkit-overflow-scrolling: touch;
}

.modal-header h3 {
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.7rem;
    cursor: pointer;
    color: var(--text-muted);
}

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

.full-width {
    grid-column: span 2;
}


.modal-footer {
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    background: white;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    flex-shrink: 0;
    /* Ensure it doesn't shrink */
    z-index: 10;
    justify-content: flex-end;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}



/* Ensure buttons take equal width */
.modal-footer .btn {
    flex: 1;
}

/* Collapsible Bike Details */
.bike-details-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.bike-details-toggle {
    width: 100%;
    background: var(--bg-light);
    border: none;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    transition: background 0.2s;
}

.bike-details-toggle:hover {
    background: #e9ecef;
}

.toggle-icon {
    transition: transform 0.3s;
    font-size: 0.8rem;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.bike-details-content {
    padding: 1rem;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.bike-details-content.collapsed {
    max-height: 0;
    padding: 0 1rem;
}

/* Modal Items List */
.modal-items-list {
    margin: 1rem 0;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.modal-items-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-item-card {
    background: white;
    padding: 0.5rem;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    margin-top: 4px;
}

.modal-item-details {
    flex: 1;
}

.modal-item-name {
    font-weight: 600;
    color: var(--text-main);
}

.modal-item-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

.modal-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.modal-item-remove:hover {
    color: #dc2626;
}


@media (max-width: 480px) {

    .form-grid {
        gap: 0.75rem;
    }

    .input-group {
        margin-bottom: 0.3rem;
    }

    .modal-header {
        margin-bottom: 0.5rem;
    }
}

/* Image Upload Styles */
.image-upload-wrapper {
    margin-top: 0.5rem;
}

.btn-upload {
    width: 100%;
    border: 1px dashed var(--primary);
    background: #eff6ff;
    color: var(--primary);
    padding: 1rem;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-preview {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
}

.item-images-thumb {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.nested-thumb {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border);
}