/* Carousel Widget Styles */
.kb-videomate-carousel {
    position: relative;
    margin: 30px 0;
    padding: 0 40px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.kb-videomate-carousel-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.kb-videomate-carousel-inner {
    display: flex;
    transition: transform 0.3s ease;
    gap: 20px;
    padding: 20px 0;
}

/* Portrait Mode Carousel */
.kb-videomate-carousel.portrait-mode .kb-videomate-carousel-inner {
    gap: 15px;
}

.kb-videomate-carousel.portrait-mode .kb-videomate-carousel-item {
    flex: 0 0 calc((95% - 30px) / 3); /* Show 3 portrait videos */
    max-width: calc((100% - 30px) / 3);
}

.kb-videomate-carousel.portrait-mode .kb-videomate-video-wrapper {
    padding-bottom: 177.78%; /* 9:16 aspect ratio */
}

/* Landscape Mode Carousel */
.kb-videomate-carousel.landscape-mode .kb-videomate-carousel-inner {
    gap: 0;
}

.kb-videomate-carousel.landscape-mode .kb-videomate-carousel-item {
    flex: 0 0 100%;
    max-width: 100%;
}

.kb-videomate-carousel.landscape-mode .kb-videomate-video-wrapper {
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.kb-videomate-carousel-item {
    flex: 0 0 calc((100% - (var(--visible-videos, 4) - 1) * 20px) / var(--visible-videos, 4));
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kb-videomate-video-wrapper {
    position: relative;
    overflow: hidden;
    background: #000;
    border-radius: 12px;
    margin: 0;
}

.kb-videomate-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.kb-videomate-video-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 14px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kb-videomate-video-wrapper:hover .kb-videomate-video-title {
    opacity: 1;
}

/* Carousel Navigation */
.kb-videomate-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.3s ease;
}

.kb-videomate-carousel-nav.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.kb-videomate-carousel-prev {
    left: 10px;
}

.kb-videomate-carousel-next {
    right: 10px;
}

.kb-videomate-carousel-nav:hover:not(.disabled) {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.kb-videomate-carousel-nav svg {
    width: 24px;
    height: 24px;
    fill: #333;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .kb-videomate-carousel.portrait-mode .kb-videomate-carousel-item {
        flex: 0 0 calc((95% - 15px) / 2);
        max-width: calc((100% - 15px) / 2);
    }
}

@media (max-width: 768px) {
    .kb-videomate-carousel {
        padding: 0 30px;
        margin: 15px 0;
    }
    
    /* Force single video view in mobile for both portrait and landscape */
    .kb-videomate-carousel.portrait-mode .kb-videomate-carousel-item,
    .kb-videomate-carousel.landscape-mode .kb-videomate-carousel-item {
        flex: 0 0 100%;
        max-width: 100%;
        margin: 0;
    }

    /* Adjust video wrapper for better mobile view */
    .kb-videomate-video-wrapper {
        max-height: 70vh;
        margin: 0 auto;
    }

    .kb-videomate-carousel.portrait-mode .kb-videomate-video-wrapper {
        max-width: 70%;
        margin: 0 auto;
    }
    
    .kb-videomate-carousel-nav {
        width: 30px;
        height: 30px;
        background: rgba(255,255,255,0.95);
    }
    
    .kb-videomate-carousel-nav svg {
        width: 20px;
        height: 20px;
    }

    /* Adjust floating video size for mobile */
    .kb-videomate-floating {
        width: 180px;
        bottom: 30px;
        right: 15px;
    }

    .kb-videomate-floating.left {
        left: 15px;
        right: auto;
    }

    .kb-videomate-floating-body {
        padding-bottom: 177.78%; /* Maintain 9:16 ratio */
        max-height: none;
    }

    /* Ensure floating video is fully visible */
    .kb-videomate-floating video {
        object-fit: contain;
    }
}

/* Additional mobile adjustments for smaller screens */
@media (max-width: 480px) {
    .kb-videomate-carousel {
        padding: 0 25px;
    }

    .kb-videomate-carousel.portrait-mode .kb-videomate-video-wrapper {
        max-width: 85%;
    }

    .kb-videomate-floating {
        width: 160px;
        bottom: 25px;
    }

    .kb-videomate-floating-close {
        width: 26px;
        height: 26px;
    }

    .kb-videomate-floating-close svg {
        width: 16px;
        height: 16px;
    }
}

/* Floating Widget Styles */
.kb-videomate-floating {
    position: fixed;
    z-index: 999999;
    bottom: 20px;
    right: 20px;
    width: 220px;
    background: transparent;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

.kb-videomate-floating.left {
    left: 20px;
    right: auto;
    transform-origin: bottom left;
}

.kb-videomate-floating-body {
    position: relative;
    padding-bottom: 177.78%; /* 9:16 aspect ratio for portrait */
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kb-videomate-floating-body video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kb-videomate-floating-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition: background-color 0.2s ease;
}

.kb-videomate-floating-close:hover {
    background: #fff;
}

.kb-videomate-floating-close svg {
    width: 20px;
    height: 20px;
    fill: #333;
}

/* Minimized State */
.kb-videomate-floating.minimized {
    width: 60px !important;
    height: 60px !important;
    padding: 0;
    border-radius: 50% !important;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.kb-videomate-floating.minimized .kb-videomate-floating-body {
    padding-bottom: 100%;
}

.kb-videomate-floating.minimized .kb-videomate-floating-close {
    display: none;
}

/* Responsive styles */
@media screen and (max-width: 600px) {
    .kb-videomate-floating-widget {
        bottom: 6px !important;
        width: 160px !important;
        height: 290px !important;
        padding: 4px 4px 0 4px;
    }

    .kb-videomate-floating-body {
        width: 140px;
    }

    .kb-videomate-floating-body video {
        width: 140px !important;
        height: 267px !important;
        border-radius: 14px;
    }

    .kb-videomate-floating-close {
        right: 24px;
    }

    /* Handle left position on mobile */
    .kb-videomate-floating-widget[data-position="left"] .kb-videomate-floating-body {
        left: -34px;
        position: relative;
    }

    .kb-videomate-floating-widget.minimized[data-position="left"] {
        left: 6px !important;
        right: auto !important;
    }

    .kb-videomate-floating-widget.minimized[data-position="right"] {
        right: 6px !important;
        left: auto !important;
    }
}

/* Fullscreen modal styles */
.kb-videomate-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.kb-videomate-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}

.kb-videomate-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 2rem;
    color: #333;
    cursor: pointer;
    z-index: 2;
    background: none;
    border: none;
    padding: 5px;
}

.kb-videomate-modal video {
    max-width: 90vw;
    max-height: 90vh;
    display: block;
    margin: 0 auto;
}

/* Video Controls */
.kb-videomate-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.5));
    display: flex;
    align-items: center;
    gap: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kb-videomate-floating-body:hover .kb-videomate-video-controls {
    opacity: 1;
}

