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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #3b82f6;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
}

/* Slack Theme - Aubergine/Purple */
.theme-slack {
    --primary: #611f69;
    --primary-hover: #4a154b;
    --primary-light: #7c3085;
    --bg: #1a1d21;
    --bg-card: #222529;
    --bg-input: #2c2d30;
    --text: #d1d2d3;
    --text-muted: #9a9b9d;
    --border: #3c3f42;
}

/* Teams Theme - Dark Purple/Blue */
.theme-teams {
    --primary: #6264a7;
    --primary-hover: #4f52a3;
    --primary-light: #7b83eb;
    --bg: #1f1f1f;
    --bg-card: #292929;
    --bg-input: #3b3b3b;
    --text: #ffffff;
    --text-muted: #a0a0a0;
    --border: #424242;
}

/* Discord Theme - Dark with Blurple */
.theme-discord {
    --primary: #5865f2;
    --primary-hover: #4752c4;
    --primary-light: #7289da;
    --bg: #313338;
    --bg-card: #2b2d31;
    --bg-input: #1e1f22;
    --text: #dbdee1;
    --text-muted: #949ba4;
    --border: #3f4147;
}

/* Slack Sidebar - Only visible with Slack theme */
.slack-sidebar {
    display: none;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #611f69 0%, #4a154b 100%);
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.theme-slack .slack-sidebar {
    display: flex;
}

.theme-slack.room-page {
    display: flex;
    flex-direction: row;
}

.theme-slack .room-container {
    flex: 1;
    min-width: 0;
}

.slack-workspace {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.workspace-icon {
    width: 36px;
    height: 36px;
    background: #1264a3;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
    margin-right: 10px;
}

.workspace-info {
    display: flex;
    flex-direction: column;
}

.workspace-name {
    color: white;
    font-weight: 700;
    font-size: 15px;
}

.workspace-status {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-top: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2bac76;
    border-radius: 50%;
    margin-right: 6px;
}

.slack-nav {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 6px 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-item svg {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    fill: currentColor;
}

.slack-section {
    padding: 12px 0;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.collapse-arrow {
    width: 12px;
    height: 12px;
    margin-right: 4px;
    opacity: 0.7;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 4px 20px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.channel-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.channel-item.active {
    background: #1264a3;
    color: white;
}

.channel-item.dimmed {
    color: rgba(255, 255, 255, 0.5);
}

.channel-hash {
    margin-right: 8px;
    font-weight: 400;
    font-size: 15px;
}

.lock-icon {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    opacity: 0.7;
}

.add-channel {
    display: flex;
    align-items: center;
    padding: 4px 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.add-channel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.add-channel svg {
    width: 14px;
    height: 14px;
    margin-right: 8px;
}

.dm-item {
    display: flex;
    align-items: center;
    padding: 4px 20px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.dm-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dm-item.dimmed {
    color: rgba(255, 255, 255, 0.5);
}

.dm-avatar {
    width: 20px;
    height: 20px;
    background: #2bac76;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-right: 8px;
}

.dm-avatar.green {
    background: #2bac76;
}

.dm-avatar.gray {
    background: #616061;
    font-size: 14px;
    font-weight: 400;
}

/* Slack Nav Rail - thin left navigation */
.slack-nav-rail {
    display: none;
    width: 70px;
    height: 100vh;
    height: 100dvh;
    background: #3f0e40;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 8px 0;
}

.theme-slack .slack-nav-rail {
    display: flex;
}

.nav-rail-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.nav-rail-workspace {
    padding: 8px 0 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.rail-workspace-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #611f69, #7c3085);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
}

.nav-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 8px;
    width: 58px;
    transition: all 0.15s;
}

.nav-rail-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-rail-item.active {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.nav-rail-item svg {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
}

.nav-rail-item span {
    font-size: 10px;
    font-weight: 500;
}

.nav-rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 8px;
}

.nav-rail-avatar {
    width: 36px;
    height: 36px;
    background: #1264a3;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: white;
    position: relative;
    cursor: pointer;
}

.avatar-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #2bac76;
    border: 2px solid #3f0e40;
    border-radius: 50%;
}

/* Hide Slack UI on mobile */
@media (max-width: 768px) {
    .slack-nav-rail,
    .slack-sidebar {
        display: none !important;
    }

    .theme-slack.room-page {
        display: block;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

body.room-page {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Landing Page */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-link {
    display: flex;
    align-items: center;
}

.kubilo-logo {
    height: 40px;
    width: auto;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.kubilo-logo:hover {
    opacity: 1;
}

header h1 {
    font-size: 2.5rem;
    margin: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

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

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    width: 100%;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 2rem;
}

.footer-links {
    margin-top: 1rem;
    font-size: 0.8rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-links .separator {
    margin: 0 0.5rem;
    opacity: 0.5;
}

.kubilo-brand {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.kubilo-brand a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.kubilo-brand a:hover {
    text-decoration: underline;
}

.version {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* Legal Pages */
.legal-page {
    max-width: 700px;
}

.legal-content {
    text-align: left;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
}

.legal-content section {
    margin-bottom: 2rem;
}

.legal-content section:last-child {
    margin-bottom: 0;
}

.legal-content h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.legal-content p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.legal-content ul {
    color: var(--text-muted);
    margin-left: 1.5rem;
    line-height: 1.8;
}

.legal-content li {
    margin-bottom: 0.25rem;
}

.legal-page footer {
    margin-top: 2rem;
}

.legal-page footer .btn {
    display: inline-block;
    margin-bottom: 1rem;
}

/* Consent Modal */
.consent-modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.consent-subtitle {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.consent-info {
    text-align: left;
    margin-bottom: 1.5rem;
}

.consent-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.consent-item:last-child {
    margin-bottom: 0;
}

.consent-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.consent-item p {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0;
    line-height: 1.4;
}

.consent-links {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.consent-links a {
    color: var(--primary);
    text-decoration: none;
}

.consent-links a:hover {
    text-decoration: underline;
}

/* Chat Room */
.room-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.room-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.room-info h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.room-info h1 span {
    font-family: monospace;
    color: var(--primary);
}

.room-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.room-meta .separator {
    margin: 0 0.5rem;
}

.room-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    word-wrap: break-word;
}

.message-own {
    align-self: flex-end;
    background: var(--primary);
}

.message-other {
    align-self: flex-start;
    background: var(--bg-card);
}

.message-sender {
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.message-own .message-sender {
    color: rgba(255, 255, 255, 0.7);
}

.message-content {
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: right;
}

.message-own .message-time {
    color: rgba(255, 255, 255, 0.6);
}

.message-system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.5rem;
}

.input-container {
    flex-shrink: 0;
    padding: 1rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.input-container form {
    display: flex;
    gap: 0.5rem;
}

.input-container input {
    flex: 1;
}

.input-container .btn {
    width: auto;
}

.connection-status {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-muted);
    display: none;
}

.connection-status.visible {
    display: block;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
}

.overlay-content h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.overlay-content p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.overlay-content .btn {
    width: auto;
    display: inline-block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Nickname Modal */
.nickname-modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.nickname-modal .form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.nickname-modal .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.room-code-display {
    font-family: monospace;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: bold;
}

.current-users {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.error-text {
    display: block;
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.25rem;
}

.back-link {
    display: block;
    margin-top: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--text);
}

input.error {
    border-color: var(--danger);
}

/* Password Option */
.password-option {
    margin-top: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.password-field {
    margin-top: 0.75rem;
}

.password-field input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
}

.password-field input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Password Modal */
.password-modal {
    text-align: center;
}

.protected-notice {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Confirm Modal */
.confirm-modal {
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-modal h2 {
    margin-bottom: 0.75rem;
    color: var(--text);
}

.confirm-modal p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-buttons .btn {
    flex: 1;
    max-width: 150px;
}

/* Settings Button */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--border);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--text);
}

/* Theme Modal */
.theme-modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 320px;
    width: 90%;
}

.theme-modal h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    text-align: center;
}

.theme-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.theme-option {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-option:hover {
    background: var(--border);
}

.theme-option.active {
    border-color: var(--primary);
    background: var(--bg);
}

.theme-preview {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.theme-preview-default {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.theme-preview-slack {
    background: linear-gradient(135deg, #611f69, #7c3085);
}

.theme-preview-teams {
    background: linear-gradient(135deg, #6264a7, #7b83eb);
}

.theme-preview-discord {
    background: linear-gradient(135deg, #5865f2, #7289da);
}

.theme-name {
    font-weight: 500;
    color: var(--text);
}

.theme-modal .close-btn {
    margin-top: 1rem;
    width: 100%;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .room-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .room-actions {
        width: 100%;
    }

    .room-actions .btn {
        flex: 1;
    }

    .message {
        max-width: 90%;
    }
}
