﻿/* =========================================================
   COMMS PORTAL
   Modern SaaS / Relay-inspired UI
   Responsive rebuild
   ========================================================= */

:root {
    --bg: #f1eefb;
    --surface: #ffffff;
    --surface-soft: #faf9ff;
    --border: #e5e1f5;
    --border-dark: #d5cff0;
    --text: #1b1730;
    --text-soft: #6b6485;
    --text-muted: #9a93b3;
    --primary: #7c5cff;
    --primary-dark: #5c37e6;
    --primary-light: #9c82ff;
    --primary-soft: #efe9ff;
    --danger: #e63946;
    --danger-soft: #fff0f1;
    --success: #2fb783;
    --warning: #e8a33d;
    /* Sidebar is the signature element: deep indigo instead of
       another white panel, so the app doesn't read as one flat
       white surface. */
    --sidebar: #1c1735;
    --sidebar-soft: #262046;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: #b6aed9;
    --sidebar-text-dim: #7d759e;
    --sidebar-text-active: #ffffff;
    --radius-sm: 7px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(28, 20, 60, 0.07);
    --shadow: 0 8px 24px rgba(28, 20, 60, 0.12);
    --gradient-primary: linear-gradient(135deg, #8a68ff 0%, #6a3ff0 100%);
    /* Layout tokens used by the responsive rules below */
    --sidebar-w: 230px;
    --topbar-h: 70px;
    --content-pad-x: 28px;
    --content-pad-y: 24px;
}


/* =========================================================
   RESET
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg {
    max-width: 100%;
}

/* Keyboard accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.nav-link:focus-visible,
.inbox-item:focus-visible,
.conversation-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
/* Skip navigation link
   Hidden until keyboard focus */
.skip-link {
    position: absolute;
    left: 16px;
    top: -100px;
    z-index: 9999;
    padding: 10px 16px;
    background: #111827;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.15s ease;
}

    .skip-link:focus,
    .skip-link:focus-visible {
        top: 16px;
    }

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}


/* =========================================================
   UTILITIES
   ========================================================= */

.hidden {
    display: none !important;
}

.muted {
    color: var(--text-muted);
}

.sub {
    color: var(--text-soft);
    margin-top: -5px;
}

.error {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--danger-soft);
    border: 1px solid #ffd4d7;
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
}


/* =========================================================
   LOGIN
   ========================================================= */

.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 5vw, 24px);
    background: radial-gradient(circle at 15% 10%, rgba(124, 92, 255, .16) 0, transparent 40%), radial-gradient(circle at 85% 90%, rgba(90, 55, 230, .12) 0, transparent 40%), var(--sidebar);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: clamp(22px, 6vw, 34px);
    box-shadow: 0 24px 60px rgba(12, 8, 35, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

    .login-brand .brand-mark {
        width: 40px;
        height: 40px;
        min-width: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: var(--gradient-primary);
        color: #fff;
        font-size: 18px;
        box-shadow: 0 4px 12px rgba(90, 55, 230, .35);
    }

    .login-brand h1 {
        margin: 0;
        font-size: 16px;
        font-weight: 750;
    }

    .login-brand p {
        margin: 2px 0 0;
        color: var(--text-soft);
        font-size: 12px;
    }

.login-heading h2 {
    margin: 0 0 6px;
    font-size: clamp(20px, 5vw, 24px);
    font-weight: 750;
    letter-spacing: -0.4px;
}

.login-heading p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
}

.login-card label {
    display: block;
    margin-top: 20px;
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
}

.login-card input {
    width: 100%;
    margin-top: 7px;
    padding: 11px 13px;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    /* 16px min prevents iOS Safari auto-zoom on focus */
    font-size: max(14px, 16px);
}

    .login-card input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(109, 74, 255, .12);
    }

.login-card .btn {
    margin-top: 26px;
}

