/* WhatsApp CRM — Premium Mobile-First Design System */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    --wa-green: #00a884;
    --wa-green-dark: #008069;
    --wa-green-light: #d9fdd3;
    --wa-teal: #128c7e;
    --wa-dark: #111b21;
    --wa-panel: #202c33;
    --wa-chat-bg: #efeae2;
    --sidebar-width: 280px;
    --header-height: 60px;
    --mobile-nav-height: 64px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(17, 27, 33, 0.06), 0 1px 2px rgba(17, 27, 33, 0.04);
    --shadow-md: 0 4px 20px rgba(17, 27, 33, 0.08);
    --shadow-lg: 0 12px 40px rgba(17, 27, 33, 0.12);
    --text-primary: #111b21;
    --text-secondary: #667781;
    --text-muted: #8696a0;
    --border-color: #e9edef;
    --border-light: #eef1f3;
    --surface: #ffffff;
    --surface-muted: #f7f8fa;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--surface-muted);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body.page-inbox {
    height: 100dvh;
    overflow: hidden;
}

a { text-decoration: none; color: inherit; }

/* ─── App shell ─── */
.app-shell {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

body.page-inbox .app-shell {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 27, 33, 0.45);
    z-index: 1040;
    opacity: 0;
    transition: opacity var(--transition);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; opacity: 1; }

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, var(--wa-dark) 0%, #1a2e35 100%);
    color: #fff;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--wa-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 14px rgba(0, 168, 132, 0.35);
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.2;
}

.sidebar-brand-text small {
    display: block;
    font-weight: 500;
    font-size: 0.7rem;
    opacity: 0.55;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.78);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0;
    font-weight: 500;
    font-size: 0.925rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}

.sidebar-nav .nav-link i { font-size: 1.15rem; opacity: 0.85; }

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(0, 168, 132, 0.22);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--wa-green);
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--wa-teal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

body.page-inbox .main-wrapper {
    height: 100dvh;
    overflow: hidden;
}

.topbar {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: none;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.topbar-menu-btn,
.topbar-back-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-content {
    flex: 1;
    padding: 1.5rem 1.75rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 1200px) {
    .main-content:not(.inbox-page) {
        padding: 1.75rem 2.25rem;
    }
}

.main-content.inbox-page {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: auto;
}

.inbox-toast-stack {
    position: fixed;
    top: calc(var(--header-height) + 0.75rem);
    right: 1rem;
    z-index: 1080;
    width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}

.inbox-toast-stack .alert {
    pointer-events: auto;
    box-shadow: var(--shadow-md);
}

/* Mobile bottom nav */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    z-index: 1030;
    box-shadow: 0 -4px 20px rgba(17, 27, 33, 0.06);
}

.mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-height: var(--mobile-nav-height);
    transition: color var(--transition);
}

.mobile-bottom-nav a i { font-size: 1.35rem; }

.mobile-bottom-nav a.active { color: var(--wa-green-dark); }

.mobile-bottom-nav a.active i { color: var(--wa-green); }

/* ─── Components ─── */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.15rem 0 0;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.card-premium {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-premium .card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.15rem 1.5rem;
    font-weight: 600;
}

.card-premium .card-body {
    padding: 1.35rem 1.5rem;
}

/* Bootstrap row on card-body cancels horizontal padding — reset it */
.card-premium > .card-body.row {
    margin-left: 0;
    margin-right: 0;
    padding: 1.35rem 1.5rem;
}

.card-premium .card-body.compact {
    padding: 1rem 1.25rem;
}

.card-premium .card-body.flush {
    padding: 0;
}

.card-premium .card-body.flush-inset .code-block,
.card-premium .card-body.flush-inset > .empty-state {
    margin: 1.35rem 1.5rem;
}

.card-premium .card-body.flush-inset .code-block {
    border-radius: var(--radius);
}

.card-stat {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    height: 100%;
}

.card-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-stat .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(0, 168, 132, 0.1);
    color: var(--wa-green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.card-stat .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.card-stat .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.35rem;
}

