/* TeamSpeak Viewer - v2.5.0 */

.teamspeak-viewer {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 8px;
    padding: 16px;
    color: #ffffff;
    max-width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
}

.teamspeak-viewer * {
    box-sizing: border-box;
}

/* Reset potential theme conflicts */
.teamspeak-viewer svg {
    vertical-align: middle;
    display: inline-block;
}

/* Loading State */
.tsv-loading {
    text-align: center;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.tsv-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: tsv-spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* Server Header */
.tsv-server {
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.tsv-server-name {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tsv-server-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: rgba(255, 255, 255, 0.85);
}

.tsv-stats-left {
    display: flex;
    gap: 16px;
    align-items: center;
}

.tsv-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1;
}

.tsv-refresh-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 4px;
    padding: 2px 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tsv-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.tsv-refresh-btn .tsv-icon {
    width: 16px;
    height: 16px;
}

/* Icons - Consistent sizing and alignment */
.tsv-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Channel Tree */
.tsv-tree {
    margin-top: 8px;
}

.tsv-channel {
    position: relative;
}

.tsv-channel-header,
.tsv-client {
    display: flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    gap: 6px;
    line-height: 1;
}

/* Collapsible behavior */
.tsv-collapsible-enabled .tsv-channel-header {
    cursor: pointer;
}

.tsv-collapsible-enabled .tsv-channel-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tsv-non-collapsible .tsv-channel-header {
    cursor: default;
}

/* Arrow for collapsible channels */
.tsv-arrow {
    width: 12px;
    height: 12px;
    fill: rgba(255, 255, 255, 0.6);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.tsv-channel.collapsed .tsv-arrow {
    transform: rotate(-90deg);
}

/* Channel and Client Icons */
.tsv-channel-icon {
    opacity: 0.7;
}

.tsv-client-icon {
    opacity: 0.9;
    color: #82a8ff;
}

/* Names */
.tsv-channel-name,
.tsv-client-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.tsv-channel-name {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
}

.tsv-client-name {
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
}

/* Client Status Icons */
.tsv-client-status {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding-left: 8px;
}

.tsv-status-icon {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    fill: currentColor;
}

.tsv-status-icon[title="Away"] {
    color: #ffa500;
}

.tsv-status-icon[title="Sound Muted"] {
    color: #ff6b6b;
}

/* Indentation using margin (more reliable than padding) */
.tsv-depth-0 { margin-left: 0; }
.tsv-depth-1 { margin-left: 20px; }
.tsv-depth-2 { margin-left: 40px; }
.tsv-depth-3 { margin-left: 60px; }
.tsv-depth-4 { margin-left: 80px; }
.tsv-depth-5 { margin-left: 100px; }
.tsv-depth-6 { margin-left: 120px; }
.tsv-depth-7 { margin-left: 140px; }

/* Spacer Channels */
.tsv-spacer .tsv-channel-header {
    cursor: default !important;
    opacity: 0.4;
    font-size: 12px;
    font-style: italic;
    min-height: 20px;
}

.tsv-spacer .tsv-channel-header:hover {
    background: transparent !important;
}

/* Collapsible Animation */
.tsv-collapsible {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    max-height: 0;
}

.tsv-collapsible.expanded {
    max-height: 5000px;
}

/* Error State */
.tsv-error {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #ffffff;
    padding: 16px;
    border-radius: 6px;
    text-align: center;
}

.tsv-error-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    color: #ff6b6b;
}

.tsv-error p {
    margin: 0 0 12px 0;
    font-weight: 500;
}

.tsv-retry-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 4px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.tsv-retry-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive Design */
@media (max-width: 480px) {
    .teamspeak-viewer {
        padding: 12px;
    }
    
    .tsv-server-name {
        font-size: 14px;
    }
    
    .tsv-server-stats {
        gap: 12px;
    }
    
    .tsv-stats-left {
        gap: 12px;
    }
    
    .tsv-stat {
        font-size: 12px;
    }
    
    .tsv-channel-name,
    .tsv-client-name {
        font-size: 12px;
    }
    
    .tsv-depth-1 { margin-left: 16px; }
    .tsv-depth-2 { margin-left: 32px; }
    .tsv-depth-3 { margin-left: 48px; }
    .tsv-depth-4 { margin-left: 64px; }
    .tsv-depth-5 { margin-left: 80px; }
    .tsv-depth-6 { margin-left: 96px; }
    .tsv-depth-7 { margin-left: 112px; }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .teamspeak-viewer {
        border: 1px solid #ffffff;
    }
    
    .tsv-channel-header:hover,
    .tsv-client:hover {
        outline: 1px solid #ffffff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .tsv-spinner {
        animation: none;
        opacity: 0.8;
    }
    
    .tsv-arrow,
    .tsv-collapsible {
        transition: none;
    }
}

/* Print Styles */
@media print {
    .teamspeak-viewer {
        background: white;
        color: black;
        box-shadow: none;
        border: 1px solid #cccccc;
    }
    
    .tsv-refresh-btn {
        display: none;
    }
    
    .tsv-icon {
        opacity: 1;
    }
}

/* Fix for potential theme conflicts */
.teamspeak-viewer ul,
.teamspeak-viewer li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.teamspeak-viewer button {
    font-family: inherit;
}

/* Ensure consistent rendering across browsers */
.teamspeak-viewer {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}