@media (max-width: 420px) {
    .login-card {
        border-radius: 12px;
        box-shadow: none;
        border-color: transparent;
    }
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    border: 0;
    border-radius: 8px;
    min-height: 40px; /* comfortable touch target */
    padding: 8px 15px;
    font-weight: 650;
    font-size: 13px;
    transition: background .15s, transform .05s, box-shadow .15s;
}

    .btn:active {
        transform: translateY(1px);
    }

    .btn:disabled {
        opacity: .45;
        cursor: not-allowed;
    }

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(90, 55, 230, .28);
}

    .btn-primary:hover {
        background: linear-gradient(135deg, #9376ff 0%, #6a3ff0 100%);
        box-shadow: 0 6px 16px rgba(90, 55, 230, .36);
    }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(230, 57, 70, .28);
}

    .btn-danger:hover {
        background: var(--danger);
        color: #fff;
        border-color: var(--danger);
        box-shadow: 0 3px 8px rgba(230, 57, 70, .25);
    }

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
    border: 1px solid var(--border);
}

    .btn-ghost:hover {
        background: var(--surface-soft);
        color: var(--text);
    }

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 32px;
    padding: 6px 11px;
    font-size: 12px;
}


/* =========================================================
   APP SHELL
   ========================================================= */

.shell {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    overflow: hidden;
    background: var(--bg);
}

/* Backdrop used behind the sidebar when it opens as a drawer on
   small screens. Present in markup, toggled by the small inline
   script added to index.html. */
.sidebar-backdrop {
    display: none;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    padding: 22px 12px 14px;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 10px;
    margin-bottom: 6px;
}

    .sidebar-brand .brand-mark {
        width: 34px;
        height: 34px;
        min-width: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 9px;
        background: var(--gradient-primary);
        color: #fff;
        font-size: 16px;
        box-shadow: 0 3px 10px rgba(90, 55, 230, .4);
    }

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

    .brand-text strong {
        font-size: 15px;
        font-weight: 750;
        color: var(--sidebar-text-active);
        letter-spacing: -0.2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .brand-text span {
        margin-top: 1px;
        font-size: 11px;
        color: var(--sidebar-text-dim);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.sidebar-section {
    margin-top: 22px;
}

.sidebar-section-title {
    padding: 0 12px;
    margin-bottom: 6px;
    color: var(--sidebar-text-dim);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .6px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-spacer {
    flex: 1;
}

.sidebar-bottom-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--sidebar-border);
}

.nav-link {
    position: relative;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 12px;
    border-radius: 9px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 600;
    transition: background .15s, color .15s;
}

.nav-icon {
    width: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--sidebar-soft);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(90, 55, 230, .35);
}

.nav-link.disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}

.nav-badge {
    margin-left: auto;
    flex: none;
    padding: 2px 7px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
}

    .nav-badge.soon {
        background: var(--sidebar-soft);
        color: var(--sidebar-text-dim);
        border: 1px solid var(--sidebar-border);
    }


/* =========================================================
   SIDEBAR FOOTER
   ========================================================= */

.sidebar-footer {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--sidebar-border);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 12px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--sidebar-soft);
    color: var(--primary-light);
    font-weight: 750;
    font-size: 13px;
    border: 1px solid var(--sidebar-border);
}

.user-info {
    min-width: 0;
    flex: 1;
}

.whoami {
    color: var(--sidebar-text-active);
    font-size: 12.5px;
    font-weight: 650;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    display: block;
    margin-top: 2px;
    color: #6ee0ac;
    font-size: 11px;
}

.logout-btn {
    justify-content: center;
    gap: 8px;
    background: var(--sidebar-soft);
    color: var(--sidebar-text);
    border-color: var(--sidebar-border);
}

    .logout-btn:hover {
        background: rgba(230, 57, 70, .16);
        color: #ff8a93;
        border-color: rgba(230, 57, 70, .3);
    }


/* =========================================================
   MAIN
   ========================================================= */

.main {
    min-width: 0;
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


/* =========================================================
   TOP BAR
   ========================================================= */

.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 var(--content-pad-x);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

#page-title {
    margin: 0;
    font-size: clamp(17px, 2.4vw, 22px);
    font-weight: 750;
    letter-spacing: -0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-subtitle {
    margin: 2px 0 0;
    color: var(--text-soft);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 17px;
    flex: none;
}

    .mobile-menu-btn:hover {
        background: var(--surface-soft);
    }

.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 16px;
}

    .icon-btn:hover {
        background: var(--surface-soft);
        color: var(--primary);
    }


/* =========================================================
   CONTENT
   ========================================================= */

.content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: var(--content-pad-y) var(--content-pad-x);
}


