/* Color Palette */
:root {
    --header-color: #334257;   /* Dark blue-grey for header */
    --button-hover: #476072;   /* Blue-grey for plus/minus hover */
    --text-light: #EEEEEE;    /* Light grey for text and icons */
    --close-hover: #dc2626;   /* Red for close button hover */
    --shadow: rgba(0, 0, 0, 0.25);
}

/* Toggle Button */
.slvp-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--header-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99998;
    box-shadow: 0 4px 16px var(--shadow);
    border: none;
    transition: all 0.2s ease;
}

.slvp-toggle-button:hover {
    background: var(--button-hover);
}


.slvp-toggle-button img {
    display: none; 
}

.slvp-toggle-button::before {
    content: '\f2a3';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 32px;
    color: var(--text-light);
}

/* Player Container */
#slvp-player-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    height: 250px;
    min-width: 300px;
    min-height: 250px;
    max-width: calc(100vw - 40px); /* Prevent overflow on mobile */
    max-height: calc(100vh - 40px);
    background: black;
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 99999;
    overflow: hidden;
    display: none;
    transition: all 0.2s ease;
}

#slvp-player-container.slvp-visible {
    display: block;
    animation: slvp-fadeIn 0.3s ease;
}

/* Player Header */
.slvp-player-header {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--header-color);
    border-bottom: 1px solid var(--header-color);
}

/* Logo/Title text */
.slvp-player-title {
    color: var(--text-light);    
    margin-right: auto;
    font-size: 10px !important;
    font-weight: normal;
}

.slvp-player-logo {
    filter: brightness(0) invert(1);
    margin-right: 8px;
}

/* Controls container */
.slvp-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Control buttons */
.slvp-control-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s ease;
    font-size: 20px;
}

.slvp-minus-btn { order: 1; }
.slvp-plus-btn { order: 2; }
.slvp-close-btn { order: 3; }

.slvp-plus-btn:hover,
.slvp-minus-btn:hover {
    background: var(--button-hover);
}

.slvp-close-btn:hover {
    background: var(--close-hover);
}

/* Video Container */
.slvp-video-frame {
    width: 100%;
    height: calc(100% - 60px);
    min-height: calc(250px - 60px);
    background: black;
    position: relative;
}

#slvp-video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Text Wrapper */
.slvp-text-wrapper {
    position: relative;
    display: inline-block;
    transition: all 0.2s ease;
    padding: 0;
    cursor: text;
}

/* Translation Icon */
.slvp-translate-icon {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    min-width: 24px; /* Minimum width */
    max-width: 40px; /* Maximum width */
    min-height: 24px; /* Minimum height */
    max-height: 40px; /* Maximum height */
    width: auto; /* Let it scale within min/max bounds */
    height: 100%; /* Match text height within bounds */
    background: #4a90e2;
    cursor: pointer;
    display: none !important;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    z-index: 1000;
    overflow: hidden;
}

.slvp-translate-icon::before {
    content: '\f2a3';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: white;
    font-size: clamp(14px, 75%, 24px); /* Min, preferred, max size */
    line-height: 1;
}

/* Scale icon based on text size */
h1 .slvp-translate-icon::before {
    font-size: min(75%, 32px);
}

h2 .slvp-translate-icon::before,
h3 .slvp-translate-icon::before {
    font-size: min(75%, 28px);
}

.dropdown .slvp-translate-icon,
.dropdown-menu .slvp-translate-icon {
    min-width: 24px;
    min-height: 24px;
    max-width: 30px;
    max-height: 30px;
}

.slvp-translate-icon:hover {
    background: #357abd;
}

/* Hover States */
body.slvp-active .slvp-text-wrapper:hover .slvp-translate-icon {
    display: flex !important;
}

body.slvp-active .slvp-text-wrapper:not(.slvp-current-translation):hover {
    border: 2px dashed #476072;
    border-radius: 4px;
    margin: -2px;
    background: transparent;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Special Content Types */
.slvp-text-wrapper[data-is-link="true"],
.slvp-text-wrapper[data-is-button="true"] {
    cursor: pointer;
    padding-right: 0;
}

.slvp-text-wrapper[data-is-link="true"] .slvp-translate-icon {
    background-color: #e67e22;
}

.slvp-text-wrapper[data-is-button="true"] .slvp-translate-icon {
    background-color: #2ecc71;
}

/* Current Translation States */
.slvp-current-translation {
    border: none !important;    
    outline: 2px dashed #3498db !important;   
    border-radius: 4px;
    background: rgba(52, 152, 219, 0.1) !important;
}

.slvp-text-wrapper[data-is-link="true"].slvp-current-translation {
    outline-color: #e67e22 !important;
}

.slvp-text-wrapper[data-is-button="true"].slvp-current-translation {
    outline-color: #2ecc71 !important;
}

/* Loading States */
.slvp-spinner {
    width: 20px;         
    height: 20px;        
    margin: 2px;
    border: 3px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    border-top-color: white;
    animation: slvp-spin 0.8s linear infinite;
}

.slvp-processing {
    outline-color: #f1c40f !important;
    cursor: progress !important;
}

/* Animations */
@keyframes slvp-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Text Markers */
.slvp-text-marker {
    cursor: pointer;     
    transition: all 0.2s ease;
    padding: 0 2px;      
    margin: 0 -2px;       
}

/* Hover for text */
.slvp-text-marker:hover {
    background: rgba(74, 144, 226, 0.1);
    outline: 2px dashed rgba(74, 144, 226, 0.3); 
}

/* Special cases */
nav .slvp-text-wrapper,
header .slvp-text-wrapper,
footer .slvp-text-wrapper,
h1 .slvp-text-wrapper,
h2 .slvp-text-wrapper,
h3 .slvp-text-wrapper,
h4 .slvp-text-wrapper,
h5 .slvp-text-wrapper,
h6 .slvp-text-wrapper {
    display: inline-block !important;
}

/* Add hover detection area */
.slvp-text-wrapper::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: calc(100% + 65px); /* Extend to cover icon */
    height: 100%;
    pointer-events: auto;
}

/* Responsive styles */
@media screen and (max-width: 768px) {
    #slvp-player-container {
        bottom: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        height: auto;
        min-width: 250px;
        min-height: 200px;
    }

    .slvp-toggle-button {
        bottom: 10px;
        right: 10px;
        width: 50px;
        height: 50px;
    }

    .slvp-toggle-button::before {
        font-size: 24px;
    }

    /* Adjust control buttons for mobile */
    .slvp-control-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    /* Adjust header for mobile */
    .slvp-player-header {
        padding: 8px;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    #slvp-player-container {
        min-width: 200px;
        min-height: 150px;
    }

    .slvp-toggle-button {
        width: 45px;
        height: 45px;
    }

    .slvp-toggle-button::before {
        font-size: 20px;
    }

    /* Further reduce control buttons */
    .slvp-control-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
}

/* Landscape orientation */
@media screen and (max-height: 480px) and (orientation: landscape) {
    #slvp-player-container {
        width: 60vw;
        height: calc(100vh - 40px);
        right: 10px;
        bottom: 10px;
    }

    .slvp-video-frame {
        height: calc(100% - 45px); /* Smaller header in landscape */
    }

    .slvp-player-header {
        padding: 6px;
    }
}

