/* ==========================================================================
   Chemicals & Petrochemicals Directory Pages Stylesheet
   Applies to:
     - /LandingPage/Home/Chemicals
     - /LandingPage/Home/PetroChemicals
     - /LandingPage/IHome/Chemicals (Hindi)
     - /LandingPage/IHome/PetroChemicals (Hindi)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Breakpoint-based Width Utilities (A1-A5, I1-I5)
   -------------------------------------------------------------------------- */
@media only screen and (max-width: 600px) {
    .A1 { width: 20rem; }
    .I1 { width: 20rem; }
}

@media only screen and (min-width: 600px) {
    .A2 { width: 20rem; }
    .I2 { width: 20rem; }
}

@media only screen and (min-width: 768px) {
    .A3 { width: 20rem; }
    .I3 { width: 20rem; }
}

@media only screen and (min-width: 992px) {
    .A4 { width: 20rem; }
    .I4 { width: 60rem; }
}

@media only screen and (min-width: 1200px) {
    .A5 { width: 100rem; }
    .I5 { width: 68rem; }
}

/* --------------------------------------------------------------------------
   2. Modal & Popup Dialog Styles
   -------------------------------------------------------------------------- */
.popup-link {
    display: flex;
    flex-wrap: wrap;
}

.popup-link a {
    background: #333;
    color: #fff;
    padding: 10px 30px;
    border-radius: 5px;
    font-size: 17px;
    cursor: pointer;
    margin: 20px;
    text-decoration: none;
}

.popup-container {
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease-in-out;
    transform: scale(1.3);
    position: fixed;
    z-index: 1000 !important;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(21, 17, 17, 0.61);
    display: flex;
    align-items: center;
}

.popup-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    margin-top: 13rem;
    width: 85%;
}

.popup-content p {
    font-size: 15px;
    padding: 10px;
    line-height: 20px;
}

.popup-content a.close {
    color: #aaaaaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    background: none;
    padding: 2px;
    margin: 0;
    text-decoration: none;
}

.popup-content a.close:hover {
    color: #333;
}

.popup-content span:hover,
.popup-content span:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.popup-container:target {
    visibility: visible;
    opacity: 1;
    transform: scale(1);
}

.popup-container h3 {
    margin: 10px;
}

.popup-style-2 {
    transform: scale(0.3);
}

.popup-style-2:target {
    transform: scale(1);
}

.popup-style-3 {
    left: 100%;
}

.popup-style-3:target {
    left: 0;
}

/* --------------------------------------------------------------------------
   3. Theme & Dark Mode
   -------------------------------------------------------------------------- */
:root {
    --background-light: #ffffff;
    --background-dark: rgb(68, 68, 68);
    --text-light: #000000;
    --text-dark: white;
}

.dark-mode {
    background-color: var(--background-dark);
    color: var(--text-dark);
}

.dark-mode h1,
.dark-mode h2,
.dark-mode h3,
.dark-mode p,
.dark-mode span,
.dark-mode div td {
    color: var(--text-dark);
}

/* --------------------------------------------------------------------------
   4. Directory Table Layout & Exact Format matching Screenshots 1, 2, 3
   -------------------------------------------------------------------------- */

/* Responsive table wrapper */
.chemicals-directory-responsive,
.about-agency .table-responsive:has(.chemical-list),
.about-agency .table-responsive:has(.chemicals-directory-table) {
    overflow-x: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 2rem !important;
}

/* Base table style: 2px solid black, collapse */
table.chemicals-directory-table,
.about-agency table:has(.chemical-list),
.about-agency table.chemicals-directory-table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    margin-bottom: 1.5rem !important;
    border: 2px solid #000000 !important;
}

table.chemicals-directory-table,
table.chemicals-directory-table th,
table.chemicals-directory-table td,
.about-agency table:has(.chemical-list),
.about-agency table:has(.chemical-list) th,
.about-agency table:has(.chemical-list) td {
    border: 2px solid #000000 !important;
    padding: 6px 8px !important;
}

/* Category Header (e.g. Major Petro-chemicals / Chemicals) */
table.chemicals-directory-table tr:first-child th,
.about-agency table:has(.chemical-list) tr:first-child th,
table.chemicals-directory-table th[colspan="3"][style*="background-color: #3668a2"],
.about-agency table:has(.chemical-list) th[colspan="3"][style*="background-color: #3668a2"] {
    background-color: #3668a2 !important;
    color: #ffffff !important;
    text-align: center !important;
    padding: 10px 12px !important;
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    font-family: 'Poppins', sans-serif !important;
}

/* Sub-header row like "A. Basic Major Petro-chemicals" */
table.chemicals-directory-table tr:nth-child(2) th,
.about-agency table:has(.chemical-list) tr:nth-child(2) th,
table.chemicals-directory-table th.text-justify.text-center,
.about-agency table:has(.chemical-list) th.text-justify.text-center {
    background-color: #ffffff !important;
    color: #000000 !important;
    text-align: center !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    padding: 8px 12px !important;
    font-family: 'Poppins', sans-serif !important;
}

