/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #2f8c99;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease;
}

.chat-button:hover {
    transform: scale(1.1);
    background: #226d78;
}

.chat-button i {
    font-size: 24px;
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.chat-window.active {
    display: flex;
}

.chat-header {
    background: #2f8c99;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
}

.close-chat {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
}

.message.client {
    align-self: flex-end;
    background: #2f8c99;
    color: white;
    border-bottom-right-radius: 2px;
}

.message.admin {
    align-self: flex-start;
    background: #e2e8f0;
    color: #1e293b;
    border-bottom-left-radius: 2px;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    display: block;
    text-align: right;
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
}

.chat-input-area input:focus {
    border-color: #2f8c99;
}

.send-button {
    background: #2f8c99;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Admin Specific Chat Styles */
.admin-chat-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - 100px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.conversations-list {
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
}

.conversation-item {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #f8fafc;
}

.conversation-item.active {
    background: #eff6ff;
    border-left: 4px solid #2f8c99;
}

.conversation-item .user-name {
    font-weight: 600;
    display: block;
}

.conversation-item .last-message {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-chat-window {
    display: flex;
    flex-direction: column;
}

.admin-chat-window .chat-messages {
    background: white;
}

.admin-chat-window .chat-header {
    background: #f8fafc;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
}

.clients-container {
    position: relative;
    z-index: 5;
    max-width: 1380px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.clients-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 28px;
    background:
        radial-gradient(circle at top right, rgba(47,140,153, 0.12), transparent 28%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(249, 249, 249, 0.96));
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 24px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.06);
}

.clients-hero__eyebrow,
.clients-sidebar__eyebrow,
.admin-chat-window__eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #2f8c99;}

.clients-hero__title {
    margin: 0;
    max-width: 680px;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    color: #333;
}

.clients-hero__description {
    margin-top: 14px;
    max-width: 720px;
    color: #777;
    font-size: 0.98rem;
}

.clients-hero__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    gap: 14px;
    width: min(100%, 380px);
}

.clients-stat-card {
    padding: 18px;
    border-radius: 18px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.clients-stat-card__label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.clients-stat-card__value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
    color: #333;
}

.clients-stat-card__value--small {
    font-size: 0.95rem;
    line-height: 1.3;
    color: #777;
}

.admin-chat-layout {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}

.clients-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.clients-sidebar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 24px 24px 18px;
    border-bottom: 1px solid #e2e8f0;
}

.clients-sidebar__title {
    margin: 0;
    font-size: 1.4rem;
    color: #0f172a;
}

.clients-sidebar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(47,140,153, 0.1);
    color: #26818f;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.clients-search {
    position: relative;
    margin: 18px 18px 16px;
}

.clients-search i {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    color: #94a3b8;
}

.clients-search input {
    width: 100%;
    padding: 12px 14px 12px 40px;
    border-radius: 14px;
    border: 1px solid #dbe2ea;
    background: #fff;
    outline: none;
    font-size: 0.92rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.clients-search input:focus {
    border-color: #2f8c99;
    box-shadow: 0 0 0 4px rgba(47,140,153, 0.12);
}

.clients-sidebar__tools {
    padding: 0 18px 18px;
    border-bottom: 1px solid #e2e8f0;
}

.clients-filter-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 2px;
}

.clients-filter-tab {
    border: 1px solid #dbe2ea;
    background: #fff;
    color: #475569;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clients-filter-tab:hover {
    border-color: rgba(47,140,153, 0.28);
    color: #235f6b;
}

.clients-filter-tab.active {
    background: linear-gradient(135deg, rgba(47,140,153, 0.12), rgba(47,140,153, 0.08));
    border-color: rgba(47,140,153, 0.25);
    color: #235f6b;
    box-shadow: 0 10px 24px rgba(47,140,153, 0.1);
}

.conversations-list {
    padding-bottom: 16px;
}

.conversation-item {
    width: calc(100% - 24px);
    margin: 0 12px 10px;
    padding: 16px 16px 14px;
    border: 1px solid transparent;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
    text-align: left;
    font: inherit;
}

.conversation-item:hover {
    background: #ffffff;
    border-color: rgba(47,140,153, 0.16);
    transform: translateY(-1px);
}

.conversation-item.active {
    background: linear-gradient(135deg, rgba(47,140,153, 0.08), rgba(47,140,153, 0.05));
    border: 1px solid rgba(47,140,153, 0.22);
    border-left: 1px solid rgba(47,140,153, 0.22);
    box-shadow: 0 14px 30px rgba(47,140,153, 0.1);
}

