/* ============================================================
   Rooms Platform — global styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

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

:root {
    --bg:          #f4f6fb;
    --surface:     #ffffff;
    --sidebar-bg:  #1a2035;
    --sidebar-txt: #a8b4d0;
    --sidebar-act: #ffffff;
    --sidebar-hi:  #2a3450;
    --accent:      #4f7cff;
    --accent-h:    #3a65e8;
    --danger:      #e53e3e;
    --warn:        #dd6b20;
    --success:     #38a169;
    --txt:         #1a202c;
    --txt-muted:   #718096;
    --border:      #e2e8f0;
    --shadow:      0 1px 4px rgba(0,0,0,.08);
    --shadow-md:   0 4px 12px rgba(0,0,0,.12);
    --radius:      8px;
    --radius-lg:   12px;
    --sidebar-w:   240px;
    --font:        'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; font-family: var(--font); color: var(--txt); background: var(--bg); font-size: 14px; }

/* ── Layout ─────────────────────────────────────────────── */

.wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px;
    max-width: 1200px;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar-logo {
    padding: 24px 20px 16px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo span { color: var(--accent); }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(168,180,208,.5);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--sidebar-txt);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: background .15s, color .15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: var(--sidebar-hi); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 13px;
    color: var(--sidebar-txt);
}
.sidebar-footer .user-name { font-weight: 500; color: #fff; }

/* ── Page header ─────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}
.page-title { font-size: 22px; font-weight: 600; }
.page-subtitle { font-size: 13px; color: var(--txt-muted); margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--txt);
}

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent); line-height: 1; margin-bottom: 4px; }
.stat-value.danger { color: var(--danger); }
.stat-label { font-size: 13px; color: var(--txt-muted); font-weight: 400; }

/* ── Tables ──────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--txt-muted);
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8faff; }
.td-mono { font-family: 'Courier New', monospace; font-size: 12px; }

/* ── Badges / chips ──────────────────────────────────────── */

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.chip-blue   { background: #ebf0ff; color: var(--accent); }
.chip-green  { background: #f0fff4; color: var(--success); }
.chip-orange { background: #fff5eb; color: var(--warn); }
.chip-red    { background: #fff5f5; color: var(--danger); }
.chip-gray   { background: #edf2f7; color: var(--txt-muted); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    font-family: var(--font);
    text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--accent-h); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #c53030; }
.btn-ghost    { background: transparent; color: var(--txt-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)    { background: var(--bg); color: var(--txt); }
.btn-sm       { padding: 5px 11px; font-size: 12px; }
.btn-icon     { padding: 7px; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-hint  { font-size: 12px; color: var(--txt-muted); margin-top: 4px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    color: var(--txt);
    background: #fff;
    transition: border .15s, box-shadow .15s;
    outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,124,255,.15); }
.form-control.error { border-color: var(--danger); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }
.field-error.visible { display: block; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Notifications ───────────────────────────────────────── */

.notif-wrap {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
}
.notif {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 12px 16px;
    font-size: 13px;
    border-left: 4px solid var(--success);
    animation: slide-in .2s ease;
}
.notif.error  { border-left-color: var(--danger); }
.notif.warn   { border-left-color: var(--warn); }

@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Auth pages (login / register) ──────────────────────── */

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.auth-logo { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.auth-logo span { color: var(--accent); }
.auth-tagline { font-size: 13px; color: var(--txt-muted); margin-bottom: 32px; }
.auth-footer  { text-align: center; font-size: 13px; color: var(--txt-muted); margin-top: 20px; }
.auth-footer a { color: var(--accent); text-decoration: none; }

/* ── Message thread ──────────────────────────────────────── */

.room-layout { display: grid; grid-template-columns: 1fr 240px; gap: 24px; align-items: start; }

.thread-wrap {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
}

.thread-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.thread-title { font-weight: 600; font-size: 15px; }
.thread-purpose { font-size: 12px; color: var(--txt-muted); margin-top: 2px; }

.thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--txt-muted);
}
.msg-author { font-weight: 500; color: var(--txt); }
.msg-time   { font-size: 11px; }

.msg-bubble {
    background: var(--bg);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 700px;
    word-break: break-word;
    white-space: pre-wrap;
}
.msg-bubble.human-msg {
    background: #ebf0ff;
    border-radius: var(--radius) 0 var(--radius) var(--radius);
}
.msg-bubble.flag-open {
    border-left: 3px solid var(--danger);
    background: #fff5f5;
}
.msg-bubble.flag-resolved {
    border-left: 3px solid var(--success);
    opacity: .75;
}

.msg-flag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: #fed7d7;
    color: var(--danger);
}
.msg-flag-badge.resolved { background: #c6f6d5; color: var(--success); }

.msg-reply-ctx {
    font-size: 12px;
    color: var(--txt-muted);
    padding: 6px 10px;
    border-left: 3px solid var(--border);
    margin-bottom: 4px;
    font-style: italic;
}

.msg-actions {
    display: none;
    gap: 6px;
    margin-top: 2px;
}
.msg-item:hover .msg-actions { display: flex; }

.msg-read-status {
    font-size: 11px;
    color: var(--txt-muted);
    margin-top: 2px;
}

.thread-compose {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.compose-reply-ctx {
    display: none;
    font-size: 12px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
    color: var(--txt-muted);
    align-items: center;
    justify-content: space-between;
}
.compose-reply-ctx.visible { display: flex; }
.compose-row { display: flex; gap: 10px; align-items: flex-end; }
.compose-area { flex: 1; }
.compose-opts { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.compose-flag { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--danger); cursor: pointer; }

/* ── Members panel ───────────────────────────────────────── */

.members-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px;
    position: sticky;
    top: 32px;
}
.members-title { font-weight: 600; font-size: 13px; margin-bottom: 12px; color: var(--txt-muted); text-transform: uppercase; letter-spacing: .06em; }
.member-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.member-item:last-child { border-bottom: none; }
.member-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.member-name  { font-size: 13px; font-weight: 500; }
.member-role  { font-size: 11px; color: var(--txt-muted); }

/* ── Invite code display ─────────────────────────────────── */

.invite-code-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}
.invite-code-box .code { flex: 1; font-weight: 600; letter-spacing: .05em; }

/* ── Empty state ─────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--txt-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Loading spinner ─────────────────────────────────────── */

.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { display: flex; justify-content: center; padding: 32px; }

/* ── Misc ────────────────────────────────────────────────── */

.text-muted  { color: var(--txt-muted); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16{ margin-top: 16px; }
.flex { display: flex; }
.gap-8{ gap: 8px; }
.items-center { align-items: center; }
.ml-auto { margin-left: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .main-content { margin-left: 0; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .room-layout { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