/* =========================================================
   TOOLBAR
   ========================================================= */

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

    .toolbar input[type="search"] {
        width: 320px;
        max-width: 100%;
        height: 40px;
        padding: 0 13px;
        background: var(--surface);
        border: 1px solid var(--border-dark);
        border-radius: 8px;
        outline: none;
        color: var(--text);
        font-size: max(13px, 16px);
        transition: border-color .15s, box-shadow .15s;
    }

        .toolbar input[type="search"]:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(109, 74, 255, .10);
        }

    .toolbar .btn {
        margin-left: auto;
    }


/* =========================================================
   TABLE
   ========================================================= */

/* Tables scroll horizontally on narrow viewports instead of
   crushing their columns illegibly. */
.table-scroll,
#ct-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

    .content > table,
    #ct-table table,
    .table-scroll table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        overflow: hidden;
        box-shadow: var(--shadow-sm);
    }

table th {
    height: 46px;
    padding: 0 16px;
    text-align: left;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .5px;
    white-space: nowrap;
}

table td {
    padding: 15px 16px;
    border-bottom: 1px solid #f0eefb;
    color: var(--text);
    font-size: 13px;
    vertical-align: middle;
}

    /* First column (typically the name) carries more weight so a row
   reads as a person, not just a line of data. */
    table td:first-child {
        font-weight: 650;
        color: var(--text);
    }

table tbody tr:nth-child(even) {
    background: #fbfaff;
}

table tbody tr:last-child td {
    border-bottom: 0;
}

table tbody tr:hover {
    background: var(--primary-soft);
}

/* Row actions (e.g. Delete) stay quiet until the row is actually
   in focus, so a long list doesn't read as a wall of buttons. */
table td:last-child {
    text-align: right;
}

    table td:last-child .btn {
        opacity: .75;
        transition: opacity .15s, background .15s, color .15s;
    }

table tbody tr:hover td:last-child .btn {
    opacity: 1;
}

@media (max-width: 700px) {
    .content > table,
    #ct-table table,
    .table-scroll table {
        min-width: 620px; /* keeps columns readable; wrapper scrolls */
    }
}


/* =========================================================
   PAGER
   ========================================================= */

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
    color: var(--text-soft);
    font-size: 13px;
    flex-wrap: wrap;
}

    .pager .btn {
        min-width: 76px;
    }


/* =========================================================
   BADGES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
}


/* =========================================================
   SCROLLBARS
   ========================================================= */

* {
    scrollbar-width: thin;
    scrollbar-color: #d4d7df transparent;
}

    *::-webkit-scrollbar {
        width: 7px;
        height: 7px;
    }

    *::-webkit-scrollbar-track {
        background: transparent;
    }

    *::-webkit-scrollbar-thumb {
        background: #d4d7df;
        border-radius: 20px;
    }

        *::-webkit-scrollbar-thumb:hover {
            background: #b9bdc8;
        }


/* =========================================================
   INBOX — 3 PANEL DESIGN
   ========================================================= */

.inbox-layout {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: 320px minmax(420px, 1fr) 280px;
    grid-template-rows: minmax(0, 1fr); /* stops the row auto-growing to
                                            fit message content */
    background: #fff;
    border: 1px solid #e7e9f0;
    border-radius: 14px;
    overflow: hidden;
}

/* Left — conversations */

.inbox-sidebar {
    min-width: 0;
    min-height: 0; /* grid items default to min-height:auto, which lets
                       content push past the row — this lets .inbox-list
                       scroll internally instead */
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e7e9f0;
}

.inbox-sidebar-header {
    padding: 22px 18px 16px;
    border-bottom: 1px solid #eceef3;
}

.inbox-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .inbox-title-row h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
        color: #172033;
    }

.inbox-subtitle {
    display: block;
    margin-top: 5px;
    color: #969cac;
    font-size: 12px;
}

.inbox-search-wrap {
    position: relative;
    margin-top: 18px;
}

    .inbox-search-wrap .search-icon {
        position: absolute;
        left: 13px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 13px;
        opacity: .55;
        pointer-events: none;
    }

.inbox-search {
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 13px 0 38px;
    border: 1px solid #e2e4eb;
    border-radius: 9px;
    background: #fafafd;
    color: #202638;
    outline: none;
    font-size: max(13px, 16px);
}

    .inbox-search:focus {
        background: #fff;
        border-color: #7656df;
        box-shadow: 0 0 0 3px rgba(118, 86, 223, .08);
    }

