/* ================================================== */
/* TELEGRAM GROUP PLUGIN - STYLES DE BASE */
/* ================================================== */

/* ===== STRUCTURE PRINCIPALE ===== */
.telegram-group-live {
    border-radius: 16px;
    margin: 20px 0;
    border: 2px solid #e1e8ed;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== EN-TÊTE ===== */
.telegram-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-height: 60px;
}

.telegram-group-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.telegram-group-icon svg {
    width: 20px;
    height: 20px;
}

.telegram-group-info {
    flex: 1;
}

.telegram-group-info h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.telegram-group-info p {
    font-size: 14px;
    margin: 0;
    opacity: 0.9;
    line-height: 1.3;
}

.telegram-group-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    min-width: 80px;
    justify-content: center;
}

.telegram-live-dot {
    width: 8px;
    height: 8px;
    background: #4cd964;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ===== CONTENEUR DES MESSAGES ===== */
.telegram-messages-container {
    max-height: 500px;
    height: 500px;
    min-height: calc(100vh - 340px);
    background: #f8f9fa;
    overflow-y: auto;
    scroll-behavior: smooth;
    position: relative;
}

.telegram-messages-list {
    padding: 8px 0;
}

/* ===== MESSAGES ===== */
.telegram-group-message {
    padding: 12px 16px;
    margin: 0;
    animation: messageSlideIn 0.3s ease-out;
    min-height: 60px;
    transition: background-color 0.2s ease;
}

.telegram-group-message:hover {
    background: rgba(0, 136, 204, 0.03);
}

.telegram-group-message.new-message {
    animation: highlightMessage 0.6s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes highlightMessage {
    0% {
        background: rgba(102, 126, 234, 0.1);
    }
    100% {
        background: transparent;
    }
}

.telegram-sender-info {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    align-items: flex-start;
}

.telegram-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.telegram-sender-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.telegram-sender-name {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.2;
}

.telegram-message-time {
    font-size: 11px;
    color: #718096;
    line-height: 1.2;
}

.telegram-message-content {
    margin-left: 40px;
    margin-top: -4px;
}

/* Style quand l'expéditeur n'est pas affiché */
.telegram-group-message:not(.has-sender) .telegram-message-content {
    margin-left: 0;
    margin-top: 0;
}

.telegram-message-meta {
    margin-top: 4px;
    text-align: right;
}

/* ===== TEXTE DES MESSAGES ===== */
.telegram-message-text {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 12px;
    background: white;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin: 0;
    position: relative;
    word-wrap: break-word;
}

.telegram-message-text::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 12px;
    width: 12px;
    height: 12px;
    background: white;
    border-left: 1px solid #e9ecef;
    border-top: 1px solid #e9ecef;
    transform: rotate(45deg);
}

.telegram-group-message:not(.has-sender) .telegram-message-text::before {
    display: none;
}

/* ===== MÉDIAS ===== */
.telegram-message-media {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.telegram-message-media:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.telegram-media {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.telegram-video-wrapper {
    position: relative;
}

.telegram-video-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.telegram-video-wrapper:hover::before {
    opacity: 1;
}

.telegram-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 20px;
    border-color: transparent transparent transparent #667eea;
    cursor: pointer;
    z-index: 2;
    transition: all 0.3s ease;
}

.telegram-video-wrapper:hover .telegram-video-play {
    transform: translate(-50%, -50%) scale(1.1);
}

.telegram-audio-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin: 4px 0;
    position: relative;
    overflow: hidden;
}

.telegram-audio-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e9ecef;
}

.telegram-audio-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.1s linear;
}

.telegram-audio {
    flex: 1;
    height: 40px;
    outline: none;
}

.telegram-voice-message {
    background: #f0f9ff;
    border-color: #b3e0ff;
}

.telegram-voice-label {
    background: #0088cc;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 136, 204, 0.3);
}

.telegram-sticker {
    max-width: 150px;
    border-radius: 8px;
}

.telegram-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    background: #0088cc;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
    margin: 2px 0;
    transition: all 0.3s ease;
}

.telegram-file-link:hover {
    background: #0077b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
    color: white;
    text-decoration: none;
}

