/**
 * APW Solutions Plugin - CSS Styles
 *
 * Styles for the Solutions shortcodes display and filtering
 */

/* ----------------------------------------
   1. CSS VARIABLES (CUSTOM PROPERTIES)
   ---------------------------------------- */
:root {
    /* Spacing values */
    --apw-spacing-xs: 5px;
    --apw-spacing-sm: 10px;
    --apw-spacing-md: 20px;
    --apw-spacing-lg: 30px;
    --apw-spacing-xl: 40px;

    /* Colors */
    --apw-primary-bg: #003E57;           /* Main background color */
    --apw-secondary-bg: #244B5A;         /* Start of gradient */
    --apw-tertiary-bg: #178093;          /* End of gradient */
    --apw-text-color: #fff;              /* Main text color */
    --apw-dark-text: #0D252C;            /* Dark text color */
    --apw-link-color: #00AADE;           /* Link color */
    --apw-card-bg: #003E57;              /* Card background */
    --apw-content-bg: #fff;              /* Content background */
    --apw-border-color: rgba(255,255,255,0.1); /* Border color */
    --apw-hover-color: #004a6a;          /* Hover state background */
    --apw-caret-color: #FFB100;          /* Dropdown caret color */

    /* Typography */
    --apw-font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --apw-heading-font-family: 'Lexend', var(--apw-font-family);
    --apw-font-size-sm: 0.875rem;
    --apw-font-size-base: 1rem;
    --apw-font-size-md: 1.125rem;
    --apw-font-size-lg: 1.25rem;
    --apw-font-size-xl: 1.5rem;
    --apw-line-height: 1.6;

    /* Specific typography sizes */
    --apw-title-size: 64px;
    --apw-dropdown-size: 30px; /* Updated to match title size better */
    --apw-text-size: 21px;
    --apw-button-line-height: 24px;
    --apw-description-line-height: 30px;

    /* Layout dimensions */
    --apw-card-width: 427px;
    --apw-card-height: 626px;
    --apw-image-width: 427px;
    --apw-image-height: 264px;
}

/* ----------------------------------------
   2. GENERAL CONTAINER STYLES
   ---------------------------------------- */
.apw-solutions-container,
.apw-solutions-category-container {
    font-family: var(--apw-font-family);
    color: var(--apw-text-color);
    line-height: var(--apw-line-height);
    width: 100%;
    margin-bottom: var(--apw-spacing-lg);
}

/* ----------------------------------------
   3. HEADER AND FILTER SECTION
   ---------------------------------------- */
.apw-solutions-header {
    display: flex;
    align-items: center;
    justify-content: center; /* Center content */
    margin-bottom: var(--apw-spacing-lg);
    background-color: transparent; /* No background */
    padding: var(--apw-spacing-md) var(--apw-spacing-lg);
    text-align: center;
}

/* Override Flatsome theme styles for the title */
.apw-solutions-container .apw-solutions-title,
.apw-solutions-category-container .apw-solutions-title {
    margin: 0;
    font-family: Montserrat;
    font-size: var(--apw-title-size);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    color: var(--apw-text-color) !important;
    display: inline-block;
    width: auto !important; /* Override Flatsome's 100% width */
    max-width: none !important; /* Ensure Flatsome doesn't constrain width */
}