.inbox-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 7px;
}

.inbox-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 10px;
    margin-bottom: 2px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s ease;
}

    .inbox-item:hover {
        background: #f7f5ff;
    }

    .inbox-item.active {
        background: #eeeaff;
    }

.inbox-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e9e2ff;
    color: #6847d7;
    font-size: 12px;
    font-weight: 700;
}

/* Cycle avatar colors across the list instead of repeating the
   same purple chip for every contact. */
.inbox-item:nth-child(6n+2) .inbox-avatar {
    background: #d9f2ec;
    color: #0f8f7f;
}

.inbox-item:nth-child(6n+3) .inbox-avatar {
    background: #ffedd1;
    color: #b9790c;
}

.inbox-item:nth-child(6n+4) .inbox-avatar {
    background: #ffe0e6;
    color: #c92a4f;
}

.inbox-item:nth-child(6n+5) .inbox-avatar {
    background: #d9ecff;
    color: #1866c2;
}

.inbox-item:nth-child(6n+0) .inbox-avatar {
    background: #ddf5e2;
    color: #29873f;
}

.inbox-item-content {
    min-width: 0;
    flex: 1;
}

.inbox-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

    .inbox-item-top strong {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #202638;
        font-size: 13px;
    }

.inbox-item-time {
    flex-shrink: 0;
    color: #9a9fad;
    font-size: 10px;
}

.inbox-item-bottom {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 5px;
}

.inbox-preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #858b9a;
    font-size: 11px;
}

