/* TTM Team Grid & Popup Styles */
.ttm-team-popup-wrapper {
    position: relative;
    width: 100%;
}

.ttm-team-grid {
    display: grid;
    gap: 30px;
    margin-bottom: 30px;
}

.ttm-team-card {
    background: #ffffff;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Creative Accent Layout (Director Style) */
.ttm-team-layout-creative .ttm-team-card {
    padding: 0 !important;
    background: transparent;
    border: none;
    overflow: visible;
    /* Important for the pop-out effect */
    height: 450px;
    /* Fixed height for consistency in this special style */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.ttm-team-layout-creative .ttm-team-image-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    margin-bottom: 0;
    overflow: visible;
    aspect-ratio: auto !important;
}

.ttm-team-layout-creative .ttm-team-accent-bg {
    position: absolute;
    top: 20px;
    right: 0;
    width: 85%;
    height: 95%;
    background-color: #ef4444;
    /* Default accent - can be changed via Elementor */
    border-radius: 100px 0 0 0;
    z-index: 1;
    overflow: hidden;
}

.ttm-team-layout-creative .ttm-team-accent-text {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%) rotate(-90deg);
    font-size: 60px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.15);
    text-transform: uppercase;
    white-space: nowrap;
    letter-spacing: 5px;
    pointer-events: none;
    transform-origin: center;
}

.ttm-team-layout-creative .ttm-team-image-wrap img {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: auto;
    max-height: 110%;
    object-fit: contain;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.3));
    z-index: 3;
    transition: all 0.5s ease;
}

.ttm-team-layout-creative .ttm-team-card:hover .ttm-team-image-wrap img {
    transform: translateX(-50%) translateY(-10px) scale(1.05);
}

.ttm-team-layout-creative .ttm-team-content {
    position: relative;
    z-index: 4;
    padding: 30px 20px;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    border-radius: 0 0 0 0;
}

.ttm-team-layout-creative .ttm-team-name {
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ttm-team-layout-creative .ttm-team-designation {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Grid Layout Helper */
.ttm-team-grid {
    display: grid;
    gap: 30px;
}

/* Highlight First Card Logic (4-Unit Grid System) */
@media (min-width: 1025px) {
    .ttm-highlight-first-yes .ttm-team-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        grid-auto-rows: 1fr;
    }

    .ttm-highlight-first-yes .ttm-team-grid>div:first-child {
        grid-column: span 2;
        grid-row: span 1;
    }

    /* Side-by-side horizontal layout ONLY for non-overlay layouts */
    .ttm-highlight-first-yes:not(.ttm-team-layout-overlay) .ttm-team-grid>div:first-child .ttm-team-card {
        flex-direction: row !important;
        height: 100%;
        text-align: left !important;
        align-items: center;
        padding: 0 !important;
        overflow: hidden;
    }

    .ttm-highlight-first-yes:not(.ttm-team-layout-overlay) .ttm-team-grid>div:first-child .ttm-team-image-wrap {
        width: 45% !important;
        height: 100% !important;
        margin-bottom: 0 !important;
        aspect-ratio: auto !important;
        position: relative;
        overflow: hidden;
    }

    .ttm-highlight-first-yes:not(.ttm-team-layout-overlay) .ttm-team-grid>div:first-child .ttm-team-image-wrap img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .ttm-highlight-first-yes:not(.ttm-team-layout-overlay) .ttm-team-grid>div:first-child .ttm-team-content {
        width: 55% !important;
        padding: 40px !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* SPECIFIC FIX FOR OVERLAY LAYOUT IN HIGHLIGHT MODE - FULL BACKGROUND COVER */
    .ttm-team-layout-overlay.ttm-highlight-first-yes .ttm-team-grid>div:first-child .ttm-team-card {
        flex-direction: column;
        /* Back to stacked for full-bleed image */
        position: relative;
        display: block !important;
        height: 100%;
        padding: 0 !important;
    }

    .ttm-team-layout-overlay.ttm-highlight-first-yes .ttm-team-grid>div:first-child .ttm-team-image-wrap {
        position: absolute;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        z-index: 1;
        overflow: hidden;
    }

    .ttm-team-layout-overlay.ttm-highlight-first-yes .ttm-team-grid>div:first-child .ttm-team-image-wrap img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .ttm-team-layout-overlay.ttm-highlight-first-yes .ttm-team-grid>div:first-child .ttm-team-content {
        position: relative;
        z-index: 2;
        width: 100% !important;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: flex-start;
        padding: 30px !important;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%) !important;
    }

    /* Styling shared for MD */
    .ttm-team-layout-overlay.ttm-highlight-first-yes .ttm-team-grid>div:first-child .ttm-team-name {
        font-size: 22px !important;
        color: #ffffff;
        margin-bottom: 5px;
    }
}

@media (max-width: 1024px) {
    .ttm-highlight-first-yes .ttm-team-grid>div:first-child {
        grid-column: span 1;
        grid-row: span 1;
    }
}

@media (max-width: 1024px) {
    .ttm-highlight-first-yes .ttm-team-grid>div:first-child {
        grid-column: span 1;
        grid-row: span 1;
    }
}

/* Standard Circle Layout */
.ttm-team-layout-circle .ttm-team-card {
    padding: 30px 20px;
    align-items: center;
}

.ttm-team-layout-circle .ttm-team-image-wrap {
    width: 120px;
    aspect-ratio: 1/1;
    /* Default for circle */
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 25px;
    background: #f3f4f6;
    border: 4px solid #f1f5f9;
    transition: all 0.3s ease;
}

/* Overlay Layout */
.ttm-team-layout-overlay .ttm-team-card {
    padding: 0 !important;
    justify-content: flex-end;
}

.ttm-team-layout-overlay .ttm-team-image-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    margin-bottom: 0;
    border-radius: 0;
    aspect-ratio: auto !important;
    /* Ignore aspect for full cover */
}

