/**
 * SSE IRC Chat Preview Styles
 * Light theme IRC chat interface integrated with THCAIndex theme
 */

/* =========================================
   Original Welcome Header Fallback Styles
   ========================================= */

.original-welcome-header {
    margin-bottom: 2rem;
}

.original-welcome-header h2 {
    color: var(--primary-green, #22c55e);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
}

.original-welcome-header p {
    color: #6b7280;
    font-size: 1.125rem;
    margin-bottom: 2rem;
    text-align: center;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-social-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.social-cta-icons {
    display: flex;
    gap: 1rem;
}

.social-green-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background: var(--primary-green, #22c55e);
    color: white;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 1.25rem;
    cursor: pointer;
}

.social-green-icon:hover {
    background: #16a34a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.social-cta-text {
    color: #6b7280;
    font-weight: 500;
    font-size: 0.875rem;
}

/* =========================================
   IRC Chat Container
   ========================================= */

.irc-chat-preview {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', 'Courier New', monospace;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    margin-bottom: 2rem;
    position: relative;
}

/* =========================================
   Chat Header
   ========================================= */

.chat-header {
    background: var(--primary-green, #22c55e);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 600;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-name {
    color: #fff;
    font-weight: 700;
}

.server-name {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
    font-size: 12px;
}

.server-name.server-link {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s ease;
    cursor: pointer;
}

.server-name.server-link:hover {
    color: rgba(34, 197, 94, 0.9); /* Green hover color to match theme */
    text-decoration: underline;
}

.server-name.server-link:visited {
    color: rgba(255, 255, 255, 0.8);
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

/* =========================================
   Connection Status Indicator
   ========================================= */

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
}

/* Status states */
.status-indicator.connecting .status-dot {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

.status-indicator.connected .status-dot,
.status-indicator.live .status-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-indicator.offline .status-dot,
.status-indicator.disconnected .status-dot,
.status-indicator.failed .status-dot {
    background: #ef4444;
}

.status-indicator.reconnecting .status-dot {
    background: #f59e0b;
    animation: pulse 1s infinite;
}

.user-count {
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
}

/* =========================================
   Chat Messages Area
   ========================================= */

.chat-messages {
    background: #f8f9fa;
    height: 200px;
    overflow-y: auto;
    padding: 12px;
    line-height: 1.4;
    font-size: 13px;
    color: #212529;
    position: relative;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* =========================================
   Loading State
   ========================================= */

.loading-messages {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: #6c757d;
    font-size: 12px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top: 2px solid var(--primary-green, #22c55e);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* =========================================
   IRC Message Styles
   ========================================= */

.message {
    margin: 1px 0;
    padding: 6px 8px;
    word-wrap: break-word;
    word-break: break-word;
    transition: background-color 0.3s ease;
    border-radius: 4px;
}

/* Alternating darker green backgrounds like vendors section */
.message:nth-child(even) {
    background: rgba(34, 197, 94, 0.12);
}

.message:nth-child(odd) {
    background: transparent;
}

.message:hover {
    background: rgba(34, 197, 94, 0.20) !important;
}

.message.new-message {
    background: rgba(34, 197, 94, 0.20) !important;
    animation: messageSlideIn 0.4s ease-out, messageFadeHighlight 3s ease-out;
}

/* Timestamp styling */
.timestamp {
    color: #495057;
    font-weight: 600;
    user-select: none;
}

/* Username styling */
.username {
    color: var(--primary-green, #22c55e);
    font-weight: 700;
    margin: 0 8px 0 4px;
}

/* Message content */
.message-content {
    color: #212529;
}

/* System messages (joins, leaves, etc.) */
.system-message {
    color: #6c757d;
    font-style: italic;
    margin-left: 4px;
}

/* Edited badge */
.edited-badge {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 10px;
    margin-left: 6px;
    font-weight: 500;
}

/* =========================================
   Chat Footer
   ========================================= */

.chat-footer {
    background: #f8f9fa;
    border-top: 1px solid #e5e7eb;
    padding: 12px 20px;
    text-align: center;
}

.chat-invite-text {
    color: #495057;
    font-size: 11px;
    margin: 0 0 8px 0;
    line-height: 1.4;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.chat-join-btn {
    color: var(--primary-green, #22c55e);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--primary-green, #22c55e);
}

.chat-join-btn:hover {
    color: white;
    background: var(--primary-green, #22c55e);
    transform: translateY(-1px);
}

.chat-join-btn i {
    font-size: 10px;
}

/* =========================================
   Authentication States
   ========================================= */

.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #6c757d;
    font-size: 11px;
    padding: 8px;
}

.loading-spinner-small {
    width: 12px;
    height: 12px;
    border: 1px solid #e5e7eb;
    border-top: 1px solid var(--primary-green, #22c55e);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* =========================================
   Message Composer Interface
   ========================================= */

.message-composer {
    background: #f8f9fa;
    padding: 8px 12px;
}

.composer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 10px;
}

.logged-in-as {
    color: #6c757d;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.logout-btn {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #dc3545;
    color: white;
}

.message-input-area {
    display: flex;
    gap: 8px;
    align-items: center;
}

.message-input-area input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.message-input-area input:focus {
    border-color: var(--primary-green, #22c55e);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.message-input-area button {
    background: var(--primary-green, #22c55e);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-input-area button:hover:not(:disabled) {
    background: #16a34a;
    transform: translateY(-1px);
}

.message-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   Animations
   ========================================= */

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

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

@keyframes messageSlideIn {
    0% { 
        transform: translateX(-10px);
        opacity: 0;
    }
    100% { 
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes messageFadeHighlight {
    0% { 
        background: rgba(34, 197, 94, 0.30) !important; 
        transform: translateX(4px);
    }
    100% { 
        background: rgba(34, 197, 94, 0.12) !important;
        transform: translateX(0);
    }
}

/* =========================================
   Responsive Design
   ========================================= */

/* Tablet */
@media (max-width: 768px) {
    .irc-chat-preview {
        margin-bottom: 1.5rem;
    }
    
    .chat-header {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .chat-messages {
        height: 160px;
        padding: 10px;
        font-size: 12px;
    }
    
    .chat-footer {
        padding: 8px 16px;
    }
    
    .server-name {
        display: none; /* Hide server name on small screens */
    }
}

/* Mobile */
@media (max-width: 480px) {
    .irc-chat-preview {
        border-radius: 8px;
        margin-bottom: 1rem;
    }
    
    .chat-header {
        padding: 8px 12px;
        font-size: 12px;
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    
    .chat-status {
        align-self: flex-end;
        margin-top: -20px;
    }
    
    .chat-messages {
        height: 140px;
        padding: 8px;
        font-size: 11px;
    }
    
    .message {
        line-height: 1.3;
    }
    
    .timestamp {
        font-size: 10px;
    }
    
    .username {
        margin: 0 6px 0 3px;
    }
    
    .chat-footer {
        padding: 6px 12px;
    }
    
    .chat-footer a {
        font-size: 11px;
    }
    
    /* Stack header elements on very small screens */
    .user-count {
        display: none;
    }
}

/* =========================================
   Dark Mode Compatibility
   ========================================= */

@media (prefers-color-scheme: dark) {
    .irc-chat-preview {
        border-color: #30363d;
    }
    
    .chat-messages::-webkit-scrollbar-thumb {
        background: #424a53;
    }
}

/* =========================================
   High Contrast Mode
   ========================================= */

@media (prefers-contrast: high) {
    .irc-chat-preview {
        border-width: 3px;
    }
    
    .status-dot {
        width: 10px;
        height: 10px;
    }
    
    .message:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* =========================================
   Print Styles
   ========================================= */

@media print {
    .irc-chat-preview {
        background: white;
        color: black;
        border: 1px solid black;
    }
    
    .chat-header {
        background: #f0f0f0;
        color: black;
    }
    
    .chat-messages {
        background: white;
        color: black;
        height: auto;
        max-height: 300px;
    }
    
    .timestamp, .system-message {
        color: #666;
    }
    
    .username {
        color: #333;
    }
    
    .chat-footer {
        background: #f9f9f9;
    }
}

/* =========================================
   Integration with Welcome Banner
   ========================================= */

/* Ensure proper spacing with the carousel below */
.welcome-banner-content .irc-chat-preview {
    margin-bottom: 0;
}

.welcome-banner-content .welcome-features-carousel {
    margin-top: 2rem;
}

/* Match the spacing and alignment of the original welcome section */
@media (min-width: 768px) {
    .irc-chat-preview {
        margin-bottom: 1rem;
    }
}

/* =========================================
   Accessibility Improvements
   ========================================= */

.irc-chat-preview {
    /* Ensure good keyboard navigation */
    outline: none;
}

.chat-messages:focus {
    outline: 2px solid var(--primary-green, #22c55e);
    outline-offset: -2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .status-dot,
    .message.new-message,
    .chat-footer a {
        animation: none;
    }
    
    .message.new-message {
        background: rgba(34, 197, 94, 0.1);
    }
}