.inbox-unread {
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #7052df;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.inbox-loading,
.inbox-empty-list {
    padding: 40px 20px;
    text-align: center;
    color: #999fac;
    font-size: 12px;
}

    .inbox-empty-list .empty-icon {
        font-size: 28px;
        margin-bottom: 10px;
    }

    .inbox-empty-list strong,
    .inbox-empty-list span {
        display: block;
    }

    .inbox-empty-list span {
        margin-top: 5px;
        font-size: 11px;
    }


/* Center — chat */

.chat-panel {
    min-width: 0;
    min-height: 0; /* critical: without this the grid row grows to fit
                       every message instead of scrolling, and shoves
                       the composer below the visible area */
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fbfbfd;
    overflow: hidden;
}

.chat-header {
    flex-shrink: 0;
    height: 76px;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: #fff;
    border-bottom: 1px solid #e8e9ef;
    gap: 10px;
}

.chat-contact {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e8e1ff;
    color: #6847d7;
    font-size: 12px;
    font-weight: 700;
}

.chat-contact-name {
    color: #202638;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-contact-phone {
    margin-top: 4px;
    color: #9298a7;
    font-size: 11px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
    flex: none;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 25px 25px;
}

.older-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.message-row {
    display: flex;
    margin-bottom: 10px;
}

    .message-row.incoming {
        justify-content: flex-start;
    }

    .message-row.outgoing {
        justify-content: flex-end;
    }

.message-content {
    max-width: min(72%, 560px);
}

.bubble {
    padding: 11px 14px 8px;
    border-radius: 15px;
    background: #fdfcff;
    border: 1px solid #e7e2f5;
    box-shadow: 0 2px 8px rgba(43, 20, 90, .04);
}

.outgoing .bubble {
    background: var(--gradient-primary);
    border-color: transparent;
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 3px 10px rgba(90, 55, 230, .25);
}

.incoming .bubble {
    border-bottom-left-radius: 5px;
}

.message-body {
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    color: #a1a5b1;
    font-size: 9px;
}

.outgoing .message-meta {
    color: rgba(255,255,255,.7);
}

.ticks {
    font-size: 11px;
}

    .ticks.read {
        color: #c9f5df;
    }

    .ticks.failed {
        color: #ffb4b4;
    }

    .ticks.pending {
        opacity: .7;
    }

.no-messages {
    height: 100%;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #969cab;
    text-align: center;
    padding: 0 20px;
}

.no-messages-icon {
    font-size: 34px;
    margin-bottom: 12px;
}

.no-messages strong {
    color: #555c6c;
    font-size: 14px;
}

.no-messages span {
    margin-top: 5px;
    font-size: 11px;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    color: #949aa9;
    padding: 30px;
}

.chat-empty-icon {
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    border-radius: 50%;
    background: #eeeaff;
    font-size: 27px;
}

.chat-empty h3 {
    margin: 0;
    color: #555b6a;
    font-size: 15px;
}

.chat-empty p {
    max-width: 260px;
    margin: 7px 0 0;
    line-height: 1.5;
    font-size: 11px;
}


/* Composer */

.chat-form {
    flex-shrink: 0;
    padding: 13px 18px 16px;
    background: #fff;
    border-top: 1px solid #e8e9ef;
}

.composer {
    display: flex;
    align-items: center;
    gap: 9px;
}

    .composer input {
        flex: 1;
        width: auto;
        height: 42px;
        margin: 0;
        padding: 0 14px;
        border: 1px solid #dfe2ea;
        border-radius: 10px;
        background: #fafafd;
        font-size: max(13px, 16px);
    }

.send-btn {
    width: 42px;
    height: 42px;
    min-height: 42px;
    flex: none;
    border: 0;
    border-radius: 10px;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 17px;
    box-shadow: 0 3px 10px rgba(90, 55, 230, .3);
}

    .send-btn:hover {
        background: linear-gradient(135deg, #9376ff 0%, #6a3ff0 100%);
    }

.composer-hint {
    margin-top: 6px;
    color: #a1a5b1;
    font-size: 9px;
}


/* Right — contact details */

.inbox-details {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    background: #fff;
    border-left: 1px solid #e7e9f0;
}

.details-header {
    padding: 28px 20px 24px;
    text-align: center;
    border-bottom: 1px solid #eceef3;
}

.details-avatar {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: #e9e2ff;
    color: #6847d7;
    font-size: 17px;
    font-weight: 700;
}

.details-header h3 {
    margin: 0;
    color: #202638;
    font-size: 15px;
}

.details-phone {
    margin-top: 5px;
    color: #969cab;
    font-size: 11px;
}

.details-section {
    padding: 18px 18px;
    border-bottom: 1px solid #eceef3;
}

.details-section-title {
    margin-bottom: 13px;
    color: #858b9a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .7px;
}

.details-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
}

.details-label {
    color: #969cab;
    font-size: 11px;
}

.details-value {
    max-width: 150px;
    color: #42495a;
    font-size: 11px;
    text-align: right;
    word-break: break-word;
}

.contact-status {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #596172;
    font-size: 11px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #45c58b;
}

.details-empty {
    height: 100%;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #a0a5b2;
    font-size: 11px;
}

.details-empty-icon {
    margin-bottom: 10px;
    font-size: 28px;
}

/* Back button used inside the chat header on mobile, to return
   to the conversation list. Hidden above the 760px breakpoint. */
.chat-back-btn {
    display: none;
}

.inbox-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.inbox-details::-webkit-scrollbar {
    width: 6px;
}

.inbox-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.inbox-details::-webkit-scrollbar-thumb {
    background: #dfe1e8;
    border-radius: 10px;
}


/* =========================================================
   RESPONSIVE
   Breakpoints: 1100 (drop inbox detail pane) · 900 (collapse
   sidebar to icon rail) · 760 (inbox becomes single pane,
   stacked navigation) · 600 (sidebar becomes an off-canvas
   drawer) · 420 (tight phones)
   ========================================================= */

@media (max-width: 1100px) {

    .inbox-layout {
        grid-template-columns: 280px minmax(340px, 1fr);
    }

    .inbox-details {
        display: none;
    }
}


@media (max-width: 900px) {

    :root {
        --sidebar-w: 76px;
        --content-pad-x: 20px;
    }

    .sidebar {
        align-items: center;
        padding-left: 8px;
        padding-right: 8px;
    }

    .sidebar-brand {
        justify-content: center;
        padding: 0;
    }

    .brand-text,
    .sidebar-section-title,
    .nav-label,
    .nav-badge,
    .user-info,
    .logout-btn span:last-child {
        display: none;
    }

    .nav-link {
        justify-content: center;
        padding: 0;
    }

    .user-card {
        justify-content: center;
        padding: 6px 0 12px;
    }

    .logout-btn {
        min-width: 0;
        width: 42px;
        height: 42px;
        min-height: 42px;
        padding: 0;
        margin: 0 auto;
    }

    .toolbar input[type="search"] {
        width: 100%;
    }
}


@media (max-width: 760px) {

    .topbar {
        padding: 0 var(--content-pad-x);
    }

    .mobile-menu-btn {
        display: flex;
    }

    /* Sidebar becomes an off-canvas drawer at full width/icons
       hidden by default; opened via .shell.sidebar-open */
    :root {
        --sidebar-w: 240px;
    }

    .sidebar {
        position: fixed;
        z-index: 40;
        top: 0;
        left: 0;
        bottom: 0;
        align-items: stretch;
        padding: 22px 12px 14px;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow);
    }

    .brand-text,
    .sidebar-section-title,
    .nav-label,
    .nav-badge,
    .user-info,
    .logout-btn span:last-child {
        display: initial;
    }

    .sidebar-brand {
        justify-content: flex-start;
    }

    .nav-link {
        justify-content: flex-start;
        padding: 0 12px;
    }

    .user-card {
        justify-content: flex-start;
    }

    .logout-btn {
        width: 100%;
        padding: 8px 15px;
    }

    .shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .shell.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(15, 18, 30, .38);
    }

    .content {
        padding: 18px var(--content-pad-x);
    }

    /* Inbox collapses to a single pane; JS toggles
       .inbox-layout.chat-open to switch between list and chat */
    .inbox-layout {
        display: block;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        margin: calc(var(--content-pad-y) * -1) calc(var(--content-pad-x) * -1);
        width: calc(100% + var(--content-pad-x) * 2);
        height: calc(100% + var(--content-pad-y) * 2);
    }

    .inbox-sidebar {
        height: 100%;
        border-right: 0;
    }

    .chat-panel {
        display: none;
    }

    .chat-back-btn {
        display: flex;
    }

    .inbox-layout.chat-open .inbox-sidebar {
        display: none;
    }

    .inbox-layout.chat-open .chat-panel {
        display: flex;
        height: 100%;
    }

    .message-content {
        max-width: 85%;
    }
}