.ttm-team-layout-overlay .ttm-team-overlay-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
    z-index: 2;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.ttm-team-layout-overlay .ttm-team-card:hover .ttm-team-overlay-bg {
    opacity: 1;
}

.ttm-team-layout-overlay .ttm-team-content {
    position: relative;
    z-index: 3;
    padding: 30px 20px;
    text-align: left;
    width: 100%;
}

.ttm-team-layout-overlay .ttm-team-name {
    color: #ffffff;
    font-size: 20px;
}

.ttm-team-layout-overlay .ttm-team-designation {
    color: rgba(255, 255, 255, 0.8);
}

/* Modern Layout (Image Top) */
.ttm-team-layout-modern .ttm-team-card {
    padding: 0;
    text-align: left;
    align-items: flex-start;
    background: #ffffff;
    border-bottom: 4px solid #1a73e8;
    /* Default accent color */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.ttm-team-layout-modern .ttm-team-image-wrap {
    width: 100%;
    aspect-ratio: 4/5;
    /* Default ratio for Modern */
    border-radius: 0;
    /* Handled by card overflow */
    margin-bottom: 0;
    border: none;
    position: relative;
    background: #f8fafc;
}

.ttm-team-layout-modern .ttm-team-image-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.02), transparent 30%);
    pointer-events: none;
}

.ttm-team-layout-modern .ttm-team-content {
    padding: 25px 20px;
    width: 100%;
}

.ttm-team-layout-modern .ttm-team-name {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.ttm-team-layout-modern .ttm-team-designation {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
    text-transform: capitalize;
}

.ttm-team-layout-modern .ttm-team-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.ttm-team-layout-modern .ttm-team-card:hover .ttm-team-image-wrap img {
    transform: scale(1.05);
}

/* Shared Hover Effects */
.ttm-team-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.ttm-team-layout-circle .ttm-team-card:hover {
    border-color: #1a73e8;
}

.ttm-team-layout-circle .ttm-team-card:hover .ttm-team-image-wrap {
    border-color: #1a73e8;
    transform: scale(1.05);
}

.ttm-team-image-wrap img {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ttm-team-card:hover .ttm-team-image-wrap img {
    transform: scale(1.1);
}

/* Modal / Popup Styles */
.ttm-team-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 99999;
    /* Higher z-index to stay above everything */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    padding: 20px;
}

.ttm-team-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.ttm-team-modal-container {
    background: #ffffff;
    width: 100%;
    max-width: 900px;
    /* Slightly wider */
    border-radius: 20px;
    position: relative;
    padding: 50px 40px;
    transform: scale(0.9) translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
}

.ttm-team-modal-overlay.open .ttm-team-modal-container {
    transform: scale(1) translateY(0);
}

.ttm-team-modal-close {
    position: absolute;
    top: 25px;
    right: 25px;
    background: #f3f4f6;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #4b5563;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.ttm-team-modal-close:hover {
    background: #ef4444;
    color: #ffffff;
    transform: rotate(90deg);
}

.ttm-team-modal-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    /* Larger image column */
    gap: 50px;
    align-items: start;
}

.ttm-team-modal-image {
    width: 100%;
    aspect-ratio: 4/5;
    /* Portrait ratio for popup image */
    border-radius: 15px;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.ttm-team-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensures filling without distortion */
}

.ttm-modal-name {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 8px 0;
    color: #111827;
    font-family: inherit;
}

.ttm-modal-designation {
    font-size: 16px;
    font-weight: 600;
    color: #1a73e8;
    background: rgba(26, 115, 232, 0.08);
    display: inline-block;
    padding: 5px 15px;
    border-radius: 50px;
    margin-bottom: 25px;
}

.ttm-modal-bio {
    font-size: 16px;
    line-height: 1.7;
    color: #4b5563;
}

.ttm-modal-bio p {
    margin-bottom: 15px;
}

/* Responsive Modal */
@media (max-width: 767px) {
    .ttm-team-modal-layout {
        grid-template-columns: 1fr;
        gap: 25px;
        text-align: center;
    }

    .ttm-team-modal-image {
        margin: 0 auto;
        width: 150px;
        height: 150px;
    }

    .ttm-team-modal-container {
        padding: 40px 20px 30px;
    }

    .ttm-modal-name {
        font-size: 24px;
    }
}