:root {
    --chem-primary: #0073aa;
    --chem-secondary: #005177;
    --chem-bg: #f8f9fa;
    --chem-card-bg: #ffffff;
    --chem-text: #333333;
    --chem-text-light: #666666;
    --chem-border: #e1e4e8;
    --chem-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --chem-radius: 12px;
    --chem-accent: #eef2f7;
}

.chemsearch-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    color: var(--chem-text);
}

/* Header & Search Bar */
.chemsearch-header {
    text-align: center;
    margin-bottom: 40px;
}

.chemsearch-search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    background: var(--chem-card-bg);
    border: 2px solid var(--chem-border);
    border-radius: 50px;
    padding: 5px 10px;
    transition: all 0.3s ease;
    box-shadow: var(--chem-shadow);
}

.chemsearch-search-wrapper:focus-within {
    border-color: var(--chem-primary);
    box-shadow: 0 0 0 4px rgba(0, 115, 170, 0.1);
}

#chemsearch-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 20px;
    font-size: 18px;
    outline: none;
    color: var(--chem-text);
}

#chemsearch-submit {
    background: var(--chem-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

#chemsearch-submit:hover {
    background: var(--chem-secondary);
}

/* Results Grid */
.chemsearch-results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

@media (max-width: 900px) {
    .chemsearch-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .chemsearch-results-grid {
        grid-template-columns: 1fr;
    }
    .chemsearch-header {
        position: sticky;
        top: 10px;
        z-index: 100;
    }
}

/* Result Card */
.chem-card {
    background: var(--chem-card-bg);
    border-radius: var(--chem-radius);
    border: 1px solid var(--chem-border);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.chem-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.chem-card-image {
    background: #fdfdfd;
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--chem-border);
}

.chem-card-image img {
    max-width: 100%;
    height: auto;
    max-height: 150px;
}

.chem-card-content {
    padding: 20px;
    flex-grow: 1;
}

.chem-card-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--chem-primary);
    line-height: 1.3;
}

.chem-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.chem-tag {
    background: var(--chem-accent);
    color: var(--chem-text-light);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.chem-tag.cas-tag {
    background: #e6fffa;
    color: #2c7a7b;
}

.chem-view-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--chem-primary);
    color: var(--chem-primary);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.chem-view-btn:hover {
    background: var(--chem-primary);
    color: white;
}

/* Loader & Skeleton */
.chemsearch-loader {
    width: 100%;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

.skeleton-card {
    height: 300px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--chem-radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error Message */
.chemsearch-error {
    text-align: center;
    padding: 40px;
    background: #fff5f5;
    color: #c53030;
    border-radius: var(--chem-radius);
    border: 1px solid #feb2b2;
}

/* Modal */
.chemsearch-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.chemsearch-modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.chemsearch-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.modal-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
}

@media (max-width: 500px) {
    .modal-details-grid {
        grid-template-columns: 1fr;
    }
}

.modal-label {
    font-weight: 700;
    color: var(--chem-text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.modal-value {
    font-size: 16px;
    color: var(--chem-text);
    word-break: break-word;
}

.synonyms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.synonym-item {
    background: #f1f3f5;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: #495057;
}

/* Physical Properties Section */
.physical-props-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid var(--chem-border);
}

.physical-props-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--chem-primary);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
}

.physical-props-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 600px) {
    .physical-props-grid {
        grid-template-columns: 1fr;
    }
}

.prop-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--chem-accent);
    border-radius: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.prop-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.prop-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.prop-icon.color-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.prop-icon.odor-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.prop-icon.boiling-icon {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: #c53030;
}

.prop-icon.melting-icon {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #2c7a7b;
}

.prop-icon.flash-icon {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #c05621;
}

.prop-icon.density-icon {
    background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
    color: #553c9a;
}

.prop-details {
    flex: 1;
    min-width: 0;
}

.prop-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--chem-text-light);
    margin-bottom: 4px;
}

.prop-value {
    font-size: 14px;
    color: var(--chem-text);
    line-height: 1.4;
    word-break: break-word;
}

/* Loading state for physical properties */
.physical-props-loading {
    padding: 30px;
    text-align: center;
}

.props-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--chem-text-light);
}

.props-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--chem-border);
    border-top-color: var(--chem-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.props-error {
    padding: 20px;
    text-align: center;
    color: var(--chem-text-light);
    background: #f8f9fa;
    border-radius: 8px;
}

/* Responsive adjustments for modal */
@media (max-width: 600px) {
    .chemsearch-modal-content {
        padding: 25px;
    }
    
    .physical-props-title {
        font-size: 16px;
    }
    
    .prop-item {
        padding: 12px;
    }
    
    .prop-icon {
        width: 32px;
        height: 32px;
    }
    
    .prop-value {
        font-size: 13px;
    }
}


/* ========================================
   Safety and Hazards Section
   ======================================== */

.safety-hazards-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid var(--chem-border);
}