/* ─── Global button alignment (all pages) ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    line-height: 1.15;
    vertical-align: middle;
    text-align: center;
}

.btn .bi,
.btn [class*=" bi-"],
.btn-wa .bi,
.btn-outline-wa .bi {
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    line-height: 1;
    min-height: 36px;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.btn-sm .bi {
    font-size: 0.95em;
}

.btn-lg {
    min-height: 48px;
}

.btn-wa {
    background: var(--wa-green);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.15rem;
    min-height: 44px;
    line-height: 1;
    gap: 0.4rem;
    transition: background var(--transition), transform 0.15s;
}

.btn-wa.btn-sm {
    min-height: 36px;
    padding: 0.45rem 0.9rem;
}

.btn-wa:hover, .btn-wa:focus {
    background: var(--wa-green-dark);
    color: #fff;
    transform: translateY(-1px);
}

.btn-wa:active { transform: translateY(0); }

.btn-outline-wa {
    border: 1.5px solid var(--wa-green);
    color: var(--wa-green-dark);
    background: transparent;
    font-weight: 600;
    border-radius: var(--radius-sm);
    min-height: 44px;
    line-height: 1;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
}

.btn-outline-wa.btn-sm {
    min-height: 36px;
    padding: 0.45rem 0.85rem;
}

.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-danger,
.btn-outline-light {
    line-height: 1;
    gap: 0.35rem;
}

.btn-outline-secondary.btn-sm,
.btn-outline-primary.btn-sm,
.btn-outline-danger.btn-sm {
    min-height: 36px;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.btn-outline-wa:hover {
    background: rgba(0, 168, 132, 0.08);
    color: var(--wa-green-dark);
}

.btn-outline-wa:disabled,
.btn-outline-wa.disabled {
    opacity: 0.45;
    color: #94a3b8;
    border-color: #cbd5e1;
    background: transparent;
    pointer-events: none;
}

.badge-wa {
    background: var(--wa-green);
    color: #fff;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.25em 0.65em;
}

.alert-premium {
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom */
}

.form-control:focus, .form-select:focus {
    border-color: var(--wa-green);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}

.form-control-sm, .form-select-sm { min-height: 38px; font-size: 0.875rem; }

.table-premium thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom-width: 1px;
    white-space: nowrap;
}

/* Mobile card list (replaces tables) */
.mobile-card-list { display: none; }

.mobile-card-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-card-item:last-child { border-bottom: none; }

/* ─── Inbox ─── */
.inbox-app {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    background: var(--surface);
    overflow: hidden;
}

.main-content.inbox-page .inbox-app {
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.inbox-list-col {
    width: 100%;
    max-width: 360px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    min-height: 0;
}

.inbox-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
}

.inbox-list-header h6 {
    font-weight: 700;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.inbox-search {
    position: relative;
}

.inbox-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.inbox-search input {
    padding-left: 2.25rem;
    background: var(--surface-muted);
    border: none;
    border-radius: var(--radius-sm);
}

.inbox-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.inbox-filters select {
    flex: 1;
    min-width: 120px;
    font-size: 0.8rem;
    min-height: 38px;
}

.chat-list-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.conv-item {
    display: block;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
    cursor: pointer;
}

.conv-item:hover { background: var(--surface-muted); }

.conv-item.active {
    background: rgba(0, 168, 132, 0.08);
    border-left: 3px solid var(--wa-green);
}

.conv-item.unread .conv-name { font-weight: 700; }

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-teal), var(--wa-green));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.conv-meta { min-width: 0; flex: 1; }

.conv-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.inbox-chat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    background: var(--wa-chat-bg);
    overflow: hidden;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.chat-header {
    background: var(--wa-panel);
    color: #fff;
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 60px;
    flex-shrink: 0;
}

.chat-header-info { flex: 1; min-width: 0; }

.chat-header-name {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-phone {
    font-size: 0.78rem;
    opacity: 0.75;
}

.chat-header-actions {
    display: flex;
    gap: 0.35rem;
}

.chat-header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background var(--transition);
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.chat-header-btn.call-btn {
    background: rgba(0, 168, 132, 0.35);
    color: #dff7ef;
}

.chat-header-status {
    font-size: 0.78rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-header-status .online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25d366;
    display: inline-block;
}

.chat-header-status .offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8696a0;
    display: inline-block;
}