@media (max-width: 600px) {

    :root {
        --content-pad-x: 16px;
        --content-pad-y: 16px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

        .toolbar .btn {
            width: 100%;
            margin-left: 0;
        }

    .chat-header {
        padding: 0 14px;
    }

    .chat-messages {
        padding: 14px 14px 18px;
    }

    .chat-form {
        padding: 10px 12px 12px;
    }

    .details-value {
        max-width: 110px;
    }
}


@media (max-width: 420px) {

    .topbar h1#page-title {
        font-size: 17px;
    }

    .chat-contact-name {
        font-size: 14px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
        min-height: 38px;
    }
}
/* Email page */
.email-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
}

.email-tab {
    padding: 10px 18px;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font-weight: 600;
    font-size: 13px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
}

    .email-tab:hover {
        background: var(--surface-soft);
        color: var(--text);
    }

    .email-tab.active {
        background: var(--primary-soft);
        color: var(--primary);
    }

.email-compose label {
    display: block;
    margin: 16px 0 6px;
    font-weight: 600;
    font-size: 13px;
}

.email-compose textarea,
.email-compose input[type="text"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    outline: none;
}

    .email-compose textarea:focus,
    .email-compose input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(109,74,255,.10);
    }

.compose-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.badge.sent {
    background: #ddf5e2;
    color: #29873f;
}

.badge.queued {
    background: #fff3cd;
    color: #856404;
}

.badge.failed {
    background: #fff0f1;
    color: #c62828;
}

.email-account-modal {
    max-width: 520px;
}

    .email-account-modal h3 {
        color: var(--text);
        font-size: 18px;
    }

    .email-account-modal .compose-row {
        margin-bottom: 16px;
    }

        .email-account-modal .compose-row:last-child {
            margin-bottom: 0;
        }

    .email-account-modal input[type="password"] {
        width: 100%;
        margin-top: 6px;
        padding: 10px 12px;
        border: 1px solid var(--border-dark);
        border-radius: 8px;
        background: #fff;
        font-size: 14px;
        outline: none;
        transition: border-color .15s, box-shadow .15s;
    }

        .email-account-modal input[type="password"]:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(109, 74, 255, .10);
        }