/* Control Icons */
.kb-videomate-icon {
    width: 24px;
    height: 24px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.kb-videomate-play-pause,
.kb-videomate-mute-unmute {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.kb-videomate-play-pause:hover,
.kb-videomate-mute-unmute:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* Carousel Widget Styles */
.kb-videomate-carousel-widget {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.kb-videomate-carousel-heading {
    margin: 0 0 20px;
    font-size: 20px;
    color: #333;
    display: none;
}

/* Video Container Styles */
.kb-videomate-video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}

.kb-videomate-video-wrapper video,
.kb-videomate-floating-body video {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Debug Info */
.kb-videomate-debug {
    margin-top: 10px;
    padding: 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.kb-videomate-debug pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Error Message */
.kb-videomate-error {
    padding: 15px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    text-align: center;
    margin: 10px 0;
}

.kb-videomate-error a {
    color: #721c24;
    text-decoration: underline;
    font-weight: bold;
}

.kb-videomate-error a:hover {
    text-decoration: none;
}

/* Video Controls */
video::-webkit-media-controls {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

video::-webkit-media-controls-enclosure {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Animation Classes */
.kb-videomate-floating-widget.kb-videomate-hidden {
    transform: translateY(120%);
}

/* Loading State */
.kb-videomate-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
}

/* Video Controls Customization */
.kb-videomate-carousel video::-webkit-media-controls,
.kb-videomate-float-content video::-webkit-media-controls {
    background-color: rgba(0,0,0,0.7);
}

.kb-videomate-carousel video::-webkit-media-controls-panel,
.kb-videomate-float-content video::-webkit-media-controls-panel {
    padding: 5px;
}

/* Animation Styles */
.kb-videomate-floating.kb-videomate-hidden {
    transform: translateY(100%);
}

/* Loading State */
.kb-videomate-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: kb-videomate-spin 1s linear infinite;
}

@keyframes kb-videomate-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Video Widget Containers */
.kb-videomate-widget {
    margin: 20px 0;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.kb-videomate-widget-heading {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

/* Carousel Widget */
.kb-videomate-carousel {
    position: relative;
    overflow: hidden;
}

.kb-videomate-carousel-inner {
    display: flex;
    transition: transform 0.3s ease;
}

.kb-videomate-carousel-item {
    flex: 0 0 auto;
    padding: 0 10px;
    width: calc(100% / var(--visible-videos, 4));
}

.kb-videomate-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: 16px;
    background: #f0f0f0;
}

.kb-videomate-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Carousel Navigation */
.kb-videomate-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 2;
}

.kb-videomate-carousel-prev {
    left: 10px;
}

.kb-videomate-carousel-next {
    right: 10px;
}

.kb-videomate-carousel-nav:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.kb-videomate-carousel-nav svg {
    width: 20px;
    height: 20px;
    fill: #333;
}

/* Floating Widget */
.kb-videomate-floating {
    position: fixed;
    z-index: 999999;
    max-width: 400px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.kb-videomate-floating.right {
    right: 20px;
    bottom: 20px;
    width: 15%;
    min-width: 80px;
    margin-bottom: 5%;
}

.kb-videomate-floating.left {
    left: 20px;
    bottom: 20px;
    width: 15%;
    min-width: 80px;
    margin-bottom: 5%;
}

.kb-videomate-floating-header {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
}

.kb-videomate-floating-title {
    font-weight: 600;
    font-size: 1.1em;
    color: #333;
}

.kb-videomate-floating-close {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
}

.kb-videomate-floating-close:hover {
    color: #333;
}

.kb-videomate-floating-body {
    position: relative;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}

.kb-videomate-floating-body video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .kb-videomate-carousel {
        padding: 0 25px !important;
    }

    .kb-videomate-carousel-inner {
        gap: 0 !important;
    }

    .kb-videomate-carousel-item {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .kb-videomate-carousel-nav {
        width: 36px !important;
        height: 36px !important;
        background: rgba(255,255,255,0.95) !important;
        z-index: 10 !important;
    }

    .kb-videomate-carousel-prev {
        left: 5px !important;
    }

    .kb-videomate-carousel-next {
        right: 5px !important;
    }

    .kb-videomate-floating {
        width: 45% !important;
        min-width: 150px !important;
        max-width: 200px !important;
        bottom: 20px !important;
        transition: all 0.3s ease !important;
    }

    .kb-videomate-floating.minimized {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        border-radius: 50% !important;
        overflow: hidden !important;
        padding: 0 !important;
    }

    .kb-videomate-floating.minimized .kb-videomate-floating-body {
        padding-bottom: 100% !important;
    }

    .kb-videomate-floating.minimized video {
        object-fit: cover !important;
    }

    .kb-videomate-floating.right {
        right: 10px !important;
        left: auto !important;
    }

    .kb-videomate-floating.left {
        left: 10px !important;
        right: auto !important;
    }

    .kb-videomate-floating-body {
        padding-bottom: 177.78% !important;
        border-radius: 16px !important;
    }

    .kb-videomate-floating-body video {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
}

@media screen and (max-width: 480px) {
    .kb-videomate-carousel-item {
        width: calc(100% / var(--visible-videos-mobile, 1));
    }
    
    .kb-videomate-floating {
        width: 50% !important;
        min-width: 140px !important;
    }
}

/* Ensure video controls are visible */
.kb-videomate-video-wrapper video,
.kb-videomate-floating-body video {
    width: 100%;
    height: auto;
    display: block;
}

.kb-videomate-video-wrapper video::-webkit-media-controls,
.kb-videomate-floating-body video::-webkit-media-controls {
    display: flex !important;
    visibility: visible !important;
}

/* Minimized circular state */
.kb-videomate-floating-widget.minimized {
    width: 80px !important;
    height: 80px !important;
    border-radius: 50% !important;
    overflow: hidden;
    position: fixed; /* Ensure fixed positioning */
    /* Position will be inherited from parent class */
}

.kb-videomate-floating-widget.minimized .kb-videomate-floating-header,
.kb-videomate-floating-widget.minimized .kb-videomate-video-controls {
    display: none;
}

.kb-videomate-floating-widget.minimized .kb-videomate-floating-body {
    padding-top: 100%;
    border-radius: 50%;
}

/* Custom Video Controls */
.kb-videomate-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kb-videomate-floating-body:hover .kb-videomate-video-controls {
    opacity: 1;
}

.kb-videomate-play-pause,
.kb-videomate-mute-unmute {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kb-videomate-play-pause:hover,
.kb-videomate-mute-unmute:hover {
    background: rgba(255,255,255,0.2);
}

.kb-videomate-progress {
    flex-grow: 1;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.kb-videomate-progress-bar {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 0%;
}

/* Control Icons */
.kb-videomate-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Video Orientation Styles */
.kb-videomate-video-wrapper {
    position: relative;
    overflow: hidden;
    background: #000;
    border-radius: 12px;
}

.kb-videomate-video-wrapper.landscape {
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.kb-videomate-video-wrapper.portrait {
    padding-bottom: 177.78%; /* 9:16 aspect ratio */
}

.kb-videomate-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Video Controls */
.kb-videomate-video-wrapper video::-webkit-media-controls,
.kb-videomate-floating-body video::-webkit-media-controls {
    display: flex !important;
    opacity: 1 !important;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

/* Ensure videos maintain aspect ratio */
.kb-videomate-video-wrapper video,
.kb-videomate-floating-body video {
    background: #000;
}

/* Video Controls */
.kb-videomate-video-wrapper video::-webkit-media-controls {
    display: flex !important;
    opacity: 1 !important;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

/* Currently Playing State */
.kb-videomate-carousel-item.is-playing .kb-videomate-video-wrapper {
    box-shadow: 0 0 0 2px #fff, 0 4px 12px rgba(0,0,0,0.2);
}

/* Floating Widget Mute Button */
.kb-videomate-mute-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    padding: 8px;
    transition: background-color 0.2s ease;
}

.kb-videomate-mute-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.kb-videomate-mute-btn svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Hide mute button when minimized */
.kb-videomate-floating.minimized .kb-videomate-mute-btn {
    display: none;
}

/* Ensure floating video is always in portrait mode */
.kb-videomate-floating-body {
    position: relative;
    padding-bottom: 177.78%; /* 9:16 aspect ratio for portrait */
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}

.kb-videomate-floating-body video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Floating Widget States */
.kb-videomate-floating {
    transition: all 0.3s ease;
}

.kb-videomate-floating.minimized {
    width: 60px !important;
    height: 60px !important;
    padding: 0;
    border-radius: 50% !important;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.kb-videomate-floating.minimized .kb-videomate-floating-body {
    padding-bottom: 100%;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .kb-videomate-mute-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }

    .kb-videomate-mute-btn svg {
        width: 18px;
        height: 18px;
    }
}