/**
 * Mad Meet The Team Widget Styles
 * Interactive dual-panel employee profile widget with customizable backgrounds and angled arrow design
 */

/* Main Widget Container */
.mad-meet-the-team-widget {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr; /* Equal panels by default */
    height: auto;
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

/* Featured Panel (Left Side) */
.mad-featured-panel {
    position: relative;
    padding: 30px;
    padding-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    color: white;
    overflow: hidden;
    min-height: 280px;
    
    /* Create the angled arrow pointing right */
    clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 50%, calc(100% - 30px) 100%, 0 100%);
    z-index: 2;
}

/* Logo Container */
.mad-logo-container {
    position: absolute;
    top: 30px;
    left: 30px;
    z-index: 5;
}

.mad-logo-icon,
.mad-logo-image {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.mad-logo-icon i,
.mad-logo-icon svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mad-logo-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}

/* Featured Content Container */
.mad-featured-content {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    transition: all 0.3s ease;
    margin-right: 50px; /* Account for angled edge */
}

.mad-featured-content.mad-updating {
    opacity: 0.7;
    transform: translateY(10px);
}

/* Featured Photo */
.mad-featured-photo {
    position: relative;
    width: var(--featured-photo-size, 200px);
    height: var(--featured-photo-size, 200px);
    margin-bottom: 20px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: var(--border-radius, 50%);
}

.mad-featured-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border: var(--border-width, 4px) solid var(--border-color, #ffffff);
    border-radius: var(--border-radius, 50%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    aspect-ratio: 1 / 1;
    display: block;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* Featured Employee Info */
.mad-featured-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.mad-featured-name {
    font-weight: bold;
    line-height: 1.2;
    margin: 0;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
}

.mad-featured-titles {
    font-style: italic;
    line-height: 1.3;
    margin: 0;
    opacity: 0.9;
}

.mad-featured-bio {
    line-height: 1.6;
    max-width: 100%;
    margin: 0;
}

.mad-featured-bio p {
    margin: 0 0 15px 0;
}

.mad-featured-bio p:last-child {
    margin-bottom: 0;
}

/* Grid Panel (Right Side) */
.mad-grid-panel {
    position: relative;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    z-index: 1;
    margin-left: -30px; /* Overlap with angled edge */
    padding-left: 60px; /* Extra padding to account for overlap */
    min-height: 280px;
}

/* Grid Title */
.mad-grid-title {
    font-weight: bold;
    line-height: 1.2;
    margin: 0 0 35px 0;
    width: 100%;
    text-align: center;
}

/* Employee Grid Container - Dynamic based on count and max per row */
.mad-employees-grid {
    width: 100%;
    display: grid;
    column-gap: var(--card-spacing, 20px);
    row-gap: var(--row-gap, 30px);
    justify-items: center;
    align-items: start;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

/* Individual Employee Grid Items */
.mad-employee-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    padding: 15px 12px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid transparent;
    outline: none;
    position: relative;
    text-align: center;
    box-sizing: border-box;
    width: 100%;
}

.mad-employee-grid-item:hover,
.mad-employee-grid-item.mad-hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.mad-employee-grid-item.mad-active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.mad-employee-grid-item.mad-focus {
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
    z-index: 1;
}

/* Employee Photos in Grid - Use CSS Variables */
.mad-employee-photo {
    position: relative;
    flex-shrink: 0;
    min-width: var(--grid-photo-size, 80px);
    width: var(--grid-photo-size, 80px);
    height: var(--grid-photo-size, 80px);
    overflow: hidden;
    border-radius: var(--border-radius, 50%);
    box-sizing: border-box;
}

.mad-employee-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border: var(--border-width, 4px) solid var(--border-color, #ffffff);
    border-radius: var(--border-radius, 50%);
    display: block;
    box-sizing: border-box;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
}

/* Employee Info Container */
/* Photo Placeholder Styling */
.mad-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius, 50%);
    border: var(--border-width, 4px) solid var(--border-color, #ffffff);
    font-size: calc(var(--featured-photo-size, 200px) * 0.3);
    color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.mad-employee-photo .mad-photo-placeholder {
    font-size: calc(var(--grid-photo-size, 80px) * 0.4);
}

.mad-employee-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
    width: 100%;
}

/* Employee Names in Grid */
.mad-employee-name {
    font-size: 14px;
    font-weight: 600;
    color: inherit;
    line-height: 1.3;
    text-align: center;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
}

/* Employee Titles in Grid */
.mad-employee-titles {
    font-size: 12px;
    font-weight: 400;
    font-style: italic;
    color: inherit;
    opacity: 0.8;
    line-height: 1.2;
    text-align: center;
    margin: 0;
    word-wrap: break-word;
    hyphens: auto;
}

/* Dynamic Grid Layout - Uses available space effectively */

/* 1 Employee - Centered single card */
.mad-employees-grid[data-count="1"] {
    grid-template-columns: minmax(150px, 220px);
    justify-content: center;
    max-width: 100%;
    margin: 0 auto;
    row-gap: var(--row-gap, 30px);
}

.mad-employees-grid[data-count="1"] .mad-employee-grid-item {
    padding: 25px 20px;
    min-height: auto;
}

.mad-employees-grid[data-count="1"] .mad-employee-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
}

