/* ==========================================================================
   Perth Framework - Combined Widget Styles
   Version: 1.0.0
   ========================================================================== */

/* ==========================================================================
   1. Blog Posts Widget
   ========================================================================== */

.perth-blog-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
}

.perth-blog-heading h2 {
    font-family: "Lora", serif;
    color: #272A2F;
    font-size: 32px;
    font-weight: 500;
    line-height: normal;
    text-transform: capitalize;
    margin: 0;
}

.perth-blog-heading a {
    color: #0067A2;
    text-align: right;
    font-size: 16px;
    font-weight: 400;
    line-height: normal;
    border-radius: 4px;
    border: 1px solid #0067A2;
    text-decoration: none;
    font-family: "Helvetica", sans-serif;
    padding: 6px 22px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.perth-blog-heading a:hover {
    background: #0067A2;
    color: #fff;
}

.perth-blog-heading a:hover svg path {
    stroke: #fff;
}

.perth-blog-heading a svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.perth-blog-cards {
    display: flex;
    gap: 30px;
}

.perth-blog-card {
    position: relative;
    flex: 1;
    min-width: 0;
}

.perth-blog-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.perth-blog-card-img img {
    border-radius: 10px;
    width: 100%;
    display: block;
}

.perth-blog-date {
    color: #6C6E71;
    font-family: "Helvetica", sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: normal;
    margin-top: 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.perth-blog-date svg {
    width: 16px;
    height: 18px;
    flex-shrink: 0;
}

.perth-blog-card h3 {
    color: #272A2F;
    font-family: "Helvetica", sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 27px;
    margin: 0 0 10px;
}

.perth-blog-card p {
    color: #272A2F;
    font-family: "Helvetica", sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 26.4px;
    margin: 0 0 10px;
}

.perth-blog-read-more {
    color: #0067A2;
    font-family: "Helvetica", sans-serif;
    font-size: 16px;
    font-weight: 600;
    display: inline-block;
    margin-top: 5px;
    transition: color 0.2s;
}

.perth-blog-read-more:hover {
    color: #004d7a;
}

/* ==========================================================================
   2. Mega Menu Widget
   ========================================================================== */

/* ---------- Wrapper ---------- */
.perth-mega-menu-wrapper {
    position: relative;
}

/* ---------- Mega Menu Content (bwp_megamenu post type) ---------- */
.perth-megamenu-content {
    width: 100%;
}

.perth-megamenu-content > * {
    max-width: 100%;
}

/* ---------- WordPress Menu Styles ---------- */
.perth-menu-container {
    position: relative;
}

.perth-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

/* Horizontal Layout */
.perth-menu.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
}

.perth-menu.horizontal .perth-menu-item {
    margin-right: 20px;
}

.perth-menu.horizontal .perth-menu-item:last-child {
    margin-right: 0;
}

/* Vertical Layout */
.perth-menu.vertical {
    flex-direction: column;
}

.perth-menu.vertical .perth-menu-item {
    margin-bottom: 10px;
}

.perth-menu.vertical .perth-menu-item:last-child {
    margin-bottom: 0;
}

/* Menu Items */
.perth-menu-item {
    position: relative;
}

.perth-menu-item a {
    display: block;
    padding: 12px 18px;
    text-decoration: none;
    transition: all 0.3s ease;
}

/* Submenu Styles */
.perth-menu .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.perth-menu.vertical .sub-menu {
    position: relative;
    top: 0;
    box-shadow: none;
    padding-left: 20px;
}

.perth-menu-item:hover > .sub-menu {
    display: block;
}

.perth-menu .sub-menu .perth-menu-item {
    margin: 0;
}

.perth-menu .sub-menu a {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.perth-menu .sub-menu .perth-menu-item:last-child a {
    border-bottom: none;
}

/* ---------- Mega Menu Dropdowns ---------- */
/* Target div.sub-menu (mega menu) - not ul.sub-menu (regular submenu) */
/* Generic selectors that work with any theme */
li.mega-menu > div.sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    padding: 30px;
    min-width: 400px;
}

li.mega-menu:hover > div.sub-menu {
    display: block;
}

/* SURGICAL FIX: Override ONLY theme's UL hiding rule, nothing else */
/* Theme rule: .site-navigation ul.menu li ul { display: none; } */
/* Higher specificity beats theme rule */
.site-navigation ul.menu li.mega-menu > div.sub-menu ul {
    display: block !important;
    position: static;
}

/* Ensure visibility for all content */
li.mega-menu > div.sub-menu *,
.perth-menu .mega-menu > div.sub-menu * {
    visibility: visible !important;
    opacity: 1 !important;
}

/* DO NOT force any display values - let Elementor CSS work naturally */
/* Elementor will handle all layout with its own CSS */

/* Full width mega menu */
li.mega-menu-fullwidth > div.sub-menu {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100vw;
    max-width: 100vw;
}

/* Container width mega menu */
li.mega-menu-fw > div.sub-menu {
    min-width: 800px;
    max-width: 1140px;
}

/* Specific selector with .perth-menu for widget usage */
.perth-menu .mega-menu > div.sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    padding: 30px;
    min-width: 400px;
}