.chat-history-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    margin: 0 auto 0.75rem;
    color: #667781;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.chat-history-loader.d-none { display: none !important; }

.chat-history-loader-spin {
    width: 14px;
    height: 14px;
    border: 2px solid #c5c9cd;
    border-top-color: #00a884;
    border-radius: 50%;
    opacity: 0;
}

.chat-history-loader.is-loading .chat-history-loader-spin {
    opacity: 1;
    animation: chat-hist-spin 0.7s linear infinite;
}

@keyframes chat-hist-spin {
    to { transform: rotate(360deg); }
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overscroll-behavior: contain;
    background-image:
        linear-gradient(rgba(239, 234, 226, 0.92), rgba(239, 234, 226, 0.92)),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.35'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.chat-input-area {
    background: #f0f2f5;
    padding: 0.55rem 0.75rem;
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    flex: 0 0 auto;
    z-index: 5;
}

.chat-composer-tools {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.session-window-banner {
    background: rgba(255, 193, 7, 0.15);
    color: var(--text-primary);
    border: 1px solid rgba(255, 193, 7, 0.35);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}

.chat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 0.35rem 0.5rem 0.35rem 0.35rem;
    box-shadow: var(--shadow-sm);
}

.chat-input-form textarea,
.chat-input-form input[type="text"] {
    border: none;
    background: transparent;
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: none;
    padding: 0.5rem 0.25rem;
    font-size: 16px;
    box-shadow: none !important;
}

.chat-input-form textarea:focus,
.chat-input-form input[type="text"]:focus {
    outline: none;
    box-shadow: none;
}

.chat-action-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.15rem;
    cursor: pointer;
}

.chat-action-btn.attach {
    background: transparent;
    color: var(--text-secondary);
}

.chat-action-btn.send {
    background: var(--wa-green);
    color: #fff;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text-secondary);
    padding: 2rem;
    text-align: center;
}

.chat-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 168, 132, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--wa-green);
    margin-bottom: 1rem;
}

/* Messages */
.msg {
    max-width: 85%;
    margin-bottom: 0.5rem;
    padding: 0.55rem 0.75rem 0.35rem;
    border-radius: 8px;
    position: relative;
    font-size: 0.925rem;
    line-height: 1.45;
    word-break: break-word;
}

.msg:hover .msg-reply-btn,
.msg:focus-within .msg-reply-btn,
.msg-reply-btn:hover,
.msg-reply-btn:focus {
    opacity: 1;
}

.msg-reply-btn {
    position: absolute;
    top: 0.3rem;
    z-index: 3;
    opacity: 0;
    /* Keep clickable while fading — button stays INSIDE .msg so hover is not lost */
    pointer-events: auto;
    border: 0;
    background: rgba(255,255,255,0.95);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #546e7a;
    box-shadow: 0 1px 3px rgba(0,0,0,.14);
    cursor: pointer;
    transition: opacity .12s ease, background .12s ease;
}

.msg-reply-btn:hover {
    background: #fff;
    color: #111b21;
}

/* Inside the bubble (top-right) so hover is not lost when moving onto it */
.msg-in .msg-reply-btn,
.msg-out .msg-reply-btn { right: 0.3rem; left: auto; }

/* Touch / coarse pointer: always show a faint reply control */
@media (hover: none), (pointer: coarse) {
    .msg-reply-btn { opacity: 0.55; }
}

.msg-bubble-inner { position: relative; padding-top: 0.1rem; }

.msg-reply-quote {
    display: flex;
    gap: 0.45rem;
    background: rgba(0,0,0,0.06);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.35rem;
    cursor: default;
}

.msg-out .msg-reply-quote { background: rgba(0,0,0,0.08); }

.msg-reply-quote-bar {
    width: 3px;
    border-radius: 3px;
    background: var(--wa-green, #25d366);
    flex-shrink: 0;
}

.msg-reply-quote-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--wa-green, #128c7e);
}