.mad-employees-grid[data-count="1"] .mad-employee-titles {
    font-size: 13px;
    opacity: 0.8;
}

/* 2 Employees - Two balanced cards */
.mad-employees-grid[data-count="2"] {
    grid-template-columns: repeat(2, minmax(130px, 180px));
    justify-content: center;
    max-width: 100%;
    margin: 0 auto;
    column-gap: 20px;
    row-gap: var(--row-gap, 30px);
}

.mad-employees-grid[data-count="2"] .mad-employee-grid-item {
    padding: 20px 15px;
    min-height: auto;
    max-width: 180px;
}

.mad-employees-grid[data-count="2"] .mad-employee-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 5px;
}

.mad-employees-grid[data-count="2"] .mad-employee-titles {
    font-size: 12px;
    opacity: 0.8;
}

/* 3 Employees - centered with controlled spacing */
.mad-employees-grid[data-count="3"] {
    grid-template-columns: repeat(3, minmax(120px, 180px));
    row-gap: var(--row-gap, 30px);
    justify-content: center;
    max-width: 100%;
}

.mad-employees-grid[data-count="3"] .mad-employee-grid-item {
    padding: 20px 15px;
    min-height: 140px;
    max-width: 180px;
}

.mad-employees-grid[data-count="3"] .mad-employee-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.mad-employees-grid[data-count="3"] .mad-employee-titles {
    font-size: 12px;
    opacity: 0.8;
}

/* 4+ Employees - Respects max-per-row setting */
.mad-employees-grid[data-count="4"],
.mad-employees-grid[data-count="5"],
.mad-employees-grid[data-count="6"],
.mad-employees-grid[data-count="7"],
.mad-employees-grid[data-count="8"],
.mad-employees-grid[data-count="9"],
.mad-employees-grid[data-count="10"] {
    grid-template-columns: repeat(var(--max-per-row, 4), minmax(100px, 160px));
    row-gap: var(--row-gap, 30px);
    justify-content: center;
}

.mad-employees-grid[data-count="4"] .mad-employee-grid-item,
.mad-employees-grid[data-count="5"] .mad-employee-grid-item,
.mad-employees-grid[data-count="6"] .mad-employee-grid-item,
.mad-employees-grid[data-count="7"] .mad-employee-grid-item,
.mad-employees-grid[data-count="8"] .mad-employee-grid-item,
.mad-employees-grid[data-count="9"] .mad-employee-grid-item,
.mad-employees-grid[data-count="10"] .mad-employee-grid-item {
    padding: 15px 10px;
}

.mad-employees-grid[data-count="4"] .mad-employee-name,
.mad-employees-grid[data-count="5"] .mad-employee-name,
.mad-employees-grid[data-count="6"] .mad-employee-name,
.mad-employees-grid[data-count="7"] .mad-employee-name,
.mad-employees-grid[data-count="8"] .mad-employee-name,
.mad-employees-grid[data-count="9"] .mad-employee-name,
.mad-employees-grid[data-count="10"] .mad-employee-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
}

