/* Seocraft Project Management - Stylesheet */
/* @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:wght@300;400;500;600&display=swap'); */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');

:root {
    --gold: #c9a84c;
    --gold-light: #e2c97e;
    --gold-dim: #8b6e2e;
    --bg: #0a0d14;
    --surface: #111520;
    --surface2: #161c2a;
    --surface3: #1e2638;
    --border: #1e2d45;
    --border-light: #2a3a55;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --red: #e05252;
    --green: #4caf82;
    --blue: #4c8fe0;
    --orange: #e0904c;
    --radius: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ---- Light theme variable overrides ---- */
[data-theme="light"] {
    --bg:           #f1f5f9;
    --surface:      #ffffff;
    --surface2:     #f8fafc;
    --surface3:     #eef2f7;
    --border:       #e2e8f0;
    --border-light: #cbd5e1;
    --text:         #0f172a;
    --text-muted:   #4b5563;
    --text-dim:     #374151;
    --shadow:       0 4px 24px rgba(0,0,0,0.08);
}

/*
 * Light-mode contrast fixes
 * ─────────────────────────
 * The brand/semantic colours (--gold, --green, --blue, --orange, --red) are
 * designed for dark backgrounds and fail WCAG AA contrast on white/light-grey.
 * Rather than changing the variables (which affect backgrounds/borders too),
 * we override every rule that uses them as FOREGROUND text colour.
 *
 * Accessible dark equivalents used below:
 *   gold   #92650a  (6.1 : 1 on white)
 *   green  #166534  (7.1 : 1 on white)
 *   blue   #1e40af  (7.5 : 1 on white)
 *   orange #92400e  (7.4 : 1 on white)
 *   red    #991b1b  (7.7 : 1 on white)
 */

/* --- Sidebar --- */
[data-theme="light"] .sidebar-logo h1           { color: #92650a; }
[data-theme="light"] .sidebar-user .role-badge  { background: rgba(201,168,76,0.14); color: #92650a; }
[data-theme="light"] .nav-link                  { color: var(--text-dim); }
[data-theme="light"] .nav-link:hover            { background: var(--surface3); color: var(--text); }
[data-theme="light"] .nav-link.active           { background: rgba(146,101,10,0.09); color: #92650a; }
[data-theme="light"] .signout-link:hover        { color: #991b1b; background: rgba(153,27,27,0.07); }

/* --- Topbar --- */
[data-theme="light"] .topbar-title              { color: var(--text); }

/* --- Badges --- */
[data-theme="light"] .badge-gold                { background: rgba(146,101,10,0.1);  color: #92650a; }
[data-theme="light"] .badge-pending             { background: rgba(146,64,14,0.1);   color: #92400e; }
[data-theme="light"] .badge-review              { background: rgba(30,64,175,0.1);   color: #1e40af; }
[data-theme="light"] .badge-complete            { background: rgba(22,101,52,0.1);   color: #166534; }
[data-theme="light"] .badge-active              { background: rgba(22,101,52,0.1);   color: #166534; }
[data-theme="light"] .badge-blocked             { background: rgba(153,27,27,0.1);   color: #991b1b; }

/* --- Buttons --- */
[data-theme="light"] .btn-secondary             { background: var(--surface3); color: var(--text); border-color: var(--border-light); }
[data-theme="light"] .btn-danger                { background: rgba(153,27,27,0.08);  color: #991b1b; border-color: rgba(153,27,27,0.2); }
[data-theme="light"] .btn-danger:hover          { background: rgba(153,27,27,0.15); }
[data-theme="light"] .btn-success               { background: rgba(22,101,52,0.09);  color: #166534; border-color: rgba(22,101,52,0.2); }
[data-theme="light"] .btn-success:hover         { background: rgba(22,101,52,0.16); }

/* --- Alerts --- */
[data-theme="light"] .alert-success             { background: rgba(22,101,52,0.08);  border-color: #166534; color: #166534; }
[data-theme="light"] .alert-error               { background: rgba(153,27,27,0.08);  border-color: #991b1b; color: #991b1b; }
[data-theme="light"] .alert-info                { background: rgba(30,64,175,0.08);  border-color: #1e40af; color: #1e40af; }

/* --- Stat cards --- */
[data-theme="light"] .stat-card .value          { color: #92650a; }

/* --- Tables --- */
[data-theme="light"] tr:hover td               { background: rgba(0,0,0,0.02); }
[data-theme="light"] th                         { color: var(--text-muted); }

/* --- Forms --- */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] select,
[data-theme="light"] textarea                   { background: #ffffff; border-color: var(--border-light); color: var(--text); }
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder      { color: #9ca3af; }
[data-theme="light"] label                      { color: var(--text-muted); }

/* --- Thread --- */
[data-theme="light"] .avatar-admin             { background: rgba(146,101,10,0.12);  color: #92650a; }
[data-theme="light"] .avatar-client            { background: rgba(30,64,175,0.12);   color: #1e40af; }
[data-theme="light"] .avatar-employee          { background: rgba(22,101,52,0.12);   color: #166534; }
[data-theme="light"] .msg-author strong        { color: var(--text); }
[data-theme="light"] .role-admin               { background: rgba(146,101,10,0.1);   color: #92650a; }
[data-theme="light"] .role-client              { background: rgba(30,64,175,0.1);    color: #1e40af; }
[data-theme="light"] .role-employee            { background: rgba(22,101,52,0.1);    color: #166534; }
[data-theme="light"] .msg-text                 { background: var(--surface2); border-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
[data-theme="light"] .thread-msg.me .msg-text  { background: rgba(146,101,10,0.07);  border-color: rgba(146,101,10,0.2); }
[data-theme="light"] .msg-text a               { color: #92650a; }
[data-theme="light"] .msg-attachment           { color: var(--text-dim); border-color: var(--border); }
[data-theme="light"] .msg-attachment:hover     { color: #92650a; }

/* --- Notifications --- */
[data-theme="light"] .notif-dropdown           { box-shadow: 0 16px 48px rgba(0,0,0,0.13); }
[data-theme="light"] .notif-bell-btn:hover,
[data-theme="light"] .notif-bell-btn.open      { background: rgba(146,101,10,0.09); border-color: #92650a; color: #92650a; }
[data-theme="light"] .notif-mark-all           { color: #92650a; }
[data-theme="light"] .notif-unread-dot         { background: #92650a; }
[data-theme="light"] .notif-item.unread        { background: rgba(146,101,10,0.05); }
[data-theme="light"] .notif-item.unread:hover  { background: rgba(146,101,10,0.1); }
[data-theme="light"] .notif-avatar.av-admin    { background: rgba(146,101,10,0.12);  color: #92650a; }
[data-theme="light"] .notif-avatar.av-client   { background: rgba(30,64,175,0.12);   color: #1e40af; }
[data-theme="light"] .notif-avatar.av-employee { background: rgba(22,101,52,0.12);   color: #166534; }

/* --- Login page --- */
[data-theme="light"] .login-page               { background-image: radial-gradient(ellipse at 30% 20%, rgba(146,101,10,0.06) 0%, transparent 60%), radial-gradient(ellipse at 70% 80%, rgba(30,64,175,0.06) 0%, transparent 60%); }
[data-theme="light"] .login-logo h1            { color: #92650a; }

/* --- Misc --- */
[data-theme="light"] .text-gold                { color: #92650a; }
[data-theme="light"] .text-muted               { color: var(--text-muted); }

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

html { font-size: 15px; }

body {
    margin: 0;
    /* font-family: 'DM Sans', sans-serif; */
    font-family: "Open Sans", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
    font-family: "Open Sans", sans-serif;
    font-size: 18px;
    color: var(--gold);
    margin: 0;
    letter-spacing: 0.5px;
}

.sidebar-logo span {
    font-family: "Open Sans", sans-serif;
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.sidebar-user {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.sidebar-user .role-badge {
    display: inline-block;
    background: var(--gold-dim);
    color: var(--gold-light);
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 4px;
}

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

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

.nav-section {
    padding: 0 16px;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 9px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    display: block;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: all 0.15s;
    margin-bottom: 1px;
}

.nav-link:hover { background: var(--surface2); color: var(--text); }

.nav-link.active {
    background: rgba(201,168,76,0.12);
    color: var(--gold);
    font-weight: 500;
}

.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.signout-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius);
    transition: all 0.15s;
    width: 100%;
}

.signout-link:hover {
    color: var(--red);
    background: rgba(224,82,82,0.08);
}

.signout-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.signout-link:hover svg { opacity: 1; }

.main-content {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-family: "Open Sans", sans-serif;
    font-size: 18px;
    color: var(--text);
    font-weight: 600;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---- Theme toggle button ---- */
.theme-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: var(--surface2);
    color: var(--text-dim);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    flex-shrink: 0;
}
.theme-btn:hover {
    background: rgba(201,168,76,0.1);
    border-color: var(--gold-dim);
    color: var(--gold);
}
/* Show sun in dark mode, moon in light mode */
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }

/* ---- Notification Bell ---- */
.notif-bell-wrap {
    position: relative;
}
.notif-bell-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: var(--surface2);
    color: var(--text-dim);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    position: relative;
    flex-shrink: 0;
}
.notif-bell-btn:hover,
.notif-bell-btn.open {
    background: rgba(201,168,76,0.1);
    border-color: var(--gold-dim);
    color: var(--gold);
}
.notif-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 17px; height: 17px;
    background: #e05252;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
    line-height: 1;
    pointer-events: none;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    background: var(--surface2);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55);
    z-index: 200;
    overflow: hidden;
    display: none;
    animation: notifFadeIn 0.15s ease;
}
.notif-dropdown.open { display: block; }
@keyframes notifFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.notif-dropdown-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.notif-dropdown-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.3px;
}
.notif-mark-all {
    font-size: 11px;
    color: var(--gold);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    opacity: 0.85;
}
.notif-mark-all:hover { opacity: 1; text-decoration: underline; }
.notif-list {
    max-height: 400px;
    overflow-y: auto;
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
.notif-item {
    display: flex;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface3); }
.notif-item.unread { background: rgba(201,168,76,0.05); }
.notif-item.unread:hover { background: rgba(201,168,76,0.09); }
.notif-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}
.notif-avatar.av-admin    { background: rgba(201,168,76,0.15); color: var(--gold); }
.notif-avatar.av-client   { background: rgba(76,143,224,0.15); color: var(--blue); }
.notif-avatar.av-employee { background: rgba(76,175,130,0.15); color: var(--green); }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-text {
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 3px;
}
.notif-item-text strong { color: var(--text); font-weight: 600; }
.notif-item-task {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.notif-item-time { font-size: 11px; color: var(--text-muted); }
.notif-unread-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--gold);
    flex-shrink: 0;
    margin-top: 6px;
    align-self: flex-start;
}
.notif-empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.notif-empty svg { display: block; margin: 0 auto 10px; opacity: 0.35; }
.notif-loading {
    padding: 28px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.page-body { padding: 32px; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card-body { padding: 24px; }

/* ---- Stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
}

.stat-card .label {
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .value {
    font-family: "Open Sans", sans-serif;
    font-size: 32px;
    color: var(--gold);
    line-height: 1;
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th {
    text-align: left;
    padding: 10px 14px;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    white-space: nowrap;
}

td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.badge-pending { background: rgba(224,144,76,0.15); color: var(--orange); }
.badge-review { background: rgba(76,143,224,0.15); color: var(--blue); }
.badge-complete { background: rgba(76,175,130,0.15); color: var(--green); }
.badge-blocked { background: rgba(224,82,82,0.15); color: var(--red); }
.badge-active { background: rgba(76,175,130,0.15); color: var(--green); }
.badge-gold { background: rgba(201,168,76,0.15); color: var(--gold); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-family: "Open Sans", sans-serif;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gold);
    color: #0a0d14;
}

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

.btn-secondary {
    background: var(--surface3);
    color: var(--text);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover { background: var(--surface2); border-color: var(--gold-dim); }

.btn-danger {
    background: rgba(224,82,82,0.15);
    color: var(--red);
    border: 1px solid rgba(224,82,82,0.2);
}

.btn-danger:hover { background: rgba(224,82,82,0.25); }

.btn-success {
    background: rgba(76,175,130,0.15);
    color: var(--green);
    border: 1px solid rgba(76,175,130,0.2);
}

.btn-success:hover { background: rgba(76,175,130,0.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 14px;
    font-family: "Open Sans", sans-serif;
    font-size: 14px;
    transition: border-color 0.15s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.08);
}

textarea { resize: vertical; min-height: 90px; }
select { appearance: none; cursor: pointer; }

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

.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; }
.checkbox-item input[type="checkbox"] { width: auto; margin: 0; }
.checkbox-item label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 20px;
    border-left: 3px solid;
}

.alert-success { background: rgba(76,175,130,0.1); border-color: var(--green); color: var(--green); }
.alert-error { background: rgba(224,82,82,0.1); border-color: var(--red); color: var(--red); }
.alert-info { background: rgba(76,143,224,0.1); border-color: var(--blue); color: var(--blue); }

/* ---- Login page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image: radial-gradient(ellipse at 30% 20%, rgba(201,168,76,0.04) 0%, transparent 60%),
                      radial-gradient(ellipse at 70% 80%, rgba(76,143,224,0.04) 0%, transparent 60%);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo h1 {
    font-family: "Open Sans", sans-serif;
    font-size: 28px;
    color: var(--gold);
    margin: 0;
}

.login-logo p {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 4px 0 0;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-card h2 {
    font-size: 15px;
    margin: 0 0 24px;
    color: var(--text-dim);
    font-weight: 400;
}

/* ---- Thread ---- */
.thread-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thread-msg {
    display: flex;
    gap: 13px;
    align-items: flex-start;
    padding: 6px 0;
}

.thread-msg.me { flex-direction: row-reverse; }

/* Avatar */
.msg-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
    margin-top: 2px;
}

.avatar-client   { background: rgba(76,143,224,0.16);  color: var(--blue); }
.avatar-employee { background: rgba(76,175,130,0.16);  color: var(--green); }
.avatar-admin    { background: rgba(201,168,76,0.16);  color: var(--gold); }

/* Bubble wrapper */
.msg-bubble {
    max-width: 74%;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 160px;
}

/* Meta row: author left, time right */
.msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 3px;
}

.thread-msg.me .msg-meta { flex-direction: row-reverse; }

.msg-author {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.msg-author strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Role pill — replaces the generic badge in threads */
.msg-role-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.role-admin    { background: rgba(201,168,76,0.12);  color: var(--gold); }
.role-client   { background: rgba(76,143,224,0.12);  color: var(--blue); }
.role-employee { background: rgba(76,175,130,0.12);  color: var(--green); }

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Message body */
.msg-text {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 3px 14px 14px 14px;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.72;
    word-break: break-word;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    transition: border-color 0.15s;
}

/* Quill-rendered HTML inside messages */
.msg-text p   { margin: 0 0 0.6em; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-text ul, .msg-text ol { margin: 0.4em 0 0.4em 1.4em; padding: 0; }
.msg-text li  { margin-bottom: 0.25em; }
.msg-text strong, .msg-text b { font-weight: 600; }
.msg-text a   { color: var(--gold); }
.msg-text pre { background: var(--surface3); border-radius: 4px; padding: 10px 14px; font-size: 13px; overflow-x: auto; }

/* My messages */
.thread-msg.me .msg-text {
    background: rgba(201,168,76,0.08);
    border-color: rgba(201,168,76,0.2);
    border-radius: 14px 3px 14px 14px;
    box-shadow: 0 1px 3px rgba(201,168,76,0.07);
}

/* Attachment link inside thread */
.msg-attachment {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.15s;
}

.msg-attachment svg { flex-shrink: 0; opacity: 0.7; }
.msg-attachment:hover { color: var(--gold); }
.msg-attachment:hover svg { opacity: 1; }

/* Status / system event divider */
.status-event {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    font-size: 11.5px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

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


/* ---- Search / Filter Bar ---- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 340px;
}

.search-wrap .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.search-wrap input[type="text"] {
    width: 100%;
    height: 36px;
    padding: 0 34px 0 34px;
    font-size: 13.5px;
}

.search-clear {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}

.search-clear:hover { color: var(--text); background: var(--surface3); }

.filter-select {
    height: 36px;
    padding: 0 36px 0 12px;
    font-size: 13.5px;
    width: auto;
    min-width: 155px;
}

.filter-bar-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: auto;
}

/* ---- Misc ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-family: "Open Sans", sans-serif;
    font-size: 22px;
    margin: 0;
    color: var(--text);
}

.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .form-row, .form-row-3, .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page-body { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