.msg-reply-quote-text {
    font-size: 0.78rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.msg-in {
    background: var(--surface);
    align-self: flex-start;
    border-top-left-radius: 2px;
    box-shadow: var(--shadow-sm);
}

.msg-out {
    background: var(--wa-green-light);
    align-self: flex-end;
    margin-left: auto;
    border-top-right-radius: 2px;
}

.msg-template-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(17, 27, 33, 0.55);
    margin-bottom: 0.2rem;
}

/* WhatsApp-style document card */
.msg-doc {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 220px;
    max-width: 280px;
    padding: 0.55rem 0.65rem;
    margin-top: 0.15rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
}

.msg-out .msg-doc {
    background: rgba(0, 0, 0, 0.08);
}

.msg-doc-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #e53935;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.msg-doc-icon .bi-file-earmark-word-fill { color: #2b579a; }
.msg-doc-icon .bi-file-earmark-excel-fill { color: #217346; }
.msg-doc-icon .bi-file-earmark-ppt-fill { color: #d24726; }
.msg-doc-icon .bi-file-earmark-zip-fill { color: #f9a825; }
.msg-doc-icon .bi-file-earmark-text-fill,
.msg-doc-icon .bi-file-earmark-fill { color: #546e7a; }

.msg-doc-info {
    flex: 1;
    min-width: 0;
}

.msg-doc-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-doc-sub {
    font-size: 0.72rem;
    color: #667781;
    margin-top: 0.1rem;
}

.msg-doc-dl {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #546e7a;
    background: rgba(255,255,255,0.85);
    flex-shrink: 0;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.msg-doc-dl:hover {
    background: #fff;
    color: var(--wa-green, #25d366);
}

/* System notices (call permission, etc.) */
.msg-system {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    margin: 0.65rem 0;
    max-width: 90%;
}

.msg-system-chip {
    background: rgba(255, 255, 255, 0.92);
    color: #546e7a;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    text-align: center;
}

.msg-system-time {
    font-size: 0.65rem;
    color: #8696a0;
}

.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.msg-time { opacity: 0.85; }

.msg-ticks {
    display: inline-flex;
    align-items: center;
    font-size: 0.95rem;
    line-height: 1;
}

.msg-ticks-read { color: #53bdeb; }
.msg-ticks-delivered,
.msg-ticks-sent { color: rgba(17, 27, 33, 0.45); }
.msg-out .msg-ticks-delivered,
.msg-out .msg-ticks-sent { color: rgba(17, 27, 33, 0.55); }
.msg-ticks-failed { color: #ef4444; }
.msg-ticks-pending { color: rgba(17, 27, 33, 0.35); }

.chat-header-status {
    font-size: 0.78rem;
    opacity: 0.9;
    margin-top: 0.1rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-header-status .online-dot,
.chat-header-status .offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.chat-header-status .online-dot { background: #25d366; }
.chat-header-status .offline-dot { background: #8696a0; }

.tag-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    cursor: pointer;
    background: #fff;
    user-select: none;
}

.tag-chip input { display: none; }

.tag-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-chip.is-on {
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

.chat-attach-menu {
    position: absolute;
    bottom: 58px;
    left: 8px;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    display: none;
    z-index: 20;
    min-width: 170px;
}

.chat-attach-menu.show { display: block; }

.chat-attach-menu button {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.875rem;
}

.chat-attach-menu button:hover { background: var(--surface-muted); }

.chat-input-form { position: relative; }

.chat-action-btn.mic.recording {
    background: #ef4444 !important;
    color: #fff !important;
    transform: scale(1.08);
}

.voice-record-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.55rem 0.9rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.voice-record-bar.d-none { display: none !important; }

.voice-record-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
}

.voice-record-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 2.5rem;
    color: #111b21;
}

.voice-record-hint {
    font-size: 0.78rem;
    color: var(--text-secondary, #667781);
    flex: 1;
}

.voice-record-cancel {
    border: 0;
    background: transparent;
    color: #ef4444;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.15rem;
    cursor: pointer;
}

.voice-record-send {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--wa-green, #25d366);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.voice-record-send:hover { filter: brightness(0.95); }

.chat-input-form.d-none { display: none !important; }

/* WhatsApp-like voice bubble */
.msg-voice {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 230px;
    max-width: 300px;
    padding: 0.35rem 0.2rem 0.25rem;
    position: relative;
}

.msg-voice-play {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    padding: 0;
}

.msg-out .msg-voice-play,
.msg-out .msg-voice-mic {
    background: #00a884;
}

.msg-in .msg-voice-play,
.msg-in .msg-voice-mic {
    background: #00a884;
}

.msg-voice-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding-top: 0;
}

.msg-voice-wave {
    position: relative;
    display: flex;
    align-items: center;
    height: 28px;
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

.msg-voice-wave-bars {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.msg-voice-wave-bars span {
    flex: 1;
    height: var(--h, 40%);
    max-width: 3px;
    border-radius: 2px;
    background: rgba(17, 27, 33, 0.28);
    transition: background 0.08s linear;
    align-self: center;
}

.msg-voice-wave-bars span.played {
    background: #00a884;
}

.msg-in .msg-voice-wave-bars span.played,
.msg-out .msg-voice-wave-bars span.played {
    background: #00a884;
}

.msg-voice-progress {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    width: 0%;
    background: transparent;
    pointer-events: none;
    z-index: 0;
}

.msg-voice-dur {
    font-size: 0.72rem;
    color: #667781;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    min-width: 2.2rem;
}

.msg-voice-mic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    position: relative;
    align-self: center;
    margin: 0;
    line-height: 1;
}

.msg-voice-mic::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #fff;
    box-shadow: inset 0 0 0 2.5px #00a884;
}

.msg-image-thumb {
    cursor: zoom-in;
}

.msg-image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(11, 20, 26, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem;
}

.msg-image-lightbox.d-none { display: none !important; }

.msg-image-lightbox-stage {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.msg-image-lightbox-stage img,
.msg-image-lightbox-stage video {
    max-width: min(96vw, 1100px);
    max-height: calc(100vh - 7rem);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
}

.msg-image-lightbox-stage video {
    background: #000;
    width: min(96vw, 1100px);
}

.msg-video-thumb {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
    background: #111;
}

.msg-video-thumb video {
    display: block;
    max-width: 100%;
    max-height: 220px;
    width: auto;
    pointer-events: none;
}

.msg-video-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.28);
    transition: background 0.15s ease;
}

.msg-video-thumb:hover .msg-video-play {
    background: rgba(0, 0, 0, 0.4);
}

.msg-video-play i {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    padding-left: 3px;
}

.msg-image-lightbox-close {
    position: absolute;
    top: 0.85rem;
    right: 1rem;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.14);
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.msg-image-lightbox-close:hover {
    background: rgba(255,255,255,0.28);
}

.msg-image-lightbox-download {
    flex-shrink: 0;
}


/* Reply composer bar */
.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f0f2f5;
    border-left: 4px solid var(--wa-green, #25d366);
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    margin-bottom: 0.45rem;
}

.chat-reply-bar.d-none { display: none !important; }

.chat-reply-bar-inner { flex: 1; min-width: 0; }

.chat-reply-bar-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--wa-green, #128c7e);
}

.chat-reply-bar-text {
    font-size: 0.8rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reply-bar-close {
    border: 0;
    background: transparent;
    color: #667781;
    font-size: 1rem;
    cursor: pointer;
}

/* Upload progress */
.chat-upload-progress {
    position: relative;
    height: 22px;
    background: #e9edef;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.45rem;
}

.chat-upload-progress.d-none { display: none !important; }

.chat-upload-progress-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg, #25d366, #128c7e);
    transition: width 0.15s ease;
}

.chat-upload-progress-label {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.72rem;
    font-weight: 600;
    color: #111b21;
}

/* Drag & drop */
.chat-drop-zone {
    position: relative;
}

.chat-drop-zone.is-dragover .chat-input-form {
    opacity: 0.35;
}

.chat-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    border: 2px dashed var(--wa-green, #25d366);
    border-radius: 12px;
    background: rgba(37, 211, 102, 0.08);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.35rem;
    color: #128c7e;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 5;
    pointer-events: none;
}

.chat-drop-overlay.show { display: flex; }
.chat-drop-overlay .bi { font-size: 1.5rem; }

.pwa-push-hint {
    position: fixed;
    right: 1rem;
    bottom: 5.5rem;
    z-index: 1080;
    background: #fff;
    border: 1px solid var(--border-color, #e9edef);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    max-width: 340px;
}

.pwa-push-hint.d-none { display: none !important; }

.pwa-push-hint-body { display: flex; flex-direction: column; gap: 0.55rem; }

.pwa-push-hint-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#pwaPushStatus.text-danger { color: #b42318 !important; }
#pwaPushStatus.text-success { color: #027a48 !important; }
#pwaPushStatus:not(.text-danger):not(.text-success) { color: #344054; }

.typing-to-customer {
    font-size: 0.75rem;
    color: var(--wa-green-dark);
    padding: 0.35rem 0.75rem 0;
    animation: typingPulse 1.2s ease-in-out infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Profile offcanvas / panel */
.profile-panel {
    width: 320px;
    border-left: 1px solid var(--border-color);
    background: var(--surface);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
}

.profile-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.profile-card {
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Login */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(145deg, #0b141a 0%, #1a3a34 50%, #0d3d32 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 168, 132, 0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.75rem;
    position: relative;
    z-index: 1;
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--wa-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px rgba(0, 168, 132, 0.35);
}

/* ─── Page layout helpers ─── */
.split-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 991.98px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
}

.form-panel .card-header {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
}

.form-panel .card-body {
    padding: 1.35rem 1.5rem;
}

.form-panel > .card-body.row {
    margin-left: 0;
    margin-right: 0;
    padding: 1.35rem 1.5rem;
}

.form-panel .form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

/* ─── Filter bar (premium) ─── */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.15rem 1.5rem;
    margin-bottom: 1.25rem;
}

.filter-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.filter-bar-title {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-bar-title i {
    color: var(--wa-green);
    font-size: 0.95rem;
}

.filter-clear {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--wa-green-dark);
    text-decoration: none;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 168, 132, 0.08);
    transition: background var(--transition);
}

.filter-clear:hover {
    background: rgba(0, 168, 132, 0.14);
    color: var(--wa-green-dark);
}

.filter-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem 1.25rem;
}

.filter-field label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.filter-field label i {
    font-size: 0.875rem;
    color: var(--wa-green);
}

.filter-bar .form-select,
.filter-bar .filter-select {
    min-height: 42px;
    padding: 0.5rem 2.35rem 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--surface-muted);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23008069' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.filter-bar .form-select:hover,
.filter-bar .filter-select:hover {
    border-color: rgba(0, 168, 132, 0.35);
    background-color: #fff;
}

.filter-bar .form-select:focus,
.filter-bar .filter-select:focus {
    border-color: var(--wa-green);
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.12);
    background-color: #fff;
}

.filter-field.is-active .form-select,
.filter-field.is-active .filter-select {
    border-color: var(--wa-green);
    background-color: rgba(0, 168, 132, 0.05);
    font-weight: 600;
}

@media (max-width: 575.98px) {
    .filter-bar {
        padding: 1rem 1.15rem;
    }

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

/* ─── Premium data tables ─── */
.table-premium-wrap {
    overflow: hidden;
}

.data-table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.data-table thead th {
    background: linear-gradient(180deg, #f8faf9 0%, #f1f5f3 100%);
    border-bottom: 2px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.875rem 1rem;
    white-space: nowrap;
}

.card-premium .data-table thead th:first-child,
.card-premium .data-table tbody td:first-child {
    padding-left: 1.5rem;
}

.card-premium .data-table thead th:last-child,
.card-premium .data-table tbody td:last-child {
    padding-right: 1.5rem;
}

.data-table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(0, 168, 132, 0.04);
}

.data-table code {
    font-size: 0.8125rem;
    background: #f0f4f2;
    color: #0d6e58;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    font-weight: 500;
}

.data-table .cell-muted {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.data-table .cell-primary {
    font-weight: 600;
}

.card-premium .card-footer-pagination {
    padding: 0.875rem 1.5rem;
    border-top: 1px solid var(--border-light);
    background: #fafbfc;
}

.card-premium .card-footer-pagination .pagination {
    margin-bottom: 0;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.card-premium .card-footer-pagination .page-link {
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
    color: var(--text-primary, #111b21);
    border-color: var(--border-light, #e9edef);
}

.card-premium .card-footer-pagination .page-item.active .page-link {
    background: var(--wa-green, #25d366);
    border-color: var(--wa-green, #25d366);
    color: #fff;
}

/* Guard against unstyled Tailwind pagination SVGs if bootstrap view is missing */
.card-footer-pagination svg,
nav[role="navigation"] svg {
    width: 1rem;
    height: 1rem;
    max-width: 1rem;
    max-height: 1rem;
    display: inline-block;
    vertical-align: middle;
}

/* ─── Status pills ─── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
}

.status-pill-success { background: #dcfce7; color: #166534; }
.status-pill-warning { background: #fef3c7; color: #92400e; }
.status-pill-danger  { background: #fee2e2; color: #991b1b; }
.status-pill-info    { background: #dbeafe; color: #1e40af; }
.status-pill-neutral { background: #f1f5f9; color: #475569; }
.status-pill-primary { background: rgba(0, 168, 132, 0.12); color: #0d6e58; }

/* ─── Mobile card list (data rows) ─── */
.mobile-card-list { display: none; }

.mobile-data-card {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: #fff;
}

.mobile-data-card:last-child {
    border-bottom: none;
}

.mobile-data-card .mdc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.mobile-data-card .mdc-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.mobile-data-card .mdc-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.mobile-data-card .mdc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.65rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.mobile-data-card .mdc-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.mobile-data-card .mdc-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-light);
}

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.data-table td .empty-state {
    padding: 2.5rem 1.5rem;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: rgba(0, 168, 132, 0.08);
    color: var(--wa-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 0;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-action {
    margin-top: 1rem;
}

/* ─── Period toggle ─── */
.period-toggle {
    display: inline-flex;
    background: #f1f5f3;
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
}

.period-toggle .btn {
    border: none !important;
    border-radius: calc(var(--radius) - 2px) !important;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    min-height: 34px;
    line-height: 1;
}

.period-toggle .btn-wa {
    box-shadow: 0 2px 6px rgba(0, 168, 132, 0.25);
}

/* ─── Code / JSON blocks ─── */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
    font-size: 0.75rem;
    line-height: 1.6;
    overflow: auto;
    max-height: 420px;
    margin: 0;
}

.code-inline {
    background: #f0f4f2;
    color: #0d6e58;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    word-break: break-all;
}

.value-field {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #f8faf9;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.8125rem;
    line-height: 1.5;
    word-break: break-all;
}

.value-field code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

.card-premium .form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.card-premium ul {
    padding-left: 1.25rem;
    margin-bottom: 0;
}

.card-premium ul li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.card-premium ul li:last-child {
    margin-bottom: 0;
}

/* ─── Alert premium ─── */
.alert-premium {
    border: none;
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
    padding: 1.15rem 1.5rem;
}

.alert-premium.alert-info {
    background: #eff6ff;
    border-left-color: #3b82f6;
    color: #1e3a5f;
}

.alert-premium.alert-warning {
    background: #fffbeb;
    border-left-color: #f59e0b;
    color: #78350f;
}

.alert-premium.alert-danger {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #7f1d1d;
}

/* ─── List item cards (quick replies etc) ─── */
.list-item-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.list-item-card:hover {
    border-color: rgba(0, 168, 132, 0.25);
    box-shadow: var(--shadow-sm);
}

.list-item-card .lic-title {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.list-item-card .lic-body {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ─── Integration link grid ─── */
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.link-grid a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    background: #f8faf9;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
}

.link-grid a:hover {
    background: rgba(0, 168, 132, 0.08);
    border-color: rgba(0, 168, 132, 0.3);
    color: var(--wa-green-dark);
}

/* ─── Report stat mini cards ─── */
.report-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.report-mini-stat {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: center;
}

.report-mini-stat .rms-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.report-mini-stat .rms-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ─── Nav pills for sub-pages ─── */
.sub-nav-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.sub-nav-pills .btn {
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    min-height: 36px;
    line-height: 1;
}

/* ─── Tag badge premium ─── */
.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}

/* ─── Form page centered ─── */
.form-page {
    max-width: 560px;
    margin: 0 auto;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.5rem;
}

/* ─── Responsive ─── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open { transform: translateX(0); }

    .main-wrapper {
        margin-left: 0;
        padding-bottom: var(--mobile-nav-height);
    }

    .topbar { display: flex; }

    .mobile-bottom-nav { display: flex; }

    .main-content {
        padding: 1.25rem 1.25rem;
        padding-bottom: calc(var(--mobile-nav-height) + 1.25rem + env(safe-area-inset-bottom));
    }

    .main-content.inbox-page {
        padding: 0;
        padding-bottom: 0;
    }

    .page-title { font-size: 1.25rem; }

    .inbox-app {
        height: 100%;
        border-radius: 0;
    }

    /* Mobile inbox: single panel view */
    .inbox-list-col {
        max-width: 100%;
        flex: 1;
        min-height: 0;
    }

    .inbox-chat-col,
    .inbox-profile-col {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1025;
        height: auto;
    }

    body.page-inbox.inbox-has-chat .mobile-bottom-nav {
        display: none !important;
    }

    .inbox-app.show-chat .inbox-list-col { display: none; }

    .inbox-app.show-chat .inbox-chat-col {
        display: flex;
        flex-direction: column;
    }

    .inbox-app.show-profile .inbox-profile-col {
        display: block;
        z-index: 1035;
        width: 100%;
        max-width: 100%;
    }

    .table-desktop { display: none !important; }
    .mobile-card-list { display: block; }

    .card-stat .stat-value { font-size: 1.4rem; }
}

@media (min-width: 992px) {
    .inbox-profile-col { display: block !important; }

    .inbox-app:not(.show-chat) .inbox-chat-col { display: flex; }

    .topbar-back-btn { display: none !important; }
}

@media (min-width: 1200px) {
    .inbox-app .inbox-profile-col {
        display: block !important;
        position: static;
        width: 300px;
        flex-shrink: 0;
    }

    .inbox-app.show-profile .inbox-profile-col {
        position: static;
        box-shadow: none;
    }
}

/* ─── WhatsApp Call modal (WebRTC) ─── */
.wa-call-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.wa-call-modal.d-none { display: none !important; }

.wa-call-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 27, 33, 0.72);
    backdrop-filter: blur(6px);
}

.wa-call-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 340px);
    background: linear-gradient(165deg, #0d6e58 0%, #111b21 100%);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem 1.75rem;
    text-align: center;
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.wa-call-avatar {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.wa-call-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.wa-call-subtitle {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 0.5rem;
}

.wa-call-timer {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 1.25rem;
    opacity: 0.9;
}

.wa-call-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
}

.wa-call-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wa-call-btn:hover { transform: scale(1.05); }

.wa-call-btn-accept {
    background: #22c55e;
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.4);
}

.wa-call-btn-decline {
    background: #ef4444;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}

.chat-header-btn.text-success {
    color: var(--wa-green) !important;
}

.chat-header-btn.text-success:hover {
    background: rgba(0, 168, 132, 0.12);
}

/* ─── PWA install & update ─── */
.pwa-install-banner {
    position: fixed;
    bottom: calc(var(--mobile-nav-height, 0px) + 1rem + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1040;
    width: min(420px, calc(100% - 2rem));
}

@media (min-width: 992px) {
    .pwa-install-banner {
        bottom: 1.25rem;
    }
}

.pwa-install-inner {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.pwa-install-icon {
    border-radius: 12px;
    flex-shrink: 0;
}

.pwa-install-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.8125rem;
}

.pwa-install-text strong {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.pwa-install-text span {
    color: var(--text-secondary);
}

.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.pwa-install-manual {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem 0;
    border-top: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.pwa-install-manual ol li {
    margin-bottom: 0.35rem;
}

.pwa-install-dismiss {
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem 0.5rem !important;
    text-decoration: none !important;
}

.pwa-update-toast {
    position: fixed;
    top: calc(var(--header-height) + 0.75rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1045;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: var(--wa-dark);
    color: #fff;
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
}

html.pwa-standalone .topbar {
    padding-top: env(safe-area-inset-top);
}

html.pwa-standalone .main-content {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

html.pwa-standalone .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
}

