/* ==================== CSS Variables ==================== */
:root {
    --bg-color: #1a1a1a;                /* dark background */
    --text-color: #ecf0f1;               /* soft off-white */
    --border-color: #3a4a5a;              /* muted blue-gray */
    --input-bg: #2c3e50;                  /* dark slate blue */
    --panel-bg: rgba(30, 40, 50, 0.95);   /* semi-transparent dark slate */
    --admin-color: #f7c35c;                /* soft gold for admin */
    --op-tag-color: #f7c35c;               /* same gold */
    --error-color: #e67e22;                 /* softer orange-red */
    --success-color: #2ecc71;               /* soft green */
    --info-color: #3498db;                  /* calm blue */
    --system-color: #95a5a6;                 /* muted gray */
    --private-color: #5fa0b0;                 /* soft cyan */
    --mention-color: #e0a070;                  /* soft orange */
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    /* Background image – replace with your own */
    background-image: url('my-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 8px;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    /* Subtle text shadow for readability */
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

@media (min-width: 768px) {
    body { padding: 20px; }
}

#connection-status {
    padding: 6px 8px;
    margin-bottom: 8px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    font-size: 13px;
    background: rgba(0,0,0,0.7);
}

.status-connected { background-color: #2ecc71; color: #1a1a1a; }
.status-disconnected { background-color: #e67e22; color: #1a1a1a; }
.status-connecting { background-color: #f7c35c; color: #1a1a1a; }

.main-header {
    text-align: center;
    margin: 10px 0 20px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 0 0 5px rgba(236, 240, 241, 0.3), 0 0 10px rgba(236, 240, 241, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    line-height: 1.2;
}

.main-header .flag { font-size: 2.5rem; }
@media (max-width: 600px) {
    .main-header { font-size: 1.5rem; }
    .main-header .flag { font-size: 2rem; }
}

#auth-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
}

@media (max-width: 480px) {
    #auth-container { padding: 12px; }
}

.tabs { display: flex; margin-bottom: 16px; }
.tab {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    background: #2c3e50;
    color: #b0b0b0;
    cursor: pointer;
    border: 1px solid #3a4a5a;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    font-size: 16px;
    transition: background 0.2s;
}
.tab.active { background: #34495e; color: var(--text-color); border-color: var(--border-color); border-bottom: 2px solid var(--border-color); }

.form-group { margin-bottom: 12px; }
label { display: block; margin-bottom: 4px; color: var(--text-color); font-size: 14px; }
input[type="text"], input[type="password"] {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid #3a4a5a;
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 16px;
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
}
input:focus { outline: none; border-color: var(--border-color); box-shadow: 0 0 5px var(--border-color); }

button {
    background: #2c3e50;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 12px 16px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    border-radius: 4px;
    transition: background 0.2s;
    min-height: 48px;
}
button:hover { background: #34495e; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.captcha {
    background: var(--input-bg);
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 8px 0;
    text-align: center;
    font-size: 16px;
}

#help-panel {
    background: #2c3e50;
    border: 1px solid #3a4a5a;
    border-radius: 5px;
    margin-bottom: 6px;
    transition: max-height 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    #help-panel { max-height: 40vh; }
    #help-panel.collapsed { max-height: 44px; }
}
@media (max-width: 767px) {
    #help-panel { max-height: 44px; }
    #help-panel.expanded { max-height: 50vh; }
}

#help-header {
    background: #34495e;
    padding: 10px 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3a4a5a;
    flex-shrink: 0;
    min-height: 44px;
}
#help-header h3 { color: var(--text-color); margin: 0; font-size: 15px; }
#help-toggle { font-size: 18px; }
#help-content {
    padding: 8px;
    background: #2c3e50;
    overflow-y: auto;
    flex: 1;
    font-size: 13px;
}
#help-content table { width: 100%; border-collapse: collapse; font-size: 12px; }
#help-content th { text-align: left; color: var(--text-color); border-bottom: 1px solid #3a4a5a; padding: 6px 0; }
#help-content td { padding: 5px 0; color: #b0b0b0; }
#help-content .admin { color: var(--op-tag-color); }

#messages {
    flex: 1 1 auto;
    overflow-y: auto;
    border: 1px solid #3a4a5a;
    padding: 8px;
    background: #1e2a36;  /* slightly lighter than body for contrast */
    font-size: 14px;
    margin-bottom: 4px;
    border-radius: 4px;
    min-height: 80px;
    -webkit-overflow-scrolling: touch;
}

#typing-indicator {
    color: #95a5a6;
    font-style: italic;
    font-size: 12px;
    padding: 4px 8px;
    min-height: 20px;
    border-top: 1px solid #3a4a5a;
    background: var(--bg-color);
    margin-bottom: 4px;
}
#typing-indicator span { animation: pulse 1.5s infinite; }
@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Message styles – these may be overridden by inline styles in index.html,
   but we keep them for consistency if the external CSS is used alone */