/* Column Header Row (Sl. No. | Group | Products) */
table.chemicals-directory-table tr[style*="background-color: #3668a2"] th:not([colspan]),
.about-agency table:has(.chemical-list) tr[style*="background-color: #3668a2"] th:not([colspan]),
table.chemicals-directory-table th.col-slno,
table.chemicals-directory-table th.col-group,
table.chemicals-directory-table th.col-products {
    background-color: #3668a2 !important;
    color: #ffffff !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding: 8px 10px !important;
    font-family: 'Poppins', sans-serif !important;
}

/* Column 1: Sl. No. (Compact, centered, ~70px) */
table.chemicals-directory-table th.col-slno,
table.chemicals-directory-table td.col-slno,
.about-agency table:has(.chemical-list) th.col-slno,
.about-agency table:has(.chemical-list) tr > td:first-of-type,
table.chemicals-directory-table tr > td:first-of-type {
    width: 70px !important;
    max-width: 85px !important;
    min-width: 55px !important;
    text-align: center !important;
    vertical-align: middle !important;
    font-weight: 600 !important;
    font-size: 1.15rem !important;
    white-space: nowrap !important;
}

/* Column 2: Group (Tight width, no huge blank gap) */
table.chemicals-directory-table th.col-group,
table.chemicals-directory-table td.col-group,
.about-agency table:has(.chemical-list) th.col-group,
.about-agency table:has(.chemical-list) tr > td:nth-of-type(2),
table.chemicals-directory-table tr > td:nth-of-type(2) {
    width: 220px !important;
    max-width: 260px !important;
    min-width: 170px !important;
    vertical-align: middle !important;
    padding: 8px 10px !important;
    text-align: left !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
}

table.chemicals-directory-table td.col-group a,
table.chemicals-directory-table td.col-group b,
.about-agency table:has(.chemical-list) tr > td:nth-of-type(2) a,
.about-agency table:has(.chemical-list) tr > td:nth-of-type(2) b,
table.chemicals-directory-table tr > td:nth-of-type(2) a,
table.chemicals-directory-table tr > td:nth-of-type(2) b {
    font-size: 1rem !important;
    color: #1a4492 !important;
    line-height: 1.35 !important;
    display: inline-block !important;
    text-transform: uppercase !important;
    text-decoration: none !important;
}

table.chemicals-directory-table td.col-group i,
.about-agency table:has(.chemical-list) tr > td:nth-of-type(2) i,
table.chemicals-directory-table tr > td:nth-of-type(2) i {
    color: #3668a2 !important;
    font-size: 1.15rem !important;
    margin-left: 4px !important;
    vertical-align: middle !important;
}

/* Column 3: Products (Takes remaining wide space, 75%+ of table) */
table.chemicals-directory-table th.col-products,
table.chemicals-directory-table td.col-products,
.about-agency table:has(.chemical-list) th.col-products,
.about-agency table:has(.chemical-list) tr > td:nth-of-type(3),
.about-agency table:has(.chemical-list) tr > td:last-of-type,
table.chemicals-directory-table tr > td:nth-of-type(3),
table.chemicals-directory-table tr > td:last-of-type {
    width: auto !important;
    vertical-align: middle !important;
    padding: 8px 10px !important;
    text-align: left !important;
}

/* Reset any text-justify on paragraph inside products cell */
.about-agency table:has(.chemical-list) td p,
table.chemicals-directory-table td p {
    font-size: 0.95rem !important;
    text-align: left !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.5 !important;
}

