* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00ff00;
    --secondary-color: #00cc00;
    --accent-color: #00bfff;
    --success-color: #00ff00;
    --error-color: #ff4444;
    --warning-color: #ffaa00;
    --background: #0a0a0a;
    --surface: #1a1a1a;
    --surface-light: #2a2a2a;
    --text-primary: #00ff00;
    --text-secondary: #00cc00;
    --text-muted: #00aa00;
    --border: #333333;
    --border-light: #444444;
    --discord-blurple: #5865F2;
    --discord-green: #57F287;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.4;
    font-size: 14px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.discord-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--surface);
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.widget-header {
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.channel-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.logout-button {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
}

.logout-button:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.logout-button:active {
    transform: scale(0.95);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning-color);
    animation: pulse 2s ease-in-out infinite;
}

.status-indicator.connected .status-dot {
    background: var(--success-color);
    animation: none;
}

.status-indicator.error .status-dot {
    background: var(--error-color);
    animation: none;
}

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

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: var(--background);
    scroll-behavior: smooth;
}

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

.messages-container::-webkit-scrollbar-track {
    background: var(--surface);
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    text-align: center;
}

.spinner {
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

.loading-state p {
    font-size: 12px;
    margin: 0;
}

.message {
    display: flex;
    gap: 10px;
    padding: 8px 4px;
    margin-bottom: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.message:hover {
    background: var(--surface);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--surface-light);
    border: 2px solid var(--border);
    object-fit: cover;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 0;
    margin-top: 0;
    line-height: 1.2;
}

/* Add margin-top when text follows header */
.message-header + .message-text {
    margin-top: 4px;
}

/* No gap when attachment follows header directly */
.message-header + .message-attachment {
    margin-top: 0;
}

.message-author {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.message-author.bot {
    color: var(--discord-blurple);
}

.message-timestamp {
    font-size: 11px;
    color: var(--text-muted);
}

.message-text {
    color: var(--text-secondary);
    font-size: 14px;
    word-wrap: break-word;
    line-height: 1.4;
    margin-top: 0;
    margin-bottom: 0;
}

.message-text.message-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 12px;
}

.message-text a {
    color: var(--accent-color);
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text .mention {
    color: var(--accent-color);
    background: rgba(0, 191, 255, 0.15);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.message-text .mention:hover {
    background: rgba(0, 191, 255, 0.25);
}

.message-embed {
    margin-top: 0;
    margin-bottom: 0;
    padding: 8px;
    background: var(--surface);
    border-left: 3px solid var(--discord-blurple);
    border-radius: 4px;
}

/* Add margin-top only if there's text content above */
.message-text + .message-embed {
    margin-top: 8px;
}

/* Remove padding from embed when it only contains an attachment (Tenor GIFs) */
.message-embed:has(> .message-attachment:only-child) {
    padding: 0;
    background: transparent;
    border: none;
}

.embed-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

.embed-description {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.message-attachment {
    margin-top: 0;
    margin-bottom: 0;
    border-radius: 4px;
    overflow: hidden;
    max-width: 100%;
    width: 100%;
}

/* Add margin-top only if there's text content above */
.message-text + .message-attachment,
.message-embed + .message-attachment {
    margin-top: 8px;
}

.message-attachment img,
.attachment-image,
.message-attachment video {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    object-fit: contain;
}

.attachment-image:hover {
    opacity: 0.9;
}

.message-attachment-file {
    margin-top: 8px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.attachment-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 13px;
    word-break: break-all;
}

.attachment-link:hover {
    text-decoration: underline;
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    align-items: center;
}

.reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.reaction:hover {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.reaction-count {
    font-weight: 500;
    min-width: 12px;
    text-align: center;
}

.custom-emoji {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
}

.add-reaction-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    opacity: 0;
}

.message:hover .add-reaction-btn {
    opacity: 1;
}

.add-reaction-btn:hover {
    background: var(--surface-light);
    border-color: var(--primary-color);
    color: var(--text-primary);
    border-style: solid;
}

.emoji-picker {
    position: fixed;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
    background: var(--surface);
}

.emoji-picker::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.emoji-picker-item {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
}

.emoji-picker-item:hover {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: scale(1.2);
}

.emoji-picker-item img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.error-message {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 12px 16px;
    margin: 8px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

.input-container {
    padding: 12px;
    background: var(--surface-light);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.nickname-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nickname-input {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.nickname-input:focus {
    border-color: var(--primary-color);
}

.nickname-input::placeholder {
    color: var(--text-muted);
}

.nickname-button {
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    color: var(--background);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nickname-button:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 255, 0, 0.3);
}

.nickname-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.message-input {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.message-input:focus {
    border-color: var(--primary-color);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.send-button {
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--background);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 255, 0, 0.3);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button svg {
    width: 18px;
    height: 18px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state p {
    font-size: 13px;
    margin-top: 12px;
}

/* Responsive design */
@media (max-width: 480px) {
    .discord-widget {
        height: 100vh;
        width: 100vw;
    }
    
    .widget-header {
        padding: 10px 12px;
    }
    
    .channel-name {
        font-size: 14px;
    }
    
    .message {
        padding: 6px 4px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .message-author {
        font-size: 13px;
    }
    
    .message-text {
        font-size: 13px;
    }
}