.perth-menu .mega-menu:hover > div.sub-menu {
    display: block;
}

.perth-menu .mega-menu-fullwidth > div.sub-menu {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100vw;
    max-width: 100vw;
}

.perth-menu .mega-menu-fw > div.sub-menu {
    min-width: 800px;
    max-width: 1140px;
}

/* ---------- Menu Icons ---------- */
.perth-menu-item a > i {
    margin-right: 8px;
    font-size: 14px;
}

/* ---------- Menu Badges ---------- */
.new-badge,
.sale-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 3px;
    margin-left: 6px;
    text-transform: uppercase;
    vertical-align: middle;
}

.new-badge {
    background: #4CAF50;
    color: #ffffff;
}

.sale-badge {
    background: #FF5722;
    color: #ffffff;
}

/* ---------- Visibility States ---------- */
/* Hide logged-in-only items when logged out */
body:not(.logged-in) .menu-item-loggedin {
    display: none !important;
}

/* Hide logged-out-only items when logged in */
body.logged-in .menu-item-loggedout {
    display: none !important;
}

/* ---------- Mobile Toggle Button ---------- */
.perth-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid #ddd;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.perth-menu-toggle:hover {
    background: #f5f5f5;
}

.perth-menu-toggle-icon {
    display: block;
}

/* ---------- Current Menu Item ---------- */
.perth-menu-item.current-menu-item > a,
.perth-menu-item.current-menu-parent > a,
.perth-menu-item.current-menu-ancestor > a {
    font-weight: 600;
}

/* ---------- Menu Item with Children Arrow ---------- */
.perth-menu-item.menu-item-has-children > a::after {
    content: '▾';
    margin-left: 8px;
    font-size: 0.8em;
    opacity: 0.7;
}

.perth-menu.vertical .perth-menu-item.menu-item-has-children > a::after {
    float: right;
}

/* ---------- Accessibility ---------- */
.perth-menu a:focus {
    outline: 2px solid #0067A2;
    outline-offset: 2px;
}

/* ---------- RTL Support ---------- */
[dir="rtl"] .perth-menu.horizontal .perth-menu-item {
    margin-left: 20px;
    margin-right: 0;
}

[dir="rtl"] .perth-menu .sub-menu {
    left: auto;
    right: 0;
}

[dir="rtl"] .perth-menu.vertical .sub-menu {
    padding-left: 0;
    padding-right: 20px;
}

[dir="rtl"] .perth-menu-item.menu-item-has-children > a::after {
    margin-left: 0;
    margin-right: 8px;
}

/* ==========================================================================
   3. Post Listing Widget
   ========================================================================== */

.perth-post-listing {
    width: 100%;
    max-width: 100%;
}

.perth-post-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.perth-post-item {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    transition: all 0.3s ease;
}

.perth-post-item:last-child {
    margin-bottom: 0 !important;
}

.perth-post-image {
    flex-shrink: 0;
}

.perth-post-image a {
    display: block;
    line-height: 0;
}

.perth-post-image img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.perth-post-image a:hover img {
    transform: scale(1.05);
    opacity: 0.9;
}

.perth-post-details {
    flex: 1;
    min-width: 0;
}

.perth-post-title {
    margin: 0 0 10px;
    padding: 0;
    line-height: 1.4;
}

.perth-post-title a {
    text-decoration: none;
    transition: color 0.3s ease;
}

.perth-post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 15px;
    font-size: 14px;
    margin: 0 0 10px;
}

.perth-post-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.perth-post-meta a {
    text-decoration: none;
    transition: color 0.3s ease;
}

.perth-post-content {
    margin: 0 0 15px;
    line-height: 1.6;
}

.perth-read-more {
    display: inline-block;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
}

.perth-read-more:hover {
    text-decoration: none;
    transform: translateX(5px);
}

/* Pagination Styles */
.perth-pagination {
    margin-top: 30px;
    padding-top: 20px;
}

.perth-pagination a,
.perth-pagination span {
    display: inline-block;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 8px 12px;
    border-radius: 4px;
    min-width: 40px;
    text-align: center;
}

.perth-pagination a:hover {
    text-decoration: none;
}

