:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --danger: #ef4444;
    --input-bg: #334155;
    --border: #475569;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Authentication */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

input,
textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: white;
    box-sizing: border-box;
}

input:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

button {
    background: var(--accent);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    width: 100%;
}

button:hover {
    background: var(--accent-hover);
}

button.secondary {
    background: var(--input-bg);
    color: var(--text-secondary);
}

button.danger {
    background: var(--danger);
}

/* Dashboard */
.dashboard {
    display: none;
    /* Hidden by default */
}

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.instance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.instance-card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    position: relative;
    transition: transform 0.2s;
}

.instance-card:hover {
    transform: translateY(-2px);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.status-connected,
.status-open {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.status-connecting {
    background: rgba(234, 179, 8, 0.2);
    color: #facc15;
}

.status-scanned_needed {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.status-disconnected {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.qr-code {
    background: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    text-align: center;
}

.qr-code img {
    max-width: 100%;
    height: auto;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
}

.hidden {
    display: none !important;
}

/* History List */
.history-list {
    max-height: 400px;
    overflow-y: auto;
    background: #f0f2f5;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.chat-msg.sent {
    align-self: flex-end;
    background: #d9fdd3;
    color: #111b21;
}

.chat-msg.received {
    align-self: flex-start;
    background: #ffffff;
    color: #111b21;
}

.chat-msg .time {
    font-size: 0.7rem;
    color: #667781;
    margin-top: 0.25rem;
    text-align: right;
}

.chat-msg .sender {
    font-weight: bold;
    font-size: 0.75rem;
    color: #128c7e;
    margin-bottom: 0.25rem;
    display: block;
}
.chat-pill {
    background: #e1f5fe;
    color: #01579b;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid #b3e5fc;
    transition: all 0.2s;
    font-weight: 500;
}

.chat-pill:hover {
    background: #0084ff;
    color: white;
    border-color: #0084ff;
}