/* Flex wrap container for product chips */
table.chemicals-directory-table td span[style*="display: flex"],
.about-agency table:has(.chemical-list) td span[style*="display: flex"],
.chemicals-product-wrap {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 4px 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* --------------------------------------------------------------------------
   5. Exact Product Box Style from Screenshots 1, 2, 3
   -------------------------------------------------------------------------- */
.about-agency .chemical-list,
.chemical-list {
    display: inline-block !important;
    white-space: nowrap !important;
    word-break: normal !important;
    border: 1.1px solid #000000 !important;
    background: #ffffff !important;
    border-radius: 0px !important; /* Strict sharp rectangular corners */
    padding: 3px 6px !important;
    margin: 2px 4px 2px 0px !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    color: #000000 !important;
    box-shadow: none !important;
    transition: none !important;
    box-sizing: border-box !important;
}

.about-agency .chemical-list:hover,
.chemical-list:hover {
    background: #f1f5f9 !important;
    border-color: #000000 !important;
    color: #000000 !important;
}

/* --------------------------------------------------------------------------
   6. Responsive Layout Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
    table.chemicals-directory-table th.col-group,
    table.chemicals-directory-table td.col-group,
    .about-agency table:has(.chemical-list) tr > td:nth-of-type(2),
    table.chemicals-directory-table tr > td:nth-of-type(2) {
        width: 180px !important;
    }
}

@media (max-width: 768px) {
    .chemicals-directory-responsive,
    .about-agency .table-responsive:has(.chemical-list) {
        overflow-x: auto !important;
    }
}

/* --------------------------------------------------------------------------
   7. Print Optimization (Ensures 100% visible width in Print & PDF)
   -------------------------------------------------------------------------- */
@media print {
    @page {
        margin: 8mm 6mm;
        size: auto;
    }

    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Container: strictly full printable width, no negative margins or overflowing widths */
    .container,
    .about-agency .container,
    .chemicals-directory-responsive,
    .about-agency .table-responsive:has(.chemical-list),
    .about-agency .table-responsive:has(.chemicals-directory-table) {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        overflow: visible !important;
    }

    /* Table: fits exactly inside page boundaries with table-layout: fixed */
    table.chemicals-directory-table,
    .about-agency table:has(.chemical-list),
    .about-agency table.chemicals-directory-table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        border: 1.5px solid #000000 !important;
        margin-bottom: 1rem !important;
    }

    /* Explicit column widths for print colgroup */
    table.chemicals-directory-table colgroup col:first-child,
    table.chemicals-directory-table col:first-child {
        width: 45px !important;
    }
    table.chemicals-directory-table colgroup col:nth-child(2),
    table.chemicals-directory-table col:nth-child(2) {
        width: 155px !important;
    }
    table.chemicals-directory-table colgroup col:nth-child(3),
    table.chemicals-directory-table col:nth-child(3) {
        width: auto !important;
    }

    table.chemicals-directory-table th,
    table.chemicals-directory-table td,
    .about-agency table:has(.chemical-list) th,
    .about-agency table:has(.chemical-list) td {
        border: 1.5px solid #000000 !important;
        padding: 4px 6px !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
        box-sizing: border-box !important;
    }

    /* Sl. No. in Print */
    table.chemicals-directory-table th.col-slno,
    table.chemicals-directory-table td.col-slno,
    .about-agency table:has(.chemical-list) th.col-slno,
    .about-agency table:has(.chemical-list) tr > td:first-of-type,
    table.chemicals-directory-table tr > td:first-of-type {
        width: 45px !important;
        max-width: 45px !important;
        min-width: 40px !important;
        font-size: 0.95rem !important;
        text-align: center !important;
        padding: 4px 2px !important;
        box-sizing: border-box !important;
    }

    /* Group in Print: fixed 155px */
    table.chemicals-directory-table th.col-group,
    table.chemicals-directory-table td.col-group,
    .about-agency table:has(.chemical-list) th.col-group,
    .about-agency table:has(.chemical-list) tr > td:nth-of-type(2),
    table.chemicals-directory-table tr > td:nth-of-type(2) {
        width: 155px !important;
        max-width: 155px !important;
        min-width: 155px !important;
        padding: 4px 6px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    table.chemicals-directory-table td.col-group a,
    table.chemicals-directory-table td.col-group b,
    .about-agency table:has(.chemical-list) tr > td:nth-of-type(2) a,
    .about-agency table:has(.chemical-list) tr > td:nth-of-type(2) b,
    table.chemicals-directory-table tr > td:nth-of-type(2) a,
    table.chemicals-directory-table tr > td:nth-of-type(2) b {
        font-size: 0.85rem !important;
    }

    /* Products in Print: takes the remaining width and wraps strictly */
    table.chemicals-directory-table th.col-products,
    table.chemicals-directory-table td.col-products,
    .about-agency table:has(.chemical-list) th.col-products,
    .about-agency table:has(.chemical-list) tr > td:nth-of-type(3),
    .about-agency table:has(.chemical-list) tr > td:last-of-type,
    table.chemicals-directory-table tr > td:nth-of-type(3),
    table.chemicals-directory-table tr > td:last-of-type {
        width: auto !important;
        padding: 4px 6px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* Product chip boxes in Print: wrap cleanly, never overflow right margin */
    .about-agency .chemical-list,
    .chemical-list {
        display: inline-block !important;
        white-space: nowrap !important;
        max-width: 100% !important;
        border: 1px solid #000000 !important;
        background: #ffffff !important;
        border-radius: 0px !important;
        padding: 2px 4px !important;
        margin: 1px 2px !important;
        font-size: 0.74rem !important;
        line-height: 1.25 !important;
        box-sizing: border-box !important;
    }

    /* Flex container for product chips in Print */
    table.chemicals-directory-table td span[style*="display: flex"],
    .about-agency table:has(.chemical-list) td span[style*="display: flex"],
    .chemicals-product-wrap {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 2px 3px !important;
        box-sizing: border-box !important;
    }

    /* Hide non-printable elements */
    .popup-container,
    .popup-content,
    nav[aria-label*="Breadcrumb"] {
        display: none !important;
    }
}
