/**
 * Frontend styles for eBay Supplies Inventory
 * Desktop-first, iPad-friendly design
 */

/* Base container */
.esi-frontend {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1e1e1e;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* ========================================
   Password Gate
   ======================================== */

.esi-password-gate {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.esi-password-box {
    background: #fff;
    padding: 48px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.esi-password-box h2 {
    margin: 0 0 12px;
    font-size: 24px;
    font-weight: 600;
    color: #1e3a5f;
}

.esi-password-box p {
    margin: 0 0 24px;
    color: #646970;
}

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

#esi-password-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}

#esi-password-input:focus {
    border-color: #2271b1;
}

.esi-error {
    color: #d63638;
    margin-top: 16px;
    font-size: 14px;
}

/* ========================================
   Buttons
   ======================================== */

.esi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    min-height: 48px; /* Touch-friendly */
}

.esi-btn-primary {
    background: #2271b1;
    color: #fff;
}

.esi-btn-primary:hover {
    background: #135e96;
}

.esi-btn-secondary {
    background: #f0f0f1;
    color: #1e1e1e;
    border: 1px solid #c3c4c7;
}

.esi-btn-secondary:hover {
    background: #e0e0e0;
}

/* ========================================
   Inventory View
   ======================================== */

.esi-inventory .esi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.esi-inventory .esi-header h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    color: #1e3a5f;
}

/* Alert banner */
.esi-alert {
    padding: 16px 20px;
    border-radius: 6px;
    margin-bottom: 24px;
    font-weight: 500;
}

.esi-alert-warning {
    background: #fcf0f0;
    border: 1px solid #d63638;
    color: #8a1c1f;
}

/* Empty state */
.esi-empty {
    text-align: center;
    padding: 60px 20px;
    background: #f6f7f7;
    border-radius: 8px;
    color: #646970;
}

/* ========================================
   Department Tabs
   ======================================== */

.esi-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 0;
}

.esi-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #50575e;
    background: #f6f7f7;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    margin-bottom: -2px;
    transition: background 0.15s, color 0.15s;
    min-height: 48px; /* Touch-friendly */
}

.esi-tab:hover {
    background: #fff;
    color: #1e3a5f;
}

.esi-tab.is-active {
    background: #fff;
    color: #1e3a5f;
    border-color: #ddd;
    border-bottom: 2px solid #fff;
}

.esi-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: #d63638;
    border-radius: 10px;
}

/* Department sections */
.esi-department-section {
    margin-bottom: 30px;
}

/* Tab mode (applied by JS): show only the active section, hide redundant titles */
.esi-inventory.esi-tabbed .esi-department-section {
    display: none;
}

.esi-inventory.esi-tabbed .esi-department-section.is-active {
    display: block;
}

.esi-inventory.esi-tabbed .esi-department-title {
    display: none;
}

/* Without JS, the tab bar is useless — hide it and fall back to the long list */
.esi-inventory:not(.esi-tabbed) .esi-tabs {
    display: none;
}

.esi-department-title {
    margin: 0 0 15px;
    padding: 12px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1e3a5f;
    border-bottom: 2px solid #2271b1;
}

/* ========================================
   Table Styles
   ======================================== */

.esi-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.esi-table thead {
    background: #f6f7f7;
}

.esi-table th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: #50575e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #ddd;
}

.esi-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

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

/* Column widths */
.esi-table .col-status {
    width: 70px;
    text-align: center;
}

.esi-table .col-qty {
    width: 160px;
}

.esi-table .col-reorder {
    width: 100px;
    text-align: center;
}

.esi-table .col-unit {
    width: 120px;
    color: #646970;
}

.esi-table .col-name {
    font-weight: 500;
}

/* Status indicators */
.esi-status-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.esi-status-low {
    background-color: #d63638;
}

.esi-status-ok {
    background-color: #00a32a;
}

.esi-status-auto {
    background-color: #2271b1;
}

/* Row status styling */
.esi-row.status-low {
    background-color: #fef7f7;
}

.esi-row.status-low:hover {
    background-color: #fcf0f0;
}

.esi-row.status-auto {
    background-color: #f7fafc;
}

.esi-row.status-auto:hover {
    background-color: #f0f6fc;
}

.esi-row.status-ok:hover {
    background-color: #f9f9f9;
}

/* Badge */
.esi-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
}

.esi-badge-auto {
    background: #2271b1;
    color: #fff;
}

/* ========================================
   Quantity Input Cell
   ======================================== */

.esi-qty-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.esi-qty-input {
    width: 100px;
    padding: 12px 14px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    transition: all 0.2s;
    -moz-appearance: textfield;
    min-height: 48px; /* Touch-friendly */
}

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

.esi-qty-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

.esi-qty-input.saving {
    background: #f6f7f7;
    color: #888;
}

.esi-qty-input.saved {
    border-color: #00a32a;
    background: #f0faf0;
}

.esi-qty-input.error {
    border-color: #d63638;
    background: #fef7f7;
}

/* Feedback indicator */
.esi-qty-feedback {
    font-size: 13px;
    min-width: 50px;
    color: #00a32a;
    opacity: 0;
    transition: opacity 0.2s;
}

.esi-qty-feedback.visible {
    opacity: 1;
}

.esi-qty-feedback.error {
    color: #d63638;
}

/* ========================================
   Legend
   ======================================== */

.esi-legend {
    margin-top: 24px;
    padding: 16px 20px;
    background: #f6f7f7;
    border-radius: 6px;
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
}

.esi-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #50575e;
}

/* ========================================
   Footer
   ======================================== */

.esi-footer {
    margin-top: 24px;
    text-align: center;
}

.esi-help-text {
    color: #646970;
    font-size: 14px;
    margin: 0;
}

/* ========================================
   iPad / Tablet adjustments
   ======================================== */

@media screen and (max-width: 1024px) {
    .esi-frontend {
        padding: 16px;
    }
    
    .esi-table th,
    .esi-table td {
        padding: 14px 16px;
    }
    
    .esi-table .col-unit {
        display: none;
    }
}

@media screen and (max-width: 768px) {
    .esi-inventory .esi-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .esi-inventory .esi-header h2 {
        font-size: 24px;
    }
    
    .esi-table .col-reorder {
        display: none;
    }
    
    .esi-table th,
    .esi-table td {
        padding: 12px;
    }
    
    .esi-qty-input {
        width: 80px;
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .esi-legend {
        gap: 16px;
    }

    .esi-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .esi-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 14px;
    }
}