.conversation-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.conversation-item .user-name {
    color: #0f172a;
    font-size: 0.96rem;
}

.conversation-item__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.72rem;
    font-weight: 700;
}

.conversation-item__email {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item .last-message {
    display: block;
    font-size: 0.78rem;
    color: #475569;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conversation-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.72rem;
    color: #64748b;
}

.conversation-item__status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.conversation-item__status--pending {
    background: rgba(244, 63, 94, 0.1);
    color: #be123c;
}

.conversation-item__status--recent {
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
}

.conversation-item__status--replied {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}

.conversation-item__status--new {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.clients-list-state,
.clients-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    color: #64748b;
}

.clients-list-state {
    min-height: 220px;
    padding: 20px;
}

.clients-list-state i,
.clients-empty-state i {
    font-size: 1.6rem;
    opacity: 0.7;
}

.clients-empty-state {
    height: 100%;
    min-height: 320px;
    padding: 28px;
}

.clients-empty-state h4 {
    margin: 0;
    font-size: 1.1rem;
    color: #0f172a;
}

.clients-empty-state p {
    max-width: 420px;
    margin: 0;
}

.admin-chat-window__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 28px;
}

.admin-chat-window__header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.admin-chat-window__meta {
    margin-top: 8px;
    color: #64748b;
    font-size: 0.9rem;
}

.admin-chat-window__status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.admin-chat-window__status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12);
}

.admin-chat-window .chat-messages {
    padding: 24px 28px;
    background:
        radial-gradient(circle at top, rgba(47,140,153, 0.05), transparent 38%),
        linear-gradient(180deg, #ffffff, #f8fafc);
    flex: 1 1 auto;
    min-height: 180px;
}

.client-detail-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding: 0 28px 20px;
}

.client-detail-card {
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.client-detail-card__label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #64748b;
}

.client-detail-card__value {
    display: block;
    font-size: 1rem;
    line-height: 1.3;
    color: #0f172a;
}

.client-detail-note {
    margin: 0 28px 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(47,140,153, 0.08);
    border: 1px solid rgba(47,140,153, 0.14);
    color: #235f6b;
    font-size: 0.84rem;
    line-height: 1.45;
}

.admin-chat-input-area {
    padding: 18px 24px;
    background: #fff;
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin-top: auto;
    border-top: 1px solid #e2e8f0;
}

.admin-chat-input-area input {
    padding: 12px 14px;
    border-radius: 12px;
}

.admin-chat-input-area input:disabled {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

.admin-chat-input-area .send-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.admin-chat-window .clients-empty-state {
    min-height: 180px;
    height: auto;
    padding-top: 20px;
    padding-bottom: 20px;
}

.admin-chat-window__footer-note {
    padding: 0 24px 18px;
    color: #94a3b8;
    font-size: 0.78rem;
}

.admin-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 24px 18px;
    background: #fff;
}

.admin-quick-reply {
    border: 1px solid rgba(47,140,153, 0.18);
    background: rgba(47,140,153, 0.06);
    color: #235f6b;
    border-radius: 999px;
    padding: 9px 14px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-quick-reply:hover {
    background: rgba(47,140,153, 0.12);
    transform: translateY(-1px);
}

.admin-chat-message__sender {
    display: block;
    margin-bottom: 6px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.72;
}

.admin-chat-window .message {
    white-space: pre-wrap;
}

@media (max-width: 980px) {
    .clients-hero {
        flex-direction: column;
        align-items: stretch;
    }

    .clients-hero__stats {
        width: 100%;
    }

    .admin-chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .clients-sidebar {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .conversations-list {
        max-height: 360px;
    }

    .client-detail-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .clients-container {
        padding: 20px 14px 28px;
    }

    .clients-hero {
        padding: 22px 18px;
        border-radius: 20px;
    }

    .clients-hero__stats {
        grid-template-columns: 1fr;
    }

    .clients-sidebar__header,
    .admin-chat-window__header,
    .admin-chat-window .chat-messages,
    .admin-chat-input-area,
    .client-detail-summary,
    .admin-quick-replies {
        padding-left: 18px;
        padding-right: 18px;
    }

    .admin-chat-window__header {
        flex-direction: column;
    }

    .client-detail-summary {
        grid-template-columns: 1fr;
        padding-bottom: 18px;
    }

    .client-detail-note {
        margin-left: 18px;
        margin-right: 18px;
    }

    .clients-filter-tabs {
        grid-template-columns: 1fr 1fr;
    }
}