.message {
    margin: 3px 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
    color: var(--text-color);
}
.message .timestamp { color: #95a5a6; }
.private { color: var(--private-color); }
.mention { color: var(--mention-color); }
.broadcast { color: var(--text-color); }
.error { color: var(--error-color); }
.success { color: var(--success-color); }
.info { color: var(--info-color); }
.system { color: var(--system-color); font-style: italic; }
.admin-nick { color: var(--admin-color); text-shadow: 0 0 5px var(--admin-color); font-weight: bold; }
.op-tag { color: var(--op-tag-color); font-size: 0.9em; margin-left: 3px; }

#input-area {
    display: flex;
    gap: 6px;
    align-items: center;
    background: var(--bg-color);
    padding: 8px 0;
    border-top: 1px solid #3a4a5a;
    flex-shrink: 0;
    position: relative;
    min-height: 60px;
}
#input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid #3a4a5a;
    color: var(--text-color);
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    border-radius: 4px;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}
#input::placeholder { color: #95a5a6; opacity: 1; }
#input:focus { outline: none; border-color: var(--border-color); }

#send {
    background: #2c3e50;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 12px 16px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    border-radius: 4px;
    min-height: 48px;
    white-space: nowrap;
}
#send:hover { background: #34495e; }

#emoji-btn {
    background: #2c3e50;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 12px 14px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    min-height: 48px;
}
#emoji-btn:hover { background: #34495e; }

#emoji-picker-container {
    position: absolute;
    bottom: 70px;
    right: 0;
    z-index: 1000;
    display: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    max-width: 90vw;
}
#emoji-picker-container.active { display: block; }

.hidden { display: none !important; }
.status { color: var(--text-color); margin-top: 8px; text-align: center; font-size: 14px; }

#chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

@media (max-width: 400px) {
    #input-area { flex-wrap: wrap; }
    #input { width: 100%; margin-bottom: 4px; }
    #send, #emoji-btn { width: 100%; }
    body { padding: 5px; }
    #messages { font-size: 13px; padding: 6px; }
    #help-content table { font-size: 11px; }
    button, .tab { font-size: 14px; }
}

#debug-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 300px;
    max-height: 200px;
    background: rgba(0,0,0,0.9);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 11px;
    overflow: auto;
    z-index: 9999;
    display: none;
    font-family: monospace;
    border-radius: 4px 0 0 0;
    box-shadow: -2px -2px 5px rgba(0,0,0,0.3);
}
#debug-content { padding: 4px; white-space: pre-wrap; word-break: break-word; }
.debug-entry { border-bottom: 1px solid #3a4a5a; padding: 2px 0; }
.debug-time { color: #95a5a6; margin-right: 4px; }
.debug-info { color: #3498db; }
.debug-error { color: #e67e22; }
.debug-warn { color: #f7c35c; }
.debug-success { color: #2ecc71; }
