
html {

    width: 100%;
}

body {

    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
}

/* Prevent all major containers from overflowing */
* {
    box-sizing: border-box;
}

/* ============================================
   GENERAL STYLES
   ============================================ */

.section1 {
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    direction: rtl;
    font-family: 'Cairo', sans-serif;
    padding: 20px 0;
    max-width: 100%;
    overflow-x: hidden;
}

#initial-search-info {
    min-height: 300px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

#initial-search-info h1 {
    font-size: 2em;
    margin: 0 0 15px 0;
    color: #333;
}

#initial-search-info p {
    font-size: 1.1em;
    color: #666;
    margin: 10px 0;
}

#loading-message {
    margin-top: 20px;
    font-size: 1em;
    color: #999;
}

/* Hide initial content when results load */
#initial-search-info.hidden {
    display: none;
}

.pre-section1 {
    width: 100%;
    height: 50px;
}

.container {
    width: 80%;
    margin: auto;
    background: transparent;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.section {
    background: transparent;
    padding: 0;
    margin-bottom: 20px;
}

.section h2 {
    margin-bottom: 15px;
    color: #668c0a;
    font-size: 1.5em;
    border-bottom: 2px solid #d0d0d0;
    padding-bottom: 20px;
}

/* ============================================
   COMPANY CARD STYLING
   ============================================ */

.company-card {
    position: relative;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    padding-bottom: 30px;
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 2px solid #e6e8e7;
    max-width: 100%;
    overflow-x: hidden;
}

/* Logo, Name, and Location Row */
.company-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.company-logo {
    width: 80px;
    height: 80px;
    max-width: 80px;
    max-height: 80px;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid #d8d8d8;
    padding: 5px;
    background-color: #ffffff;
    box-sizing: border-box;
    display: block;
}

.description {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    margin-top: 0%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.logo-link {
    text-decoration: none;
}

.name-link {
    text-decoration: none;
    color: inherit;
}

.company-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.company-card h3 {
    margin: 0;
    color: black;
    opacity: 0.65;
    font-size: 1.2em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Location - VISIBLE on Desktop */
.location {
    display: flex;
    text-align: left;
    color: #666;
    font-size: 1em;
    font-weight: 800;
    align-items: center;
    gap: 5px;
    justify-content: flex-start;
}

.location p {
    margin: 0;
    white-space: nowrap;
}

.location img {
    flex-shrink: 0;
    width: 20px;
    height: 15px;
    max-width: 20px;
    max-height: 15px;
}

/* ============================================
   PRODUCTS STYLING
   ============================================ */

.products {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    align-items: flex-start;
    margin-top: 15px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.product-item {
    flex: 0 0 calc(20% - 8px);
    max-width: calc(20% - 8px);
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    padding: 8px;
    transition: all 0.3s ease;
}

.product-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #668c0a;
}

.product-image {
    width: 100%;
    max-width: 100%;
    height: 110px;
    object-fit: cover;
    margin-bottom: 8px;
    border-radius: 4px;
    display: block;
}

.product-name {
    font-size: 0.85em;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin: 0;
    padding: 0 5px;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* ============================================
   COMPANY ACTION LINKS
   ============================================ */

.company-action-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
    max-width: 100%;
}

.buttons-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Profile Link - Primary Green Button */
.profile-link {
    background: #668c0a;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 140, 10, 0.3);
    font-size: 0.9em;
}

.profile-link:hover {
    background: #557308;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 140, 10, 0.4);
}

/* Contact Button - Secondary Green Button */
.contact-company-btn {
    background: #7ca50f;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 12px rgba(124, 165, 15, 0.3);
    font-family: 'Cairo', sans-serif;
}

.contact-company-btn:hover {
    background: #668c0a;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 165, 15, 0.4);
}

/* ============================================
   SOCIAL MEDIA ICONS
   ============================================ */

.social-icons-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.social-icons-container a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.social-icons-container i {
    font-size: 28px;
    color: #000000;
    opacity: 0.5;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.social-icons-container a:hover i {
    opacity: 0.9;
    transform: scale(1.1);
}

/* ============================================
   CONTACT POPUP STYLING - GREEN THEME
   ============================================ */

.contact-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid #668c0a;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    min-width: 320px;
    max-width: 500px;
    animation: popupSlideIn 0.3s ease-out;
    box-sizing: border-box;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes popupSlideOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.contact-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

.contact-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #668c0a;
    padding-bottom: 15px;
}

.contact-popup-title {
    font-size: 1.4em;
    font-weight: bold;
    color: #668c0a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.contact-popup-close {
    background: #f5f5f5;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.contact-popup-close:hover {
    background: #e74c3c;
    color: white;
    transform: rotate(90deg);
}

.contact-popup-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid #dee2e6;
}

.contact-item:hover {
    background: linear-gradient(135deg, #668c0a 0%, #557308 100%);
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(102, 140, 10, 0.3);
}

.contact-item:hover i,
.contact-item:hover a,
.contact-item:hover span {
    color: white !important;
}

.contact-item i {
    color: #668c0a;
    font-size: 20px;
    min-width: 25px;
    text-align: center;
    transition: color 0.3s ease;
}

.contact-item a {
    color: #333;
    text-decoration: none;
    font-size: 1em;
    flex: 1;
    word-break: break-all;
    font-weight: 500;
    transition: color 0.3s ease;
}

.contact-item a:hover {
    text-decoration: underline;
}

.contact-item span {
    color: #333;
    font-size: 1em;
    flex: 1;
    word-break: break-word;
    font-weight: 500;
    transition: color 0.3s ease;
}

.no-contact-info {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

/* ============================================
   NO RESULTS STYLING
   ============================================ */

.no-results {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.no-results h2 {
    color: #e74c3c;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.search-suggestions {
    margin: 30px 0;
    text-align: right;
}

.search-suggestions h3 {
    color: #2c3e50;
    font-size: 1.2em;
    margin-bottom: 15px;
}

.search-suggestions ul {
    list-style: none;
    padding: 0;
}

.search-suggestions li {
    padding: 8px 0;
    color: #555;
}

.popular-categories {
    margin-top: 30px;
}

.popular-categories h3 {
    color: #2c3e50;
    font-size: 1.2em;
    margin-bottom: 15px;
}

.category-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.category-links a {
    background: #668c0a;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.3s ease;
}

.category-links a:hover {
    background: #557308;
}

.section1-inner-blank {
    width: 100%;
    height: 500px;
}

/* ============================================
   PAGINATION STYLING - GREEN THEME
   ============================================ */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 20px;
    flex-wrap: wrap;
    max-width: 100%;
    padding: 0 10px;
}

.pagination a, .pagination span {
    padding: 8px 12px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination a.active {
    background: #668c0a;
    color: white;
    border-color: #668c0a;
}

.pagination a:hover {
    background: #f1f8e9;
    border-color: #668c0a;
}

.section1-end-blank {
    width: 100%;
    height: 50px;
}

/* ============================================
   ADDITIONAL SAFETY MEASURES
   ============================================ */

img {
    max-width: 100%;
    height: auto;
}

table {
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

pre, code {
    max-width: 100%;
    overflow-x: auto;
}

/* Fix search title section */
.search-title-section {
    max-width: 100%;
    box-sizing: border-box;
    padding: 40px 20px;
    margin-left: 0;
    margin-right: 0;
}

.search-title-section h1 {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE
   ============================================ */

@media (max-width: 768px) {
    .nav-end-blank {
        height: 20px;
    }

    .container {
        width: 98%;
        max-width: 100%;
        padding: 0 1%;
        box-sizing: border-box;
    }

    .company-card {
        padding: 15px;
        padding-bottom: 20px;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 100%;
    }

    .section {
        padding: 0;
    }

    .section h2 {
        font-size: 1.3em;
    }

    /* Mobile: Grid layout for header */
    .company-header {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto auto;
        gap: 10px;
        align-items: start;
    }

    /* Logo on the left - spans rows 1-2 */
    .logo-link {
        grid-column: 1;
        grid-row: 1 / 3;
        display: flex;
        align-items: flex-start;
        padding-top: 5px;
    }

    .company-logo {
        width: 85px;
        height: 85px;
        max-width: 85px;
        max-height: 85px;
    }

    /* Company name on the right - row 1 */
    .company-info {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .company-card h3 {
        font-size: 1em;
        text-align: right;
        margin-top: 0;
        margin-bottom: 5px;
    }

    /* Location under the name - row 2, right side */
    .location {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        text-align: right;
        font-size: 0.75em;
        margin: 0;
        width: auto;
        min-width: auto;
        gap: 5px;
        align-self: start;
        flex-direction: row-reverse;
    }

    .location img {
        width: 16px;
        height: 12px;
        max-width: 16px;
        max-height: 12px;
        flex-shrink: 0;
    }
    
    .location p {
        margin: 0;
        white-space: nowrap;
    }

    /* Description spans full width - row 3 */
    .description {
        grid-column: 1 / 3;
        grid-row: 3;
        text-align: right;
        font-size: 0.8em;
        margin: 0;
        margin-top: 5px;
        padding-right: 0;
        align-self: start;
    }

    /* Products - show only 3 in a row */
    .products {
        margin-top: 15px;
        justify-content: flex-start;
        gap: 8px;
    }

    .product-item {
        flex: 0 0 calc(33.333% - 6px);
        max-width: calc(33.333% - 6px);
        padding: 6px;
    }
    
    .product-item.responsive-hidden {
        display: none;
    }

    .product-image {
        height: 90px;
        margin-bottom: 6px;
    }

    .product-name {
        font-size: 0.75em;
    }

    /* Action links - HORIZONTAL LAYOUT */
    .company-action-links {
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        flex-wrap: nowrap;
    }

    .buttons-container {
        display: flex;
        gap: 8px;
        flex: 1;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .buttons-container a,
    .buttons-container button {
        font-size: 0.8em;
        padding: 10px 14px;
        flex: 1;
        white-space: nowrap;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .social-icons-container {
        display: flex !important;
        gap: 6px;
        flex-shrink: 0;
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .social-icons-container a i {
        font-size: 22px;
    }

    /* Contact Popup Mobile */
    .contact-popup {
        min-width: 280px;
        max-width: 90vw;
        padding: 20px;
    }

    .contact-popup-title {
        font-size: 1.2em;
    }

    .contact-item {
        padding: 12px;
        gap: 10px;
    }
}

@media (max-width: 361px) {
    .container {
        width: 96%;
        padding: 0 2%;
    }

    /* Show only 2 products per row on very small screens */
    .product-item {
        flex: 0 0 calc(50% - 5px);
        max-width: calc(50% - 5px);
    }
    
    .product-image {
        height: 75px;
    }
    
    .product-name {
        font-size: 0.65em;
    }
    
    .company-logo {
        width: 85px;
        height: 85px;
        max-width: 85px;
        max-height: 85px;
    }

    .buttons-container a,
    .buttons-container button {
        font-size: 0.7em;
        padding: 8px 10px;
    }

    .social-icons-container i {
        font-size: 20px;
    }
}