.mad-employees-grid[data-count="4"] .mad-employee-titles,
.mad-employees-grid[data-count="5"] .mad-employee-titles,
.mad-employees-grid[data-count="6"] .mad-employee-titles,
.mad-employees-grid[data-count="7"] .mad-employee-titles,
.mad-employees-grid[data-count="8"] .mad-employee-titles,
.mad-employees-grid[data-count="9"] .mad-employee-titles,
.mad-employees-grid[data-count="10"] .mad-employee-titles {
    font-size: 11px;
    opacity: 0.8;
}

/* Card alignment - let content determine height */
.mad-employee-grid-item {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .mad-meet-the-team-widget {
        grid-template-columns: 1fr 1fr;
    }
    
    .mad-featured-panel {
        clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 50%, calc(100% - 20px) 100%, 0 100%);
    }
    
    .mad-grid-panel {
        margin-left: -20px;
        padding-left: calc(var(--widget-padding, 40px) + 30px);
    }
    
    .mad-featured-content {
        margin-right: 30px;
    }
}

@media (max-width: 768px) {
    .mad-meet-the-team-widget {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .mad-featured-panel {
        clip-path: none; /* Remove angled edge on mobile */
        order: 1;
        min-height: auto; /* Let content determine height */
        padding: 25px 20px;
    }

    .mad-grid-panel {
        margin-left: 0;
        padding-left: 20px;
        padding-right: 20px;
        padding-top: 25px;
        padding-bottom: 25px;
        order: 2;
        border-top: 2px solid rgba(255, 255, 255, 0.2);
    }

    .mad-featured-content {
        margin-right: 0;
        max-width: none;
    }

    /* Override all data-count grid layouts on mobile */
    .mad-employees-grid,
    .mad-employees-grid[data-count="1"],
    .mad-employees-grid[data-count="2"],
    .mad-employees-grid[data-count="3"],
    .mad-employees-grid[data-count="4"],
    .mad-employees-grid[data-count="5"],
    .mad-employees-grid[data-count="6"],
    .mad-employees-grid[data-count="7"],
    .mad-employees-grid[data-count="8"],
    .mad-employees-grid[data-count="9"],
    .mad-employees-grid[data-count="10"] {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        max-width: 100%;
        column-gap: 15px;
        row-gap: 20px;
        padding: 10px 5px;
    }

    /* Reset item constraints on mobile */
    .mad-employees-grid .mad-employee-grid-item {
        max-width: none;
        min-height: auto;
        padding: 15px 12px;
    }

    .mad-logo-container {
        position: relative;
        top: auto;
        left: auto;
        margin-bottom: 15px;
    }

    .mad-featured-photo {
        width: min(calc(var(--featured-photo-size, 200px) * 0.7), 140px);
        height: min(calc(var(--featured-photo-size, 200px) * 0.7), 140px);
        margin-bottom: 15px;
    }

    .mad-employee-photo {
        width: 70px;
        height: 70px;
        min-width: 60px;
        min-height: 60px;
    }

    .mad-employee-name {
        font-size: 13px;
    }

    .mad-employee-titles {
        font-size: 11px;
    }

    .mad-grid-title {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .mad-featured-name {
        font-size: 22px !important;
    }

    .mad-featured-titles {
        font-size: 14px !important;
    }

    .mad-featured-bio {
        font-size: 14px !important;
        line-height: 1.5;
    }
}

/* Tablet portrait - between phone and tablet landscape */
@media (max-width: 600px) {
    .mad-employees-grid,
    .mad-employees-grid[data-count="1"],
    .mad-employees-grid[data-count="2"],
    .mad-employees-grid[data-count="3"],
    .mad-employees-grid[data-count="4"],
    .mad-employees-grid[data-count="5"],
    .mad-employees-grid[data-count="6"],
    .mad-employees-grid[data-count="7"],
    .mad-employees-grid[data-count="8"],
    .mad-employees-grid[data-count="9"],
    .mad-employees-grid[data-count="10"] {
        grid-template-columns: repeat(2, 1fr);
        column-gap: 12px;
        row-gap: 18px;
    }

    .mad-employee-photo {
        width: 65px;
        height: 65px;
    }

    .mad-grid-title {
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .mad-meet-the-team-widget {
        margin: 10px 0;
        border-radius: 12px;
    }

    .mad-featured-panel {
        padding: 20px 15px;
    }

    .mad-grid-panel {
        padding: 20px 15px;
    }

    /* Smart grid: 1 column for 1-2 people, 2 columns for 3+ */
    .mad-employees-grid,
    .mad-employees-grid[data-count="3"],
    .mad-employees-grid[data-count="4"],
    .mad-employees-grid[data-count="5"],
    .mad-employees-grid[data-count="6"],
    .mad-employees-grid[data-count="7"],
    .mad-employees-grid[data-count="8"],
    .mad-employees-grid[data-count="9"],
    .mad-employees-grid[data-count="10"] {
        grid-template-columns: repeat(2, 1fr);
        column-gap: 12px;
        row-gap: 15px;
        padding: 5px 0;
    }

    /* Single column for 1-2 people on small phones */
    .mad-employees-grid[data-count="1"],
    .mad-employees-grid[data-count="2"] {
        grid-template-columns: 1fr;
        max-width: 200px;
        margin: 0 auto;
    }

    .mad-featured-photo {
        width: 110px;
        height: 110px;
        margin-bottom: 12px;
    }

    .mad-employee-photo {
        width: 60px;
        height: 60px;
        min-width: 55px;
        min-height: 55px;
    }

    .mad-featured-info {
        gap: 8px;
    }

    .mad-employees-grid .mad-employee-grid-item {
        padding: 12px 10px;
        gap: 8px;
        min-height: auto;
    }

    .mad-employee-name {
        font-size: 12px;
        line-height: 1.3;
    }

    .mad-employee-titles {
        font-size: 10px;
    }

    .mad-grid-title {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .mad-featured-name {
        font-size: 20px !important;
    }

    .mad-featured-titles {
        font-size: 13px !important;
    }

    .mad-featured-bio {
        font-size: 13px !important;
    }
}

/* Animation Support */
.mad-logo-icon[data-animate],
.mad-logo-image[data-animate] {
    animation-duration: var(--animation-duration, 1s);
    animation-delay: var(--animation-delay, 0s);
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mad-featured-photo img,
    .mad-employee-photo img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    .mad-meet-the-team-widget {
        grid-template-columns: 1fr;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .mad-featured-panel {
        clip-path: none;
        background: #f5f5f5 !important;
        color: #000 !important;
    }
    
    .mad-grid-panel {
        margin-left: 0;
        padding-left: var(--widget-padding, 40px);
        border-top: 1px solid #ccc;
    }
    
    .mad-employee-grid-item {
        background: none !important;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    .mad-employee-grid-item:hover,
    .mad-employee-grid-item.mad-hover,
    .mad-employee-grid-item.mad-active {
        transform: none;
        box-shadow: none;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .mad-employee-grid-item,
    .mad-featured-content,
    .mad-featured-photo img,
    .mad-employee-photo img,
    .mad-logo-icon,
    .mad-logo-image {
        transition: none;
    }
    
    .mad-employee-grid-item:hover,
    .mad-employee-grid-item.mad-hover {
        transform: none;
    }
    
    .mad-employee-grid-item.mad-active {
        transform: scale(1.02);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .mad-meet-the-team-widget {
        box-shadow: 0 8px 32px rgba(255, 255, 255, 0.1);
    }
}

/* Container Context Support */
.panel-grid-cell .mad-meet-the-team-widget,
.so-panel .mad-meet-the-team-widget {
    margin: 20px auto;
}

/* Elementor Context */
.elementor-widget-container .mad-meet-the-team-widget {
    margin: 0;
}

/* No Employees Fallback */
.mad-no-employees {
    padding: 60px 40px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 18px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Loading State */
.mad-meet-the-team-widget.mad-loading {
    opacity: 0.7;
    pointer-events: none;
}

.mad-meet-the-team-widget.mad-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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