.perth-pagination span.current {
    font-weight: 600;
}

.perth-pagination .prev,
.perth-pagination .next {
    font-weight: 500;
}

.perth-pagination .dots {
    border: none;
    background: transparent !important;
    cursor: default;
}

/* No Posts Message */
.perth-no-posts {
    text-align: center;
    padding: 40px 20px;
    color: #6C6E71;
    font-size: 16px;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Blog Posts Widget - Mobile */
@media (max-width: 991px) {
    .perth-blog-cards {
        flex-direction: column;
    }

    .perth-blog-heading h2 {
        font-size: 22px;
    }

    .perth-blog-heading a {
        padding: 6px 15px;
    }

    .perth-blog-card h3 {
        font-size: 18px;
    }
}

/* Mega Menu Widget - Mobile */
@media (max-width: 768px) {
    .perth-menu-toggle {
        display: inline-block;
        margin-bottom: 15px;
    }

    .perth-menu.mobile-collapsible {
        display: none;
        flex-direction: column;
    }

    .perth-menu.mobile-collapsible.active {
        display: flex;
    }

    .perth-menu.horizontal.mobile-collapsible {
        flex-direction: column;
    }

    .perth-menu.horizontal.mobile-collapsible .perth-menu-item {
        margin-right: 0;
        margin-bottom: 5px;
        width: 100%;
    }

    .perth-menu.mobile-collapsible .perth-menu-item a {
        padding: 12px 15px;
        border-bottom: 1px solid #f0f0f0;
    }

    .perth-menu.mobile-collapsible .sub-menu {
        position: relative;
        top: 0;
        box-shadow: none;
        padding-left: 20px;
        background: #f9f9f9;
    }

    .perth-menu.mobile-collapsible .sub-menu a {
        padding: 10px 15px;
    }

    /* Mega menu on mobile */
    .perth-menu .mega-menu-dropdown {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        margin-left: 0 !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-shadow: none;
        background: #f9f9f9;
    }

    .mega-menu-content-wrapper {
        padding: 15px;
    }

    /* Mobile responsive mega menu styles */
    li.mega-menu > div.sub-menu,
    .perth-menu .mega-menu > div.sub-menu {
        position: relative !important;
        left: 0 !important;
        right: auto !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        transform: none !important;
        padding: 15px !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    /* Full width on mobile should be 100% of screen */
    li.mega-menu-fullwidth > div.sub-menu,
    li.mega-menu-fw > div.sub-menu {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        left: 0 !important;
        transform: none !important;
    }

    /* Ensure Elementor sections stack on mobile */
    li.mega-menu > div.sub-menu .elementor-section,
    li.mega-menu > div.sub-menu .elementor-container,
    .perth-menu .mega-menu > div.sub-menu .elementor-section,
    .perth-menu .mega-menu > div.sub-menu .elementor-container {
        flex-direction: column !important;
    }

    li.mega-menu > div.sub-menu .elementor-column,
    .perth-menu .mega-menu > div.sub-menu .elementor-column {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Make mega menu content readable on mobile */
    li.mega-menu > div.sub-menu,
    .perth-menu .mega-menu > div.sub-menu {
        font-size: 14px !important;
    }

    li.mega-menu > div.sub-menu img,
    .perth-menu .mega-menu > div.sub-menu img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Post Listing Widget - Mobile */
    .perth-post-item {
        flex-direction: column;
        gap: 15px;
    }

    .perth-post-image {
        width: 100%;
    }

    .perth-post-meta {
        font-size: 13px;
        gap: 5px 10px;
    }

    .perth-pagination a,
    .perth-pagination span {
        padding: 6px 10px;
        font-size: 14px;
        min-width: 35px;
    }
}

/* Post Listing Widget - Small Mobile */
@media (max-width: 480px) {
    .perth-post-title {
        font-size: 18px;
    }

    .perth-post-meta {
        font-size: 12px;
    }

    .perth-post-content {
        font-size: 14px;
    }
}

/* Mega Menu Widget - Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Adjust mega menu width on tablets */
    li.mega-menu-fw > div.sub-menu,
    .perth-menu .mega-menu-fw > div.sub-menu {
        min-width: 600px !important;
        max-width: 90vw !important;
    }

    /* Ensure full width mega menus work on tablets */
    li.mega-menu-fullwidth > div.sub-menu,
    .perth-menu .mega-menu-fullwidth > div.sub-menu {
        width: 95vw !important;
        max-width: 95vw !important;
    }

    /* Reduce padding on tablets */
    li.mega-menu > div.sub-menu,
    .perth-menu .mega-menu > div.sub-menu {
        padding: 20px !important;
    }
}
