/* CSS Reset and Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success-color: #059669;
    --success-light: #d1fae5;
    --warning-color: #d97706;
    --warning-light: #fef3c7;
    --error-color: #dc2626;
    --error-light: #fee2e2;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.icon-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0.25rem;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-primary);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
}

/* Sections */
.section {
    background: var(--bg-primary);
    margin: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Search Container */
.search-container {
    margin-bottom: 1rem;
}

.search-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.search-input-wrapper input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input-wrapper input:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

.search-status {
    margin-top: 0.5rem;
    font-size: 0. min-height: 875rem;
   1.25rem;
}

.search-status.info {
    color: var(--primary-color);
}

.search-status.success {
    color: var(--success-color);
}

.search-status.error {
    color: var(--error-color);
}

.search-status.warning {
    color: var(--warning-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.btn-search {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
}

.btn-search:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary {
    width: 100%;
    background: var(--primary-color);
    color: white;
    padding: 0.875rem;
    font-size: 1rem;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-submit {
    width: 100%;
    background: var(--success-color);
    color: white;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-submit:hover:not(:disabled) {
    background: #047857;
    box-shadow: var(--shadow-md);
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background: var(--error-light);
    color: var(--error-color);
}

.btn-add {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-add:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

/* Search Results */
.search-results {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.search-results.hidden {
    display: none;
}

.search-results h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.result-item:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.result-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.result-uom {
    display: inline-block;
    background: var(--bg-tertiary);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* Cart Items */
.badge {
    background: var(--primary-color);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-cart {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-cart svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-cart p {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.empty-cart small {
    font-size: 0.875rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.cart-item:hover {
    border-color: var(--primary-color);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.cart-item-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cart-item-uom {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

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

.quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.quantity-btn {
    background: var(--bg-tertiary);
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    font-weight: 500;
}

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

.quantity-input {
    width: 60px;
    border: none;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem;
    -moz-appearance: textfield;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cart-item-total {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

/* Notes Section */
.notes-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.notes-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Submit Section */
.submit-status {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    display: none;
}

.submit-status.show {
    display: block;
}

.submit-status.success {
    background: var(--success-light);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.submit-status.error {
    background: var(--error-light);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 3000;
}

.loading-overlay.hidden {
    display: none;
}

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

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

#loadingText {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 640px) {
    .section {
        margin: 0.75rem;
        padding: 1rem;
    }

    .header-content {
        padding: 0;
    }

    .app-header h1 {
        font-size: 1rem;
    }

    .search-input-wrapper {
        flex-direction: column;
    }

    .btn-search {
        width: 100%;
    }

    .cart-item {
        flex-wrap: wrap;
    }

    .cart-item-quantity {
        flex: 1;
        justify-content: flex-end;
    }

    .cart-item-total {
        width: 100%;
        text-align: right;
        margin-top: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .app-header,
    .search-section,
    .submit-section,
    .icon-btn {
        display: none !important;
    }

    .section {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}


/* Sync Section */
.sync-section {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg-primary) 100%);
    border: 1px solid var(--primary-color);
    border-left-width: 4px;
}

.sync-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.sync-info h2 {
    margin-bottom: 0.25rem;
}

.sync-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.sync-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-sync {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-sync:hover {
    background: var(--primary-hover);
}

.btn-sync:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.btn-sync svg {
    transition: transform 0.3s ease;
}

.btn-sync:not(:disabled):hover svg {
    transform: rotate(180deg);
}

/* Status Badges */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 500;
}

.status-badge.online {
    background: var(--success-light);
    color: var(--success-color);
}

.status-badge.offline {
    background: var(--error-light);
    color: var(--error-color);
}

.pending-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 500;
    background: var(--warning-light);
    color: var(--warning-color);
    margin-right: 0.5rem;
}

/* Updated Search Section */
.search-section .search-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.search-section #productSearch {
    flex: 1;
}

.btn-search {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-search:hover {
    background: var(--primary-hover);
}


/* Two column form row */
.form-row.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row.two-col {
        grid-template-columns: 1fr;
    }
}

/* Select styling */
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select:invalid,
select option[value=""] {
    color: var(--text-light);
}