/* ===== SONDAGES ===== */
.telegram-poll {
    padding: 16px;
    border-radius: 12px;
    margin: 8px 0;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.telegram-poll-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.telegram-poll-icon {
    font-size: 16px;
}

.telegram-poll-title {
    font-size: 14px;
    font-weight: 700;
    color: #2d3748;
}

.telegram-poll-question {
    font-size: 15px;
    font-weight: 600;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    text-align: left;
    line-height: 1.4;
}

.telegram-poll-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.telegram-poll-option {
    padding: 12px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin: 0;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.telegram-poll-option:hover {
    border-color: #0088cc;
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.15);
    transform: translateY(-1px);
}

.telegram-poll-option.winner {
    border-color: #28a745;
    background: #f8fff9;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.telegram-poll-option.correct {
    border-color: #28a745;
    background: #f8fff9;
    box-shadow: 0 0 0 1px rgba(40, 167, 69, 0.2);
}

.telegram-poll-winner-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.telegram-poll-correct-badge {
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 11px;
    margin-left: 6px;
}

.telegram-poll-rank {
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 11px;
    margin-right: 6px;
    flex-shrink: 0;
    margin-top: 2px;
}

.telegram-poll-option-content {
    flex: 1;
    margin: 0;
}

.telegram-poll-option-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
}

.telegram-poll-option-text {
    font-size: 14px;
    line-height: 1.4;
    flex: 1;
    font-weight: 500;
}

.telegram-poll-percentage {
    font-size: 14px;
    font-weight: 700;
    color: #2d3748;
    min-width: 40px;
    text-align: right;
}

.telegram-poll-results {
    display: flex;
    gap: 8px;
    align-items: center;
}

.telegram-poll-bar {
    height: 6px;
    border-radius: 3px;
    background: #e9ecef;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    flex: 1;
    overflow: hidden;
    position: relative;
}

.telegram-poll-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease-in-out;
    position: relative;
}

.telegram-poll-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.telegram-poll-option.winner .telegram-poll-bar-fill {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
}

.telegram-poll-option.correct .telegram-poll-bar-fill {
    background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%);
}

.telegram-poll-votes {
    font-size: 12px;
    color: #718096;
    min-width: 60px;
    text-align: right;
    font-weight: 500;
}

.telegram-poll-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #dee2e6;
    gap: 12px;
}

.telegram-poll-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.telegram-poll-total {
    font-size: 13px;
    color: #718096;
    margin: 0;
    font-weight: 500;
}

.telegram-poll-visibility {
    font-size: 12px;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
}

.telegram-poll-meta {
    display: flex;
    gap: 6px;
    align-items: center;
}