.apw-solutions-category-select:focus {
    color: var(--apw-text-color) !important;
    background: linear-gradient(215deg, #244B5A 0%, #178093 100%) !important;
    outline: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.apw-solutions-filter {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 15px; /* Space between title and dropdown */
}

/* Select dropdown styling - moved from JS */
.apw-solutions-category-select {
    height: 100px; /* Fixed height */
    padding: 0 50px 0 25px; /* Adjusted padding with more space on right for caret */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: linear-gradient(215deg, #244B5A 0%, #178093 100%) 0% 0% no-repeat padding-box;
    color: var(--apw-text-color);
    border: none;
    border-radius: 58px; /* Exact border radius */
    font-family: 'Montserrat', var(--apw-font-family);
    font-size: var(--apw-title-size);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    margin: 0;
    text-align: center; /* Center text */
    cursor: pointer;
    min-width: 170px; /* Ensure enough space for text */
    display: inline-block;
    width: auto;
    max-width: none !important;
}

/* Font Awesome caret styling - with correct positioning and size from JS */
.apw-solutions-filter .fa-caret-down {
    color: var(--apw-caret-color);
    font-size: 30px; /* Proper size as specified in JS */
    position: absolute;
    right: 32px; /* Exact positioning from JS */
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; /* Ensures clicks pass through to select */
    z-index: 1;
}

/* Hover state for select dropdown */
.apw-solutions-category-select:hover {
    background: linear-gradient(215deg, #1f3f4c 0%, #126b7b 100%) 0% 0% no-repeat padding-box;
}

/* Focus state for select dropdown */
.apw-solutions-category-select:focus {
    outline: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Style dropdown options for better readability */
.apw-solutions-category-select option {
    background-color: #001a25 !important; /* Much darker background for better contrast */
    color: white !important; /* Force white text */
    padding: 10px; /* Add some padding for better appearance */
    font-size: 18px; /* Slightly smaller than the main dropdown */
}

/* Additional styling for dropdown menu */
select.apw-solutions-category-select {
    background-color: #001a25 !important; /* Dark background for the dropdown */
}

/* Target the dropdown menu in different browsers */
select.apw-solutions-category-select::-webkit-listbox {
    background-color: #001a25 !important;
}

select.apw-solutions-category-select::-moz-list {
    background-color: #001a25 !important;
}

/* Target Firefox specifically */
@supports (-moz-appearance:none) {
    select.apw-solutions-category-select {
        background-color: #001a25 !important;
    }
    select.apw-solutions-category-select option {
        background-color: #001a25 !important;
    }
}

/* Target Webkit browsers */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    select.apw-solutions-category-select option {
        background-color: #001a25 !important;
    }
}

/* Hide native dropdown arrow in IE */
.apw-solutions-category-select::-ms-expand {
    display: none;
}

/* Font Awesome caret styling */
.apw-solutions-filter .fa-caret-down {
    color: var(--apw-caret-color);
    font-size: 30px;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none; /* Ensures clicks pass through to select */
    z-index: 1;
}

/* ----------------------------------------
   4. GRID LAYOUT
   ---------------------------------------- */
.apw-solutions-grid {
    position: relative;
    transition: opacity 0.3s ease;
    padding: 0px 15px;
}

.apw-solutions-grid.loading {
    opacity: 0.5;
    pointer-events: none;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
    justify-content: center; /* Center cards */
}

.col-md-4 {
    width: 33.33%;
    padding: 10px 15px;
    margin-bottom: var(--apw-spacing-lg);
    display: flex;
    justify-content: center; /* Center card in column */
}

/* ----------------------------------------
   5. SOLUTION CARD STYLING
   ---------------------------------------- */
.apw-solution-card {
    background-color: var(--apw-card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: var(--apw-card-width);
    height: var(--apw-card-height);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.apw-solution-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    background-color: var(--apw-hover-color);
}

.apw-solution-category {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(215deg, #244B5A 0%, #178093 100%) 0% 0% no-repeat padding-box;
    color: var(--apw-text-color);
    border-radius: 58px;
    font: normal normal bold 14px/24px var(--apw-font-family);
    letter-spacing: 0px;
    margin: var(--apw-spacing-md) auto;
    text-transform: capitalize;
    text-align: center;
    /* Center category label */
    align-self: center;
}

/* Fix for Flatsome theme width interference with solution titles */
.apw-solution-card .apw-solution-title {
    font: normal normal bold var(--apw-text-size)/var(--apw-button-line-height) var(--apw-font-family);
    margin: 0 var(--apw-spacing-md) var(--apw-spacing-md);
    color: var(--apw-text-color) !important;
    text-align: center; /* Center title */
    width: auto !important; /* Override Flatsome's 100% width */
    max-width: none !important; /* Ensure Flatsome doesn't constrain width */
    display: block;
    font-size: 30px;
}

.apw-solution-excerpt {
    padding: var(--apw-spacing-md);
    margin: 0;
    background-color: var(--apw-content-bg);
    font: normal normal medium var(--apw-text-size)/var(--apw-description-line-height) var(--apw-font-family);
    color: var(--apw-dark-text);
    text-align: center; /* Center description */
    /* Reduced space after description */
    flex: 0 0 auto;
    font-size: 21px;
}

.apw-solution-image {
    width: 100%; /* Full width */
    height: auto; /* Changed from fixed height to auto */
    overflow: hidden;
    margin: 0; /* Remove margins */
    /* Fix image to be flush with container */
    display: block;
    /* Push the link to bottom */
    margin-top: auto;
}

.apw-solution-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Remove any borders */
    border: none;
    border-radius: 0;
    vertical-align: bottom; /* Removes any gap below image */
}

.apw-solution-link {
    display: block;
    width: 100%;
    padding: var(--apw-spacing-md);
    background-color: #fff; /* White background as specified */
    font: normal normal bold var(--apw-text-size)/var(--apw-button-line-height) var(--apw-font-family);
    letter-spacing: 0px;
    color: var(--apw-link-color);
    text-align: center;
    /* Remove margin-top as image now pushes it to bottom */
    margin-top: 0;
    /* Ensure no space between image and link */
    line-height: 1;
}

/* Fix card layout to ensure image is at bottom followed immediately by link */
.apw-solution-card {
    display: flex;
    flex-direction: column;
}

.apw-solution-card > * {
    flex-shrink: 0;
}

.apw-solution-card > .apw-solution-excerpt {
    flex-grow: 1;
}

/* ----------------------------------------
   6. LOADING AND ERROR STATES
   ---------------------------------------- */
.apw-solutions-error,
.apw-solutions-empty {
    padding: var(--apw-spacing-md);
    background-color: var(--apw-hover-color);
    border-radius: 5px;
    text-align: center;
    color: var(--apw-text-color);
}

.apw-solutions-grid.loading:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--apw-tertiary-bg);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ----------------------------------------
   7. UTILITY CLASSES
   ---------------------------------------- */
.apw-hidden {
    display: none;
}

.apw-text-center {
    text-align: center;
}

.apw-mb-sm {
    margin-bottom: var(--apw-spacing-sm);
}

.apw-mb-md {
    margin-bottom: var(--apw-spacing-md);
}

.apw-mb-lg {
    margin-bottom: var(--apw-spacing-lg);
}

/* ----------------------------------------
   8. RESPONSIVE STYLES
   ---------------------------------------- */
/* Desktop (850px and above) - Default styles above apply */

/* Tablet (550px to 849px) */
@media screen and (max-width: 849px) {
    :root {
        --apw-title-size: 40px;
        --apw-dropdown-size: 22px;
        --apw-text-size: 18px;
    }

    .apw-solutions-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        padding: var(--apw-spacing-sm);
        justify-content: center;
        padding-top: 50px
    }

    .col-md-4 {
        width: 50%; /* 2 columns on tablet */
    }

    .apw-solution-card {
        max-width: 90%;
        min-height: 500px;
    }

    .apw-solutions-container .apw-solutions-title,
    .apw-solutions-category-container .apw-solutions-title {
        font-size: 30px;
    }

    .apw-solutions-category-select {
        height: fit-content;
        font-size: 30px;
        padding: 0 30px 0 30px;
    }

    .apw-solutions-filter .fa-caret-down {
        right: 10px;
        font-size: 24px;
    }

    .apw-solution-image {
        height: auto;
        max-height: 220px;
    }
}

/* Mobile (549px and below) */
@media screen and (max-width: 549px) {
    :root {
        --apw-title-size: 32px;
        --apw-dropdown-size: 18px;
        --apw-text-size: 16px;
    }

    .apw-solutions-header {
        flex-direction: column;
        gap: 15px;
    }

    .apw-solutions-filter {
        margin-left: 0;
    }

    .col-md-4 {
        width: 90%; /* 1 column on mobile */
    }

    .apw-solution-card {
        min-height: 450px;
    }

    .apw-solution-category {
        padding: 6px 15px;
        font-size: 12px;
    }

    .apw-solution-image {
        height: auto;
        max-height: 180px;
    }
}