/* --- Gmail Account Modal --- */
.email-account-modal {
    max-width: 520px;
}

    .email-account-modal h3 {
        margin: 0;
        color: var(--text);
        font-size: 18px;
    }

    .email-account-modal .compose-row {
        margin-bottom: 16px;
    }

        .email-account-modal .compose-row:last-child {
            margin-bottom: 0;
        }

    .email-account-modal input[type="text"],
    .email-account-modal input[type="email"],
    .email-account-modal input[type="password"],
    .email-account-modal input[type="number"] {
        width: 100%;
        margin-top: 6px;
        padding: 10px 12px;
        border: 1px solid var(--border-dark);
        border-radius: 8px;
        background: #fff;
        color: var(--text);
        font-size: 14px;
        outline: none;
        transition: border-color .15s, box-shadow .15s;
        box-sizing: border-box;
    }

        .email-account-modal input[type="text"]:focus,
        .email-account-modal input[type="email"]:focus,
        .email-account-modal input[type="password"]:focus,
        .email-account-modal input[type="number"]:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(109, 74, 255, .10);
        }

    .email-account-modal input::placeholder {
        color: var(--text-muted);
    }

    .email-account-modal .sub {
        font-weight: 400;
        color: var(--text-muted);
    }

    .email-account-modal .modal-error {
        margin-top: 8px;
        padding: 10px 12px;
        border-radius: 8px;
        background: #fff0f1;
        color: #c62828;
        font-size: 13px;
    }

        .email-account-modal .modal-error.hidden {
            display: none;
        }

/* Gmail Add Account Modal */
.email-account-modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-sizing: border-box;
}

    .email-account-modal label {
        display: block;
        font-size: 13px;
        font-weight: 600;
        color: var(--text);
        margin-top: 16px;
    }

    .email-account-modal input[type="text"],
    .email-account-modal input[type="email"],
    .email-account-modal input[type="password"],
    .email-account-modal input[type="number"] {
        box-sizing: border-box;
        width: 100%;
        display: block;
    }


/* =========================================================
   INBOX CHAT MESSAGE LAYOUT FIX
   ========================================================= */

.chat-messages {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

    /* Each message gets its own full-width row */
    .chat-messages .message-row {
        display: flex !important;
        width: 100% !important;
        flex: 0 0 auto !important;
        box-sizing: border-box !important;
    }

        /* Incoming messages on left */
        .chat-messages .message-row.incoming {
            justify-content: flex-start !important;
        }

        /* Outgoing messages on right */
        .chat-messages .message-row.outgoing {
            justify-content: flex-end !important;
        }

    /* Message content must not shrink to tiny width */
    .chat-messages .message-content {
        display: flex !important;
        max-width: 75% !important;
        min-width: 0 !important;
        flex: 0 1 auto !important;
    }

    /* Correct bubble sizing */
    .chat-messages .bubble {
        display: block !important;
        width: fit-content !important;
        max-width: 100% !important;
        min-width: 70px !important;
        box-sizing: border-box !important;
        word-wrap: break-word !important;
        overflow-wrap: anywhere !important;
    }

    /* Incoming bubble */
    .chat-messages .incoming .bubble {
        margin-right: auto !important;
    }

    /* Outgoing bubble */
    .chat-messages .outgoing .bubble {
        margin-left: auto !important;
    }

    /* Message text */
    .chat-messages .message-body {
        white-space: normal !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
    }

    /* Time + ticks */
    .chat-messages .message-meta {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 5px !important;
        white-space: nowrap !important;
    }

/* Template Sender Layout */
.template-sender-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - 180px);
}

.sender-controls {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

    .sender-controls h3 {
        margin: 0 0 10px 0;
        font-size: 18px;
        color: #111827;
    }

    .sender-controls label {
        display: block;
        font-size: 12px;
        font-weight: 600;
        color: #6b7280;
        margin-bottom: 5px;
    }

    .sender-controls select {
        width: 100%;
        height: 40px;
        padding: 0 10px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        margin-bottom: 15px;
    }

/* Variables Grid */
.variables-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #f3f4f6;
}

.var-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .var-field label {
        font-size: 11px;
        color: #374151;
        margin: 0;
    }

    .var-field input {
        height: 35px;
        padding: 0 10px;
        border: 1px solid #d1d5db;
        border-radius: 6px;
    }

/* Preview Window */
.sender-preview {
    background: #f3f4f6;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.preview-body {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}

.email-render {
    background: white;
    width: 100%;
    max-width: 600px;
    min-height: 800px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 0; /* HTML template handles its own padding */
}

.preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    font-style: italic;
}

.var-placeholder {
    background: #e0e7ff;
    color: #4338ca;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
}