.safety-hazards-title {
    font-size: 18px;
    font-weight: 700;
    color: #dc2626;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
}

.safety-hazards-loading {
    padding: 30px;
    text-align: center;
}

/* No Hazards Container */
.no-hazards-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-radius: 12px;
    border: 1px solid #86efac;
}

.no-hazards-icon {
    margin-bottom: 16px;
}

.no-hazards-text {
    font-size: 18px;
    font-weight: 700;
    color: #166534;
    margin-bottom: 8px;
}

.no-hazards-subtext {
    font-size: 14px;
    color: #15803d;
    text-align: center;
}

/* Safety Grid - Two Column Layout */
.safety-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.safety-grid.single-column {
    grid-template-columns: 1fr;
}

@media (max-width: 700px) {
    .safety-grid {
        grid-template-columns: 1fr;
    }
}

/* Safety Column */
.safety-column {
    background: #fafafa;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--chem-border);
}

.safety-column-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-bottom: 1px solid var(--chem-border);
}

.safety-column-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--chem-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.safety-column-content {
    padding: 18px;
}

/* GHS Column Specific */
.ghs-column .safety-column-header {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

/* NFPA Column Specific */
.nfpa-column .safety-column-header {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

/* GHS Pictograms */
.ghs-pictograms {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    justify-content: center;
}

.ghs-pictogram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ghs-pictogram img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.ghs-pictogram img:hover {
    transform: scale(1.1);
}

.pictogram-label {
    font-size: 10px;
    color: var(--chem-text-light);
    text-align: center;
    max-width: 70px;
    line-height: 1.2;
}

/* GHS Signal Word */
.ghs-signal-word {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
}

.ghs-signal-word.signal-danger {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fca5a5;
}

.ghs-signal-word.signal-warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
}

.signal-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--chem-text-light);
}

.signal-value {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.signal-danger .signal-value {
    color: #dc2626;
}

.signal-warning .signal-value {
    color: #d97706;
}

/* GHS Hazard Statements */
.ghs-hazard-statements {
    background: white;
    border-radius: 8px;
    padding: 14px;
    border: 1px solid var(--chem-border);
}

.hazard-statements-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--chem-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.hazard-statements-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.hazard-statement {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid #ef4444;
}

.hazard-code {
    font-size: 11px;
    font-weight: 700;
    color: white;
    background: #ef4444;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.hazard-desc {
    font-size: 13px;
    color: var(--chem-text);
    line-height: 1.4;
}

/* NFPA Diamond */
.nfpa-diamond-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.nfpa-diamond {
    width: 120px;
    height: 120px;
    position: relative;
    transform: rotate(45deg);
}

.nfpa-quadrant {
    position: absolute;
    width: 50%;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: #000;
    border: 1px solid rgba(0,0,0,0.2);
}

.nfpa-quadrant span {
    transform: rotate(-45deg);
}

.nfpa-fire {
    top: 0;
    left: 0;
    background: #dc2626;
    color: white;
    border-radius: 4px 0 0 0;
}

.nfpa-instability {
    top: 0;
    right: 0;
    background: #fbbf24;
    color: #000;
    border-radius: 0 4px 0 0;
}

.nfpa-special {
    bottom: 0;
    right: 0;
    background: white;
    color: #000;
    border-radius: 0 0 4px 0;
}

.nfpa-health {
    bottom: 0;
    left: 0;
    background: #2563eb;
    color: white;
    border-radius: 0 0 0 4px;
}

/* NFPA Ratings List */
.nfpa-ratings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nfpa-rating-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--chem-border);
}

.nfpa-rating-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    flex-shrink: 0;
}

.nfpa-rating-health .nfpa-rating-badge {
    background: #2563eb;
    color: white;
}

.nfpa-rating-fire .nfpa-rating-badge {
    background: #dc2626;
    color: white;
}

.nfpa-rating-instability .nfpa-rating-badge {
    background: #fbbf24;
    color: #000;
}

.nfpa-special-item .nfpa-rating-badge.special {
    background: #ffffff;
    color: #000;
    border: 2px solid #333;
    font-size: 12px;
    min-width: 32px;
    width: auto;
    padding: 0 6px;
}

.nfpa-rating-info {
    flex: 1;
    min-width: 0;
}

.nfpa-rating-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--chem-text);
    margin-bottom: 2px;
}

.nfpa-rating-desc {
    font-size: 11px;
    color: var(--chem-text-light);
    line-height: 1.3;
}

/* Responsive adjustments for safety section */
@media (max-width: 600px) {
    .safety-hazards-title {
        font-size: 16px;
    }
    
    .ghs-pictogram img {
        width: 50px;
        height: 50px;
    }
    
    .nfpa-diamond {
        width: 100px;
        height: 100px;
    }
    
    .nfpa-quadrant {
        font-size: 20px;
    }
    
    .hazard-statements-list {
        max-height: 150px;
    }
}
