/**
 * Stream Chat Manager - Frontend CSS
 * All rules scoped to .scm- prefix to avoid conflicts with theme
 */

/* Container */
.scm-container {
    display: flex;
    gap: 15px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 20px 0;
    box-sizing: border-box;
    overflow-x: hidden;
}

.scm-layout-horizontal {
    flex-direction: row;
}

.scm-layout-vertical {
    flex-direction: column;
}

/* Stream Wrapper */
.scm-stream-wrapper {
    flex: 3;
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    isolation: isolate;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.scm-stream-wrapper[data-ratio="16:9"] {
    aspect-ratio: 16 / 9;
}

.scm-stream-wrapper[data-ratio="4:3"] {
    aspect-ratio: 4 / 3;
}

.scm-stream-wrapper[data-ratio="1:1"] {
    aspect-ratio: 1 / 1;
}

.scm-stream-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    border: none;
    display: block;
    border-radius: inherit;
}

.scm-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.scm-placeholder p {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

/* Chat Wrapper */
.scm-chat-wrapper {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    height: 435px;
    background: #1a1f28;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.scm-layout-horizontal .scm-chat-wrapper {
    min-height: 200px;
}

.scm-layout-vertical .scm-chat-wrapper {
    width: 100% !important;
    min-height: 400px;
}

.scm-chat-iframe {
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 200px;
    border: none;
    display: block;
}

/* External chat action shown when the embedded chat frame is disabled */
.scm-chat-action {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin: -8px 0 20px;
}

.scm-view-chat-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff !important;
    border: 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(5, 150, 105, 0.3);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none !important;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.scm-view-chat-btn:hover,
.scm-view-chat-btn:focus {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
    transform: translateY(-1px);
}

/* iOS Safari iframe width/clip fixes */
@supports (-webkit-touch-callout: none) {
    .scm-stream-iframe {
        width: 1px;
        min-width: 100%;
    }
}

/* Buttons Container */
.scm-buttons-wrapper {
    position: relative;
    margin: 20px 0;
}

@media screen and (max-width: 768px) {
    .scm-chat-wrapper {
        height: 600px !important;
        min-height: 400px;
    }
}

.scm-buttons-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 0 6px 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 0;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Hint Text */
.scm-hint {
    display: none;
    font-size: 11px;
    color: #6b7280;
    margin: 0;
    padding: 0 5px;
    opacity: 0.8;
    font-style: italic;
    text-align: center;
}

/* Scrollbar styling */
.scm-buttons-container::-webkit-scrollbar {
    height: 8px;
}

.scm-buttons-container::-webkit-scrollbar-track {
    background: #1a1f28;
    border-radius: 4px;
}

.scm-buttons-container::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 4px;
}

.scm-buttons-container::-webkit-scrollbar-thumb:hover {
    background: #2563eb;
}

/* Channel Buttons - Default Style */
.scm-style-default .scm-channel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    min-width: 100px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    white-space: nowrap;
    line-height: 1.4;
}

.scm-style-default .scm-channel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.5);
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
}

.scm-style-default .scm-channel-btn:active {
    transform: translateY(0);
}

.scm-style-default .scm-channel-btn.active,
.scm-style-default .scm-channel-btn.active:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.5) !important;
    color: #fff !important;
}

/* Channel Buttons - Pills Style */
.scm-style-pills .scm-channel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    min-width: 90px;
    flex-shrink: 0;
    background: #1a1f28;
    color: #e4e6eb;
    border: 2px solid #2d333b;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.scm-style-pills .scm-channel-btn:hover {
    border-color: #3b82f6;
    color: #60a5fa;
    background: #2d333b;
}

.scm-style-pills .scm-channel-btn.active,
.scm-style-pills .scm-channel-btn.active:hover {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #fff !important;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.4) !important;
}

/* Channel Buttons - Minimal Style */
.scm-style-minimal .scm-channel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    min-width: 80px;
    flex-shrink: 0;
    background: transparent;
    color: #9ca3af;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.scm-style-minimal .scm-channel-btn:hover {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.scm-style-minimal .scm-channel-btn.active,
.scm-style-minimal .scm-channel-btn.active:hover {
    color: #e4e6eb !important;
    border-bottom-color: #10b981 !important;
}

/* Button Icon */
.scm-btn-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

/* Loading State */
.scm-channel-btn.loading {
    opacity: 0.6;
    cursor: wait;
}

.scm-channel-btn.loading .scm-btn-text::after {
    content: '...';
    animation: scm-dots 1.5s infinite;
}

@keyframes scm-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Responsive */
@media (max-width: 1024px) {
    .scm-layout-horizontal {
        flex-direction: column;
    }
    
    .scm-stream-wrapper {
        flex: none;
    }
    
    .scm-chat-wrapper {
        flex: none;
        width: 100% !important;
        max-width: 100%;
        height: 400px;
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .scm-container {
        gap: 10px;
    }
    
    .scm-buttons-container {
        gap: 6px;
    }
    
    .scm-channel-btn {
        font-size: 12px;
        padding: 7px 14px;
        min-width: 85px;
    }
    
    .scm-hint {
        display: block;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .scm-container {
        gap: 8px;
        margin: 10px 0;
    }
    
    .scm-buttons-wrapper {
        margin: 10px 0;
    }

    .scm-chat-action {
        margin: 0 0 10px;
    }

    .scm-view-chat-btn {
        width: 100%;
    }
    
    .scm-buttons-container {
        gap: 6px;
    }
    
    .scm-channel-btn {
        font-size: 11px !important;
        padding: 6px 12px !important;
        min-width: 70px !important;
        gap: 4px;
    }
    
    .scm-btn-icon {
        font-size: 14px;
    }
    
    .scm-hint {
        font-size: 9px;
        padding: 0 2px;
    }
    
    .scm-stream-wrapper {
        min-height: 250px;
        border-radius: 6px;
    }
    
    .scm-chat-wrapper {
        border-radius: 6px;
    }
    
    .scm-buttons-container::-webkit-scrollbar {
        height: 4px;
    }
}

/* Animation */
.scm-fade-in {
    animation: scmFadeIn 0.3s ease-in-out;
}

@keyframes scmFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


