/* ==========================================================================
   1. General Body & Page Styles
   ========================================================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 20px;
}

/* ==========================================================================
   2. Layout Containers
   ========================================================================== */

.layout-container {
    display: flex;
    gap: 25px;
    max-width: 1100px;
    margin: 0 auto;
    align-items: flex-start;
}
@media screen and (max-width: 500px) {
    .layout-container { flex-direction: column; }
}

.main-content {
    flex: 3;
    background: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sidebar {
    flex: 1;
    position: sticky;
    top: 20px;
}

/* ==========================================================================
   3. Typography
   ========================================================================== */

h1, h2, h3 {
    color: #1a202c;
    border-bottom: 2px solid #edf2f7;
    padding-bottom: 10px;
    margin-top: 0;
}

h3 { margin-top: 20px; }

/* ==========================================================================
   4. Form Elements & Buttons
   ========================================================================== */

.form-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 25px;
}

.input-wrapper {
    position: relative;
    display: flex;
}

.input-wrapper.search-wrapper {
    display: flex;
    gap: 10px; /* Space between input and toggle button */
}

input[type="text"],
input[type="number"],
button {
    padding: 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.2s;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: #4a5568;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 85, 104, 0.1);
}

/* --- Main Action Button --- */
button#add-to-order {
    background-color: #4a5568;
    color: white;
    cursor: pointer;
    border: none;
    font-weight: 600;
}

button#add-to-order:hover { background-color: #2d3748; }
button#add-to-order:disabled { background-color: #a0aec0; cursor: not-allowed; }

/* --- Toggle Button Styling --- */
.mode-toggle {
    flex: 0 0 48px;
    height: 48px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #edf2f7;
    border: 1px solid #cbd5e0;
    color: #4a5568;
    cursor: pointer;
}

.mode-toggle svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy transition */
}

.mode-toggle:hover {
    background-color: #e2e8f0;
    border-color: #a0aec0;
}

/* State: Create Mode Active */
.mode-toggle.active {
    background-color: #3182ce;
    border-color: #3182ce;
    color: white;
}

.mode-toggle.active:hover {
    background-color: #2c5282;
}

/* Rotate SVG to form an X */
.mode-toggle.active svg {
    transform: rotate(135deg); 
}

/* Visual cue for the input when in Create Mode */
input.create-mode-active {
    border-color: #3182ce;
    background-color: #ebf8ff;
}

input.create-mode-active:focus {
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

/* ==========================================================================
   5. Inventory Status & Notifications
   ========================================================================== */

.inventory-status {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9em;
    font-weight: 600;
    color: #4a5568;
    background-color: #edf2f7;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#product-sku { padding-right: 120px; }

.inventory-status.visible { opacity: 1; }
.inventory-status.error { color: #c53030; background-color: #fed7d7; }

/* --- Notification Box --- */
.notification-box {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s;
    opacity: 1;
}

.notification-box.hidden {
    top: -100px;
    opacity: 0;
}

/* Default/Error State */
.notification-box.error {
    background-color: #e53e3e; /* Red */
}

/* Success State */
.notification-box.success {
    background-color: #48bb78; /* Green */
}

/* ==========================================================================
   6. Autocomplete List
   ========================================================================== */

.autocomplete-items {
    position: absolute;
    z-index: 99;
    width: 100%;
    left: 0;
    top: 100%;
    margin-top: 4px;
    background-color: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
}

.autocomplete-items div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px; 
    cursor: pointer; 
    border-bottom: 1px solid #edf2f7;
}

.autocomplete-items div:last-child { border-bottom: none; }
.autocomplete-items div:hover { background-color: #f7fafc; }

.autocomplete-active { 
    background-color: #4a5568 !important; 
    color: #ffffff; 
}
.autocomplete-active .autocomplete-order-id,
.autocomplete-active .autocomplete-email { color: #e2e8f0; }

.autocomplete-order-id { font-weight: 600; white-space: nowrap; color: #4a5568; }
.autocomplete-name { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.autocomplete-email { color: #718096; font-size: 0.9em; white-space: nowrap; }
.autocomplete-count {
    background-color: #edf2f7;
    color: #4a5568;
    font-size: 0.85em;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    margin-left: auto; /* This pushes the count to the far right */
}

/* ==========================================================================
   7. Sidebar
   ========================================================================== */

details {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
}

summary { font-weight: 600; cursor: pointer; color: #2d3748; }

.instructions ol { padding-left: 20px; line-height: 1.6; color: #4a5568; }
.instructions code { background-color: #edf2f7; padding: 2px 6px; border-radius: 4px; font-family: monospace; }

.activity-log-container {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

#activity-log {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.9em;
}

#activity-log li {
    background-color: #fff;
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
    animation: fadeIn 0.5s ease-in-out;
}

.log-product { font-weight: 600; color: #2d3748; }
.log-details { font-size: 0.9em; color: #718096; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   8. Session History
   ========================================================================== */

#history-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#history-list li {
    background: #f7fafc;
    border-radius: 6px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: center;
}

#history-list li input {
    flex: 1;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    padding: 8px;
    text-align: left;
    font-size: 14px;
    border-radius: 4px;
}

.history-sku { flex-basis: 30%; }
.history-quantity { flex-basis: 15%; text-align: center !important; }
.history-customer { flex-basis: 55%; }