/* =========================================================
   CHEMICAL RESISTANCE LOOKUP - Modal & Components
   ========================================================= */

/* -------------------------
   1) Trigger Button
   ------------------------- */
.mb-chemical-resistance-wrapper {
    margin: 15px 0;
}

.mb-chem-lookup-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #008345 0%, #006633 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 131, 69, 0.3);
}

.mb-chem-lookup-btn:hover {
    background: linear-gradient(135deg, #006633 0%, #004d26 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 131, 69, 0.4);
}

.mb-chem-lookup-btn:active {
    transform: translateY(0);
}

.mb-chem-lookup-icon {
    font-size: 18px;
}

/* -------------------------
   2) Modal Overlay & Container
   ------------------------- */
.mb-chem-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(2px);
}

.mb-chem-modal-overlay.active {
    display: flex;
}

.mb-chem-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* -------------------------
   3) Modal Header
   ------------------------- */
.mb-chem-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-radius: 12px 12px 0 0;
}

.mb-chem-modal-header h3 {
    margin: 0 0 4px 0;
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.mb-chem-compound-label {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.mb-chem-compound-label strong {
    color: #008345;
    font-weight: 600;
}

.mb-chem-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mb-chem-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* -------------------------
   4) Modal Body
   ------------------------- */
.mb-chem-modal-body {
    padding: 20px 24px;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* -------------------------
   5) Search Input
   ------------------------- */
.mb-chem-search-wrapper {
    position: relative;
    margin-bottom: 12px;
}
 
.mb-chem-search-input {
    width: 100%;
 
    padding: 12px 45px 12px 44px !important;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.mb-chem-search-input:focus {
    border-color: #008345;
    box-shadow: 0 0 0 3px rgba(0, 131, 69, 0.1);
}

.mb-chem-search-input::placeholder {
    color: #999;
}

.mb-chem-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    pointer-events: none;
}

.screen-reader-text {
    position: absolute;
    padding-left: 45px;
    width: 1px;
    height: 1px;
 
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* -------------------------
   6) Dropdown List
   ------------------------- */
.mb-chem-dropdown {
    flex: 1;
    min-height: 150px;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: #fafafa;
}

.mb-chem-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mb-chem-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.15s ease;
}

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

.mb-chem-item:hover {
    background: #e8f5e9;
}

.mb-chem-item.selected {
    background: #c8e6c9;
}

.mb-chem-item.hidden {
    display: none;
}

.mb-chem-name {
    font-size: 14px;
    color: #333;
    flex: 1;
    padding-right: 10px;
}

/* -------------------------
   7) Resistance Badges
   ------------------------- */
.mb-chem-resistance-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.resistance-excellent {
    background: #c8e6c9;
    color: #2e7d32;
}

.resistance-good {
    background: #dcedc8;
    color: #558b2f;
}

.resistance-fair {
    background: #fff9c4;
    color: #f9a825;
}

.resistance-not-recommended {
    background: #ffcdd2;
    color: #c62828;
}

.resistance-unknown {
    background: #e0e0e0;
    color: #616161;
}

.resistance-resistant {
    background: #b3e5fc;
    color: #0277bd;
}

/* -------------------------
   8) Results Area
   ------------------------- */
.mb-chem-results {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    min-height: 60px;
    transition: all 0.3s ease;
}

.mb-chem-results-placeholder {
    margin: 0;
    color: #888;
    font-size: 14px;
    font-style: italic;
    text-align: center;
}

.mb-chem-results-content {
    margin: 0;
    font-size: 15px;
    color: #333;
    line-height: 1.5;
}

.mb-chem-results-content .chemical-name {
    font-weight: 600;
    color: #333;
}

.mb-chem-results-content .resistance-value {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 4px;
}

.mb-chem-results.has-result {
    background: #e8f5e9;
    border-color: #a5d6a7;
}

.mb-chem-results.has-result.resistance-not-recommended {
    background: #ffebee;
    border-color: #ef9a9a;
}

/* -------------------------
   9) Modal Footer
   ------------------------- */
.mb-chem-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 12px;
    justify-content: center;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
}

.mb-chem-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.mb-chem-btn-close {
    background: #e0e0e0;
    color: #333;
}

.mb-chem-btn-close:hover {
    background: #d0d0d0;
}

.mb-chem-btn-another {
    background: #fff;
    color: #008345;
    border: 2px solid #008345;
}

.mb-chem-btn-another:hover {
    background: #e8f5e9;
}

.mb-chem-btn-done {
    background: #008345;
    color: #fff;
}

.mb-chem-btn-done:hover {
    background: #006633;
}

/* Hide buttons initially */
.mb-chem-btn-another,
.mb-chem-btn-done {
    display: none;
}

.mb-chem-modal-footer.has-selection .mb-chem-btn-close {
    display: none;
}

.mb-chem-modal-footer.has-selection .mb-chem-btn-another,
.mb-chem-modal-footer.has-selection .mb-chem-btn-done {
    display: inline-block;
}

/* -------------------------
   10) Mobile Responsive
   ------------------------- */
@media (max-width: 767px) {
    .mb-chem-modal-overlay {
        padding: 10px;
        align-items: flex-end;
    }
    
    .mb-chem-modal {
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        animation: modalSlideUp 0.3s ease;
    }
    
    @keyframes modalSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .mb-chem-modal-header {
        padding: 16px 20px;
        border-radius: 16px 16px 0 0;
    }
    
    .mb-chem-modal-header h3 {
        font-size: 18px;
    }
    
    .mb-chem-modal-body {
        padding: 16px 20px;
    }
    
    .mb-chem-search-input {
        padding: 10px 14px 10px 40px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .mb-chem-dropdown {
        max-height: 200px;
    }
    
    .mb-chem-item {
        padding: 12px 14px;
    }
    
    .mb-chem-modal-footer {
        padding: 14px 20px;
        flex-wrap: wrap;
    }
    
    .mb-chem-btn {
        flex: 1;
        min-width: 120px;
    }
    
    .mb-chem-lookup-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .mb-chem-modal-header h3 {
        font-size: 16px;
        padding-right: 30px;
    }
    
    .mb-chem-compound-label {
        font-size: 13px;
    }
    
    .mb-chem-name {
        font-size: 13px;
    }
    
    .mb-chem-resistance-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .mb-chem-results {
        padding: 12px;
    }
    
    .mb-chem-results-content {
        font-size: 14px;
    }
}

/* -------------------------
   11) No Results State
   ------------------------- */
.mb-chem-no-results {
    padding: 20px;
    text-align: center;
    color: #888;
    font-style: italic;
}

/* -------------------------
   12) Loading State
   ------------------------- */
.mb-chem-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
}

.mb-chem-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #008345;
    border-radius: 50%;
    margin-right: 10px;
    animation: spin 0.8s linear infinite;
}

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

/* =========================================================
   END OF CHEMICAL RESISTANCE LOOKUP STYLES
   ========================================================= */