.telegram-poll-type,
.telegram-poll-status {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.telegram-poll-type {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.telegram-poll-type.quiz {
    background: rgba(255, 193, 7, 0.1);
    color: #d97706;
}

.telegram-poll-status {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.telegram-poll-status.closed {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}

/* Indicateurs visuels pour l'état du sondage */
.telegram-poll.open .telegram-poll-bar-fill {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.telegram-poll.closed .telegram-poll-bar-fill {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
}

.telegram-poll.quiz .telegram-poll-bar-fill {
    background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%);
}

/* ===== PIED DE PAGE ===== */
.telegram-group-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
    min-height: 50px;
}

.telegram-refresh-btn {
    padding: 8px 16px;
    font-size: 14px;
    background: #0088cc;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
    transition: all 0.3s ease;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.telegram-refresh-btn:hover:not(:disabled) {
    background: #0077b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.4);
}

.telegram-refresh-btn:disabled {
    background: #adb5bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.telegram-countdown {
    padding: 6px 12px;
    font-size: 13px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.telegram-countdown.loading {
    border-color: #0088cc;
    background: #f0f9ff;
    animation: pulse 1.5s infinite;
}

.telegram-countdown.error {
    border-color: #e74c3c;
    background: #fee;
    color: #c33;
}

.telegram-countdown.success {
    border-color: #28a745;
    background: #f8fff9;
    color: #28a745;
    animation: pulseSuccess 1s ease-in-out;
}

@keyframes pulseSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.telegram-spinner-mini {
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid #0088cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

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

/* ===== NOTIFICATIONS ===== */
.telegram-media-playing-notification {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
    z-index: 10000;
    animation: slideInDown 0.3s ease-out;
    min-width: 300px;
}

.telegram-media-playing-notification .telegram-notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    font-weight: 600;
}

.telegram-notification-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.telegram-refresh-anyway {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.telegram-refresh-anyway:hover {
    background: rgba(255, 255, 255, 0.3);
}

.telegram-notification-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.telegram-notification-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.telegram-new-messages-indicator {
    position: absolute;
    bottom: 60px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
    animation: slideInUp 0.3s ease-out;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

/* ===== ÉTATS D'ERREUR ===== */
.telegram-error,
.telegram-info {
    padding: 16px;
    margin: 8px;
    font-size: 14px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
}

.telegram-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
}

.telegram-info {
    background: #eff;
    border: 1px solid #cef;
    color: #366;
}

/* ===== SCROLLBAR ===== */
.telegram-messages-container::-webkit-scrollbar {
    width: 6px;
}

.telegram-messages-container::-webkit-scrollbar-track {
    margin: 4px;
    border-radius: 3px;
    background: #f1f3f4;
}

.telegram-messages-container::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.telegram-messages-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* ===== ANIMATIONS ===== */
.telegram-group-message {
    animation: messageSlideIn 0.3s ease-out;
}

.telegram-poll-bar-fill {
    transition: width 0.5s ease-in-out;
}

.telegram-database-notice {
    background: #e7f3ff;
    border: 1px solid #b8daff;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #004085;
    text-align: center;
}

.telegram-source-indicator {
    font-size: 0.8em;
    margin-left: 5px;
    opacity: 0.7;
}

.telegram-group-message.from-database {
    opacity: 0.95;
    border-left: 3px solid #6c757d;
}

.telegram-group-message.from-database .telegram-message-time {
    font-style: italic;
}

/* ===== DESIGN RESPONSIVE ===== */
@media (max-width: 768px) {
    .telegram-group-live {
        border-radius: 12px;
        margin: 16px 0;
    }
    
    .telegram-group-header {
        padding: 12px 16px;
    }
    
    .telegram-messages-container {
        max-height: 400px;
        height: 400px;
        min-height: calc(100vh - 300px);
    }
    
    .telegram-group-message {
        padding: 10px 12px;
    }
    
    .telegram-group-footer {
        padding: 10px 12px;
        flex-direction: column;
        gap: 8px;
    }
    
    .telegram-refresh-btn {
        width: 100%;
        justify-content: center;
    }
    
    .telegram-countdown {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .telegram-group-live {
        border-radius: 8px;
        margin: 12px 0;
    }
    
    .telegram-group-header {
        padding: 10px 12px;
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .telegram-messages-container {
        max-height: 300px;
        height: 300px;
        min-height: calc(100vh - 250px);
    }
    
    .telegram-group-message {
        padding: 8px 10px;
    }
    
    .telegram-message-text {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .telegram-sender-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .telegram-message-content {
        margin-left: 0;
        margin-top: 4px;
    }
}

/* ===== THÈME SOMBRE ===== */
@media (prefers-color-scheme: dark) {
    .telegram-group-live {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .telegram-group-header {
        background: #4a5568;
    }
    
    .telegram-messages-container {
        background: #2d3748;
    }
    
    .telegram-message-text {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .telegram-message-text::before {
        background: #4a5568;
        border-color: #718096;
    }
    
    .telegram-sender-name {
        color: #e2e8f0;
    }
    
    .telegram-audio-wrapper {
        background: #4a5568;
        border-color: #718096;
    }
    
    .telegram-group-footer {
        background: #4a5568;
        border-color: #718096;
    }
    
    .telegram-countdown {
        background: #2d3748;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .telegram-countdown.loading {
        border-color: #0088cc;
        background: #2d5a5a;
    }
    
    .telegram-countdown.success {
        border-color: #28a745;
        background: #2d5a2d;
        color: #a3d9a5;
    }
    
    .telegram-poll {
        background: #4a5568;
        border-color: #718096;
    }
    
    .telegram-poll-question {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .telegram-poll-option {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .telegram-poll-option.winner {
        background: #2d5a2d;
        border-color: #48bb78;
    }
    
    .telegram-poll-bar {
        background: #718096;
    }
}
