:root {
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f5;
}

/* Login Page */
#login-page {
    background: linear-gradient(135deg, #128C7E 0%, #075E54 100%);
    min-height: 100vh;
}

#login-page .card {
    border: none;
    border-radius: 15px;
}

/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar .sidebar-header {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

/* Scrollable navigation area */
#sidebar .nav-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for sidebar */
#sidebar .nav-scroll-area::-webkit-scrollbar {
    width: 6px;
}

#sidebar .nav-scroll-area::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

#sidebar .nav-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

#sidebar .nav-scroll-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

#sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 12px 20px;
    transition: all 0.3s;
}

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

#sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
}

#sidebar .sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

/* Main Content */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background-color: #f5f5f5;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #eee;
}

/* Extra small button */
.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.2;
    border-radius: 0.2rem;
}

/* Session Cards */
.session-card {
    overflow: visible !important;
}

.session-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.session-card .card-body {
    overflow: visible !important;
    padding: 0.75rem;
}

.session-card .card-title {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.session-card .form-select-sm {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
}

.session-card .form-check-input {
    margin-top: 0.15rem;
}

.session-card small {
    font-size: 0.7rem;
}

/* Session popup menu */
.session-popup-menu {
    position: fixed;
    z-index: 999999 !important;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 8px 0;
    min-width: 160px;
    border: 1px solid #ddd;
    animation: menuFadeIn 0.1s ease-out;
    transform: translateZ(0);
    will-change: transform, opacity;
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.session-menu-item {
    display: block;
    padding: 10px 16px;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.session-menu-item:hover {
    background: #f0f0f0;
}

.session-menu-danger {
    color: #dc3545;
}

.session-menu-danger:hover {
    background: #fff0f0;
}

.session-menu-item i {
    margin-right: 10px;
    width: 16px;
    display: inline-block;
}

.session-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.session-status.connected {
    background-color: #28a745;
}

.session-status.disconnected {
    background-color: #dc3545;
}

.session-status.qr_pending {
    background-color: #ffc107;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Template Cards */
.template-card {
    transition: transform 0.2s;
}

.template-card:hover {
    transform: translateY(-2px);
}

.template-content {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.9em;
    max-height: 100px;
    overflow: hidden;
}

/* Campaign Status Badges */
.badge-draft { background-color: #6c757d; }
.badge-scheduled { background-color: #17a2b8; }
.badge-running { background-color: #28a745; }
.badge-paused { background-color: #ffc107; color: #000; }
.badge-completed { background-color: #007bff; }
.badge-cancelled { background-color: #dc3545; }

/* Progress Bar */
.progress {
    height: 8px;
    border-radius: 4px;
}

/* Groups List */
.groups-list-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.groups-list-item:hover {
    background-color: #f8f9fa;
}

.groups-list-item.active {
    background-color: #e9ecef;
}

/* Table */
.table th {
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    color: #6c757d;
}

/* Pagination */
.pagination {
    margin: 0;
}

.pagination .page-link {
    border: none;
    color: #128C7E;
}

.pagination .page-item.active .page-link {
    background-color: #128C7E;
    border-color: #128C7E;
    color: #fff;
}

/* Toast */
.toast {
    border: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* QR Code */
#qr-container {
    min-height: 256px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    #sidebar {
        position: fixed;
        top: 42px;
        left: -260px;
        width: 250px;
        height: calc(100vh - 42px);
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    #sidebar.show {
        left: 0;
    }

    #main-content {
        margin-left: 0;
        margin-top: 42px;
    }

    /* Mobile header */
    #mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        height: 42px;
    }

    /* Overlay when sidebar open */
    #sidebar.show::after {
        content: '';
        position: fixed;
        top: 42px;
        left: 250px;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
    }

    /* Compact campaign status chips on mobile */
    .campaign-status-chips .badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.6rem !important;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===================================
   Campaign Form - WhatsApp Style
   =================================== */

/* Campaign Modal */
#campaign-modal .modal-header {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border-bottom: none;
}

#campaign-modal .modal-header .modal-title {
    color: white;
    font-weight: 600;
}

/* Campaign Form Cards */
#campaign-modal .card {
    border-radius: 15px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.06);
    border: none;
}

#campaign-modal .card-header {
    background: #f8f9fa;
    border-bottom: 2px solid #f0f0f0;
    font-weight: 600;
    color: #333;
    border-radius: 15px 15px 0 0 !important;
}

#campaign-modal .card-header i {
    margin-right: 8px;
}

/* Device Cards */
.device-card {
    border: 2px solid #e0e0e0 !important;
    border-radius: 12px !important;
    transition: all 0.2s ease;
    cursor: pointer;
}

.device-card:hover {
    border-color: #25D366 !important;
    background: #f8fff9 !important;
}

.device-card.bg-success.bg-opacity-10 {
    border-color: #25D366 !important;
    background: #e8f5e9 !important;
}

.device-radio {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-radio i {
    font-size: 24px;
    color: #ccc;
}

.device-card.bg-success.bg-opacity-10 .device-radio i {
    color: #25D366;
}

/* Contact Count Box */
#campaign-contact-count {
    color: #25D366 !important;
}

/* Form Inputs */
#campaign-modal .form-control,
#campaign-modal .form-select {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 16px;
    transition: all 0.2s;
}

#campaign-modal .form-control:focus,
#campaign-modal .form-select:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1);
}

#campaign-modal textarea.form-control {
    min-height: 140px;
    resize: vertical;
}

/* Placeholder Tags */
#campaign-modal .btn-outline-primary {
    background: #e3f2fd;
    color: #1565c0;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    transition: all 0.2s;
}

#campaign-modal .btn-outline-primary:hover {
    background: #bbdefb;
    color: #1565c0;
}

/* Media Upload */
#campaign-media-dropzone {
    border: 2px dashed #ccc !important;
    border-radius: 12px !important;
    padding: 25px !important;
    transition: all 0.2s;
}

#campaign-media-dropzone:hover {
    border-color: #25D366 !important;
    background: #f8fff9 !important;
}

/* Anti-Ban Alert */
#campaign-modal .alert-warning {
    background: #fff8e1;
    border: 1px solid #ffecb3;
    border-radius: 10px;
    color: #f57f17;
}

/* Submit Button */
#save-campaign-btn {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    font-weight: 600;
    transition: all 0.2s;
}

#save-campaign-btn:hover {
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

/* Schedule Section */
#campaign-modal .form-check-input:checked {
    background-color: #25D366;
    border-color: #25D366;
}

/* Success button override */
.btn-success {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #20c55e 0%, #0e7d6d 100%);
}

/* ============================================
   Campaign Create Page
   ============================================ */
.campaign-create-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 15px;
}

.campaign-create-card {
    background: #fff;
    border-radius: 20px;
    padding: 35px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.cc-section {
    margin-bottom: 30px;
}

.cc-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.cc-section h3 i {
    margin-right: 6px;
    color: #25D366;
}

.cc-field {
    margin-bottom: 18px;
}

.cc-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #444;
    font-size: 14px;
}

.cc-field input[type="text"],
.cc-field input[type="number"],
.cc-field select,
.cc-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    outline: none;
}

.cc-field input:focus,
.cc-field select:focus,
.cc-field textarea:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1);
}

.cc-field textarea {
    min-height: 150px;
    resize: vertical;
    font-family: inherit;
}

.cc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.cc-help {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* Device cards */
.cc-devices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cc-device {
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 14px;
}

.cc-device:hover {
    border-color: #25D366;
    background: #f8fff9;
}

.cc-device.selected {
    border-color: #25D366;
    background: #e8f5e9;
}

.cc-device-radio {
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cc-device.selected .cc-device-radio {
    border-color: #25D366;
}

.cc-device.selected .cc-device-radio::after {
    content: '';
    width: 12px;
    height: 12px;
    background: #25D366;
    border-radius: 50%;
}

/* Checkbox style for multi-select devices */
.cc-device-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cc-device-checkbox i {
    display: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.cc-device.selected .cc-device-checkbox {
    background: #25D366;
    border-color: #25D366;
}

.cc-device.selected .cc-device-checkbox i {
    display: block;
}

.cc-device-info {
    flex: 1;
}

.cc-device-info .name {
    font-weight: 600;
    color: #333;
}

.cc-device-info .phone {
    font-size: 13px;
    color: #666;
}

.cc-device-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.cc-device-status.online {
    background: #d4edda;
    color: #155724;
}

/* Compact device cards for Create Campaign */
.cc-devices-compact {
    margin: 0;
}

.cc-device-card {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: #fff;
}

.cc-device-card:hover {
    border-color: #25D366;
}

.cc-device-card.selected {
    border-color: #25D366;
}

.cc-device-check {
    flex-shrink: 0;
    font-size: 14px;
    color: #adb5bd;
}

.cc-device-card.selected .cc-device-check {
    color: #25D366;
}

.cc-device-card .cc-device-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.cc-device-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-device-phone {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.cc-device-dot.online {
    background: #28a745;
}

.cc-device-dot.offline {
    background: #ffc107;
}

.cc-section-compact {
    padding: 12px 0 !important;
}

/* Contact selector for campaign creation */
.cc-contact-select-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.cc-contact-selector {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    background: #fafafa;
}

.cc-contact-selector-header {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cc-contact-selector-header input {
    flex: 1;
    min-width: 200px;
}

.cc-contact-selector-actions {
    display: flex;
    gap: 5px;
}

.cc-contact-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cc-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.cc-contact-item:hover {
    border-color: #25D366;
    background: #f8fff9;
}

.cc-contact-item.selected {
    border-color: #25D366;
    background: #e8f5e9;
}

.cc-contact-item .cc-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cc-contact-item.selected .cc-checkbox {
    background: #25D366;
    border-color: #25D366;
}

.cc-contact-item.selected .cc-checkbox i {
    color: white;
    font-size: 12px;
}

.cc-contact-item .cc-checkbox i {
    display: none;
}

.cc-contact-item.selected .cc-checkbox i {
    display: block;
}

.cc-contact-item .cc-contact-details {
    flex: 1;
    min-width: 0;
}

.cc-contact-item .cc-contact-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-contact-item .cc-contact-phone {
    font-size: 12px;
    color: #666;
}

/* Contact check icon style */
.cc-contact-check {
    flex-shrink: 0;
    font-size: 16px;
    color: #adb5bd;
}

.cc-contact-item.selected .cc-contact-check {
    color: #25D366;
}

.cc-contact-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.cc-contact-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.cc-contact-phone {
    font-size: 11px;
    color: #888;
}

.cc-device-status.offline {
    background: #fff3cd;
    color: #856404;
}

/* Compact media upload */
.cc-media-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cc-upload-compact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.cc-upload-compact:hover {
    background: #e9ecef;
    border-color: #25D366;
}

.cc-upload-compact i {
    font-size: 18px;
    color: #25D366;
}

/* Media preview */
.cc-file-preview {
    margin-top: 12px;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
}

.cc-preview-content {
    text-align: center;
    margin-bottom: 10px;
}

.cc-preview-content img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    object-fit: cover;
}

.cc-preview-content video {
    max-width: 250px;
    max-height: 150px;
    border-radius: 8px;
}

.cc-preview-content .cc-doc-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.cc-preview-content .cc-doc-preview i {
    font-size: 24px;
    color: #666;
}

.cc-preview-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.cc-preview-name {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.cc-preview-content img {
    cursor: pointer;
    transition: transform 0.2s;
}

.cc-preview-content img:hover {
    transform: scale(1.02);
}

/* Fullscreen preview modal */
.cc-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cc-preview-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.cc-preview-modal-content img,
.cc-preview-modal-content video {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
}

.cc-preview-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    padding: 0 10px;
}

.cc-preview-close:hover {
    color: #ff6b6b;
}

/* Contact info bar */
.cc-contact-info {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.cc-contact-label {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.cc-contact-count {
    font-size: 24px;
    font-weight: 700;
    color: #25D366;
}

.cc-group-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    min-width: 220px;
    outline: none;
}

.cc-group-select:focus {
    border-color: #25D366;
}

/* Placeholder tags */
.cc-placeholders {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.cc-tag {
    background: #e3f2fd;
    color: #1565c0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.cc-tag:hover {
    background: #bbdefb;
}

/* File upload */
.cc-upload {
    display: block;
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    color: #666;
}

.cc-upload:hover {
    border-color: #25D366;
    background: #f8fff9;
    color: #333;
}

.cc-upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: #999;
}

.cc-upload:hover .cc-upload-icon {
    color: #25D366;
}

.cc-file-preview {
    margin-top: 12px;
    padding: 12px 16px;
    background: #e8f5e9;
    border-radius: 10px;
    font-size: 14px;
    color: #2e7d32;
}

/* Anti-ban note */
.cc-antiban-note {
    background: #fff8e1;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 13px;
    color: #f57f17;
    margin-top: 16px;
}

.cc-antiban-note i {
    margin-right: 4px;
}

/* Anti-Ban Protection Section */
.cc-antiban-section {
    border: 2px solid #25D366;
    border-radius: 14px;
    background: linear-gradient(135deg, #f0fff4 0%, #fff 100%);
}

.cc-antiban-section h3 .badge {
    font-size: 11px;
    vertical-align: middle;
    margin-left: 8px;
}

.cc-warmup-box {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.cc-warmup-header {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
}

.cc-warmup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.cc-warmup-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.cc-warmup-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.cc-warmup-progress {
    margin-top: 12px;
}

.cc-warmup-progress small {
    display: block;
    text-align: center;
    margin-top: 6px;
    color: #888;
    font-size: 12px;
}

.cc-limits-table {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

.cc-limits-header {
    background: #f8f9fa;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.cc-limits-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.cc-limits-table th,
.cc-limits-table td {
    padding: 8px 14px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.cc-limits-table th {
    background: #fafafa;
    font-weight: 600;
    color: #555;
}

.cc-limits-table tr:last-child td {
    border-bottom: none;
}

.cc-protections {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

.cc-protections-header {
    background: #f8f9fa;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.cc-protections-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 14px;
}

.cc-protection-item {
    font-size: 13px;
    color: #333;
}

.cc-protection-item i {
    margin-right: 6px;
}

.cc-sleep-info {
    background: #e3f2fd;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    color: #1565c0;
}

.cc-sleep-info i {
    margin-right: 6px;
}

@media (max-width: 768px) {
    .cc-warmup-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .cc-protections-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Submit button */
.cc-submit-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cc-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(37, 211, 102, 0.3);
}

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

.cc-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 600px) {
    .cc-row {
        grid-template-columns: 1fr;
    }
    .campaign-create-card {
        padding: 20px;
    }
    .cc-contact-info {
        flex-direction: column;
        text-align: center;
    }
}

/* ============================================
   WhatsApp-like Inbox
   ============================================ */
.inbox-container {
    display: flex;
    height: calc(100vh - 80px);
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

/* --- Sidebar --- */
.inbox-sidebar {
    width: 350px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    background: #fff;
}

.inbox-sidebar-header {
    padding: 10px 12px;
    background: #f0f2f5;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inbox-sidebar-header .form-select {
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid #d1d7db;
}

.inbox-search-box {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 8px;
    padding: 0 10px;
    border: 1px solid #d1d7db;
}

.inbox-search-box i {
    color: #8696a0;
    font-size: 14px;
}

.inbox-search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px;
    font-size: 13px;
    background: transparent;
}

/* Conversation list */
.inbox-conv-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.inbox-conv-list::-webkit-scrollbar { width: 6px; }
.inbox-conv-list::-webkit-scrollbar-thumb { background: #c5c5c5; border-radius: 3px; }

.inbox-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #8696a0;
}

.inbox-empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
}

.inbox-conv-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.15s;
    gap: 12px;
    border-left: 6px solid transparent;
}
.inbox-conv-item.conv-mine {
    border-left-color: #25D366;
    background: #f0fdf4;
}
.inbox-conv-item.conv-mine:hover { background: #dcfce7; }
.inbox-conv-item.conv-tagged {
    border-left-color: #f59e0b;
    background: #fffbeb;
}
.inbox-conv-item.conv-tagged:hover { background: #fef3c7; }

/* Status dot in conv name */
.conv-status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}
.conv-status-dot.conv-status-pending  { background: #f59e0b; }
.conv-status-dot.conv-status-resolved { background: #25D366; }

/* Assignee / tag badges in time area */
.conv-assignee-badge, .conv-tag-badge {
    font-size: 9px;
    color: #25D366;
    margin-right: 3px;
    vertical-align: middle;
}
.conv-tag-badge { color: #f59e0b; }
.conv-lock-badge { font-size: 9px; color: #dc3545; margin-right: 3px; vertical-align: middle; }
.conv-hide-badge { font-size: 9px; color: #6c757d; margin-right: 3px; vertical-align: middle; }
.conv-is-hidden { opacity: 0.5; font-style: italic; border-left: 3px solid #6c757d !important; }
.conv-is-hidden .inbox-conv-name { color: #6c757d !important; }
.conv-is-hidden:hover { opacity: 0.75; }

/* Conv toolbar (status + assign/tag) */
.inbox-conv-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
    flex-wrap: wrap;
}
.conv-status-btns {
    display: flex;
    gap: 4px;
}
.conv-status-btn {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid #d1d7db;
    background: #fff;
    cursor: pointer;
    color: #54656f;
    transition: all 0.15s;
}
.conv-status-btn[data-status="open"].active    { background: #25D366; color: #fff; border-color: #25D366; }
.conv-status-btn[data-status="pending"].active { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.conv-status-btn[data-status="resolved"].active{ background: #8696a0; color: #fff; border-color: #8696a0; }
.conv-status-btn:hover { border-color: #25D366; color: #25D366; }

.conv-assign-me-btn {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid #25D366;
    background: #fff;
    color: #25D366;
    cursor: pointer;
    transition: all 0.15s;
}
.conv-assign-me-btn:hover { background: #25D366; color: #fff; }

.conv-assign-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.conv-assigned-label {
    font-size: 11px;
    color: #25D366;
    font-weight: 600;
}
.conv-tag-dropdown { position: relative; }
.conv-tag-trigger {
    background: none;
    border: 1px solid #d1d7db;
    border-radius: 50%;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: #54656f;
    font-size: 14px;
    transition: all 0.15s;
}
.conv-tag-trigger:hover { border-color: #25D366; color: #25D366; }
.conv-tag-menu {
    position: absolute;
    right: 0; top: 32px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.14);
    min-width: 180px;
    z-index: 999;
    overflow: hidden;
}
.conv-tag-section-label {
    padding: 6px 12px 2px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #8696a0;
    letter-spacing: 0.5px;
}
.conv-tag-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
}
.conv-tag-menu-item:hover { background: #f0f2f5; }
.conv-tag-menu-item.assigned, .conv-tag-menu-item.is-tagged { color: #25D366; font-weight: 600; }

.inbox-conv-item:hover {
    background: #f5f6f6;
}

.inbox-conv-item.active {
    background: #f0f2f5;
}

.inbox-conv-item .inbox-conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #dfe5e7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 20px;
    overflow: hidden;
    position: relative;
}

.inbox-conv-item .inbox-conv-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.inbox-conv-item .inbox-conv-avatar.has-unread {
    background: #25D366;
}

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

.inbox-conv-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.inbox-conv-name {
    font-weight: 600;
    font-size: 15px;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-conv-time {
    font-size: 12px;
    color: #8696a0;
    white-space: nowrap;
    margin-left: 6px;
}

.inbox-conv-time.has-unread {
    color: #25D366;
    font-weight: 600;
}

.inbox-conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.inbox-conv-preview {
    font-size: 13px;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.inbox-conv-badge {
    background: #25D366;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: 6px;
    flex-shrink: 0;
}

/* Stats bar */
.inbox-stats-bar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f0f2f5;
    border-top: 1px solid #e0e0e0;
    gap: 8px;
    flex-wrap: wrap;
    overflow: visible;
}

.inbox-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Clickable filter stats */
.inbox-stat.inbox-filter {
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.15s;
    border: 2px solid transparent;
}

.inbox-stat.inbox-filter:hover {
    background: #e9edef;
}

.inbox-stat.inbox-filter.active {
    background: #d9fdd3;
    border-color: #25D366;
}

.inbox-stat-num {
    font-weight: 700;
    font-size: 14px;
    color: #111b21;
}

.inbox-stat-num.inbox-stat-unread {
    color: #25D366;
}

.inbox-stat-label {
    font-size: 10px;
    color: #8696a0;
    text-transform: uppercase;
}

.inbox-sync-buttons {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.inbox-sync-btn {
    background: none;
    border: 1px solid #d1d7db;
    border-radius: 8px;
    padding: 4px 10px;
    cursor: pointer;
    color: #54656f;
    transition: background 0.15s;
}

.inbox-sync-btn:hover {
    background: #e9edef;
}

.inbox-sync-btn.force-sync {
    background: #e3f2fd;
    border-color: #90caf9;
    color: #1976d2;
}

/* --- Chat panel --- */
.inbox-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
    min-width: 0;
}

.inbox-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f0f2f5;
    border-bottom: 1px solid #d1d7db;
    min-height: 60px;
    flex-shrink: 0;
}

.inbox-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.inbox-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #dfe5e7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 18px;
}

.inbox-chat-name {
    font-weight: 600;
    font-size: 16px;
    color: #111b21;
}

.inbox-chat-phone {
    font-size: 13px;
    color: #8696a0;
}

.inbox-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.inbox-chat-header-actions .dropdown {
    display: flex;
    align-items: center;
}

.inbox-header-btn {
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: #54656f;
    font-size: 18px;
    transition: background 0.15s;
}

.inbox-header-btn:hover {
    background: #e9edef;
}

/* Messages area */
.inbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 60px;
    background: #e5ddd5;
    position: relative;
}

.inbox-messages::-webkit-scrollbar { width: 6px; }
.inbox-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }

/* Scroll to bottom button */
.inbox-scroll-bottom {
    position: fixed;
    bottom: 100px;
    right: 80px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #54656f;
    font-size: 20px;
    transition: all 0.2s;
    z-index: 100;
}

.inbox-scroll-bottom:hover {
    background: #f0f2f5;
    transform: scale(1.05);
}

.inbox-scroll-bottom.has-new {
    background: #25D366;
    color: white;
}

.inbox-chat-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.inbox-chat-placeholder-inner {
    text-align: center;
    color: #8696a0;
    background: rgba(255,255,255,0.85);
    padding: 40px;
    border-radius: 12px;
}

.inbox-chat-placeholder-inner i {
    font-size: 60px;
    display: block;
    margin-bottom: 12px;
    color: #25D366;
}

.inbox-chat-placeholder-inner h5 {
    color: #41525d;
    margin-bottom: 8px;
}

/* Chat bubbles */
.chat-msg {
    display: flex;
    margin-bottom: 3px;
}

.chat-msg.outgoing {
    justify-content: flex-end;
}

.chat-msg.incoming {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 65%;
    padding: 6px 8px 4px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
}

.chat-msg.outgoing .chat-bubble {
    background: #d9fdd3;
    border-top-right-radius: 0;
}

/* Per-session color tag inside outgoing bubbles */
.chat-session-tag {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.chat-msg.incoming .chat-bubble {
    background: #fff;
    border-top-left-radius: 0;
}

.chat-bubble-text {
    font-size: 14px;
    line-height: 1.4;
    color: #111b21;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble-text a {
    color: #027eb5;
    text-decoration: underline;
}

.chat-msg.outgoing .chat-bubble-text a {
    color: #024d6e;
}

.inbox-conv-labels {
    display: flex;
    gap: 3px;
    margin-top: 2px;
    flex-wrap: wrap;
}
.inbox-label {
    font-size: 9px;
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}

.chat-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.chat-bubble-time {
    font-size: 11px;
    color: #667781;
}

/* Sticker messages — no bubble background, floating image */
.chat-sticker-msg .chat-bubble {
    background: none !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
}
.chat-sticker-msg .chat-bubble-footer {
    position: absolute;
    bottom: 4px;
    right: 6px;
    background: rgba(0,0,0,0.35);
    border-radius: 8px;
    padding: 1px 5px;
    margin-top: 0;
}
.chat-sticker-msg .chat-bubble-time { color: #fff; }
.chat-sticker-msg .chat-bubble { position: relative; display: inline-block; }
.chat-sticker-msg .chat-media img { border-radius: 4px; }

.chat-reactions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}
.chat-reaction {
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 1px 5px;
    font-size: 14px;
    border: 1px solid rgba(0,0,0,0.08);
}

/* Status ticks */
.chat-status-tick {
    display: inline-flex;
    font-size: 14px;
    color: #8696a0;
}

.chat-status-tick.status-sent { color: #8696a0; }
.chat-status-tick.status-delivered { color: #8696a0; }
.chat-status-tick.status-read { color: #53bdeb; }

/* Media in chat */
.chat-media {
    margin-bottom: 4px;
    border-radius: 6px;
    overflow: hidden;
}

.chat-media img {
    max-width: 300px;
    max-height: 300px;
    display: block;
    border-radius: 6px;
    cursor: pointer;
}

.chat-media video {
    max-width: 300px;
    max-height: 300px;
    display: block;
    border-radius: 6px;
}

.chat-media-doc {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.04);
    border-radius: 6px;
    font-size: 13px;
    color: #111b21;
}

.chat-media-doc i {
    font-size: 24px;
    color: #54656f;
}

.chat-media-placeholder {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(0,0,0,0.06);
    border-radius: 6px;
    font-size: 13px;
    color: #667781;
    font-style: italic;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-media-placeholder:hover {
    background: rgba(0,0,0,0.1);
    color: #25D366;
}

.chat-media-placeholder i {
    font-size: 18px;
}

.chat-media-placeholder .ms-auto {
    margin-left: auto;
    font-size: 14px;
    opacity: 0.6;
    animation: dl-nudge 2.5s ease-in-out infinite;
}

.chat-media-placeholder:hover .ms-auto {
    opacity: 1;
    animation: none;
}

.voice-transcript {
    margin-top: 4px;
    font-size: 0.72rem;
    color: #555;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-left: 2px solid #8b5cf6;
    padding-left: 5px;
    transition: max-height .2s ease;
}
.voice-transcript.expanded {
    max-height: 200px;
    white-space: normal;
    text-overflow: unset;
}
}

@keyframes dl-nudge {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    80% { transform: translateY(3px); opacity: 1; }
}

/* Voice upload pending bubble */
.chat-upload-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: #667781;
    font-size: 13px;
    font-style: italic;
    min-width: 160px;
}

.chat-upload-pending i {
    font-size: 20px;
    color: #25D366;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

.refresh-spin {
    animation: spin 1s linear infinite;
}

/* Quoted message */
.chat-quoted {
    background: rgba(0,0,0,0.05);
    border-left: 4px solid #25D366;
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 12px;
}

.chat-quoted-name {
    font-weight: 600;
    color: #25D366;
    font-size: 12px;
}

.chat-quoted-text {
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.merge-result-item {
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
}
.merge-result-item:hover { background: #f0f2f5; }
.merge-result-item.selected { background: #e8f5e9; border-color: #25D366; }

.chat-status-reply-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(37,211,102,0.12);
    border-left: 3px solid #25D366;
    border-radius: 4px;
    padding: 2px 8px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #128C7E;
}

/* Date separator */
/* Chat loading skeleton */
.chat-loading-skeleton {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.skel-bubble {
    height: 38px;
    width: 55%;
    border-radius: 12px;
    background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: skel-shimmer 1.2s infinite;
}
.skel-bubble.outgoing { align-self: flex-end; }
.skel-bubble.wide { width: 72%; }
.skel-bubble.short { width: 35%; }
@keyframes skel-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.chat-date-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
}

.chat-date-sep span {
    background: rgba(225,218,208,0.88);
    color: #54656f;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
}

/* Reply action on bubble */
.chat-bubble-actions {
    display: none;
    position: absolute;
    top: 4px;
    gap: 3px;
    align-items: center;
}
.chat-msg.outgoing .chat-bubble-actions { left: -100px; flex-direction: row-reverse; }
.chat-msg.incoming .chat-bubble-actions { right: -100px; }
.chat-msg:hover .chat-bubble-actions { display: flex; }

.chat-action-btn {
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #8696a0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.chat-action-btn:hover { background: #fff; color: #3b82f6; }

/* ── Message action menu (three-dot dropdown) ── */
.chat-action-dropdown { position: relative; }
.chat-msg-menu, .chat-delete-menu {
    position: absolute;
    top: 32px;
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    z-index: 999;
    min-width: 180px;
    overflow: hidden;
}
.chat-msg-menu.menu-up, .chat-delete-menu.menu-up { top: auto; bottom: 32px; }
.chat-msg.outgoing .chat-msg-menu,
.chat-msg.outgoing .chat-delete-menu { right: auto; left: 0; }
.chat-msg-menu button, .chat-delete-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    color: #1a1a1a;
    gap: 2px;
}
.chat-msg-menu button:hover, .chat-delete-menu button:hover { background: #f0f2f5; }
.chat-menu-danger { color: #e53e3e !important; }
.chat-menu-divider { margin: 3px 0; border: none; border-top: 1px solid #f0f2f5; }

/* Speed row inside message menu */
.chat-speed-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-top: 1px solid #f0f2f5;
    border-bottom: 1px solid #f0f2f5;
}
.chat-speed-label { font-size: 11px; color: #8696a0; flex-shrink: 0; margin-right: 2px; }
.speed-btn {
    flex: 1;
    padding: 3px 0;
    background: #f0f2f5;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: #111b21;
    text-align: center;
}
.speed-btn:hover { background: #25D366; color: #fff; }
.chat-deleted-badge {
    font-size: 11px;
    color: #e74c3c;
    font-style: italic;
    margin-bottom: 4px;
    opacity: 0.8;
}
.chat-deleted-badge.chat-deleted-everyone {
    color: #888;
    font-style: italic;
    font-size: 12px;
    opacity: 1;
    border-left: 2px solid #ccc;
    padding-left: 6px;
}
.chat-bubble-text.chat-deleted-content {
    opacity: 0.55;
    text-decoration: line-through;
    font-size: 13px;
}
.msg-highlight { animation: highlightFade 2s ease; }
@keyframes highlightFade {
    0%,20% { background: rgba(37,211,102,0.25); border-radius: 8px; }
    100% { background: transparent; }
}

/* Reply preview bar */
.inbox-reply-bar,
.inbox-file-bar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: #f0f2f5;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.inbox-reply-preview,
.inbox-file-preview {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    border-left: 3px solid #25D366;
    padding-left: 8px;
}

.inbox-reply-name {
    font-weight: 600;
    font-size: 13px;
    color: #25D366;
}

.inbox-reply-text {
    font-size: 13px;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-reply-close,
.inbox-file-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #8696a0;
    font-size: 16px;
    padding: 4px 8px;
}

.inbox-file-preview i {
    font-size: 20px;
    color: #54656f;
}

.inbox-file-preview span {
    font-size: 13px;
    color: #111b21;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Input area */
.inbox-input-area {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f0f2f5;
    gap: 8px;
    flex-shrink: 0;
}

.inbox-attach-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #54656f;
    font-size: 22px;
    padding: 4px;
    transition: color 0.15s;
}

.inbox-attach-btn:hover {
    color: #111b21;
}

.inbox-input-form {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inbox-text-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    resize: none;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    font-family: inherit;
}

.inbox-send-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #54656f;
    font-size: 22px;
    padding: 4px 8px;
    transition: color 0.15s;
}

.inbox-send-btn:hover {
    color: #25D366;
}

/* Mic button */
.inbox-mic-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #54656f;
    font-size: 20px;
    padding: 4px 6px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.inbox-mic-btn:hover { color: #25D366; }

/* Voice recording bar */
.inbox-recording-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: #fff;
    border-top: 1px solid #e9edef;
}
.rec-cancel-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #ea4335;
    font-size: 18px;
    padding: 4px 6px;
}
.rec-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ea4335;
    animation: recPulse 1s infinite;
    flex-shrink: 0;
}
@keyframes recPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.rec-timer {
    font-size: 15px;
    font-weight: 600;
    color: #111b21;
    font-variant-numeric: tabular-nums;
}
.rec-send-btn {
    background: #25D366;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.rec-send-btn:hover { background: #128C7E; }

/* Highlight animation for scrollToMessage */
.chat-msg-highlight {
    animation: highlightMsg 1.5s ease;
}

@keyframes highlightMsg {
    0%, 100% { background: transparent; }
    25% { background: rgba(37, 211, 102, 0.2); }
}

/* Mobile back button — hidden on desktop */
.inbox-mobile-back {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #3b4a54;
    font-size: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
}
.inbox-mobile-back:hover { background: rgba(0,0,0,0.07); }

/* --- Responsive --- */
@media (max-width: 768px) {
    /* Inbox page: fixed to exact remaining screen */
    #page-inbox {
        position: fixed;
        top: 42px;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        padding: 0;
        z-index: 10;
    }

    .inbox-container {
        flex-direction: row;
        height: 100%;
        position: relative;
        overflow: hidden;
        touch-action: pan-y;
        max-width: 100%;
        border-radius: 0;
    }

    /* Sidebar: full screen, slides left when chat opens */
    .inbox-sidebar {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        min-width: unset;
        max-height: none;
        border-right: none;
        border-bottom: none;
        z-index: 2;
        transition: transform 0.28s ease;
    }

    /* Chat panel: full screen, starts off-screen right */
    .inbox-chat {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateX(100%);
        transition: transform 0.28s ease;
        z-index: 3;
    }
    .inbox-messages {
        min-height: 0;
    }

    /* Chat panel off-screen — disable pointer events so taps reach sidebar */
    .inbox-container .inbox-chat {
        pointer-events: none;
    }

    /* When a conversation is open on mobile */
    .inbox-container.mobile-chat-open .inbox-sidebar {
        transform: translateX(-100%);
        pointer-events: none;
    }
    .inbox-container.mobile-chat-open .inbox-chat {
        transform: translateX(0);
        pointer-events: auto;
    }

    /* Show back button on mobile */
    .inbox-mobile-back {
        display: flex;
    }

    /* Compact conversation list items on mobile */
    .inbox-conv-item {
        padding: 7px 48px;
        gap: 9px;
    }
    .inbox-conv-item .inbox-conv-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    .inbox-conv-name {
        font-size: 13px;
    }
    .inbox-conv-preview {
        font-size: 12px;
    }
    .inbox-conv-time {
        font-size: 11px;
    }

    .inbox-messages {
        padding: 4px 2px 0;
        overflow-x: hidden;
    }
    .inbox-chat-header {
        padding: 1px 4px;
        min-height: 0;
    }
    .inbox-chat-header .inbox-avatar {
        display: none;
    }
    .inbox-chat-header-info {
        gap: 6px;
    }
    .inbox-chat-name {
        font-size: 12px;
        line-height: 1.2;
    }
    .inbox-chat-phone {
        font-size: 9px;
        line-height: 1.2;
    }
    .inbox-input-area {
        padding: 2px 4px;
        padding-bottom: max(2px, env(safe-area-inset-bottom, 2px));
        max-width: 100%;
        box-sizing: border-box;
        border-top: none;
        margin-top: 0;
    }
    .inbox-reply-bar,
    .inbox-file-bar {
        max-width: 100%;
        box-sizing: border-box;
    }
    .inbox-messages {
        padding-bottom: 2px;
    }
    .inbox-text-input {
        padding: 3px 6px;
        font-size: 12px;
    }
    .chat-msg {
        margin-bottom: 1px;
        max-width: 100%;
    }
    .chat-bubble {
        max-width: 92%;
        padding: 2px 5px 2px;
        border-radius: 5px;
        word-break: break-all;
    }
    .chat-bubble-text {
        font-size: 11px;
        line-height: 1.25;
    }
    .chat-bubble-time {
        font-size: 8px;
    }
    .chat-bubble-footer {
        margin-top: 0;
        gap: 2px;
    }
    .chat-media img,
    .chat-media video {
        max-width: 130px;
        max-height: 130px;
    }
    .chat-media-doc {
        font-size: 10px;
        padding: 3px 6px;
        gap: 4px;
    }
    .chat-media-doc i {
        font-size: 14px;
    }
    .chat-session-tag {
        font-size: 8px;
        margin-bottom: 1px;
    }
    .inbox-attach-btn,
    .inbox-send-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* Group members panel */
.inbox-group-panel {
    width: 260px;
    min-width: 260px;
    border-left: 1px solid #e0e0e0;
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.inbox-group-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 14px;
    background: #f0f2f5;
}
.inbox-group-member-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}
.inbox-group-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid #f5f5f5;
}
.inbox-group-member-row:hover { background: #f9f9f9; }
.inbox-group-member-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
#login-error {
    animation: shake 0.4s ease;
}

/* ── In-chat search bar ── */
.inbox-chat-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f2f5;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}
.inbox-chat-search-input {
    flex: 1;
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    outline: none;
    background: #fff;
}
.inbox-chat-search-nav, .inbox-chat-search-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #54656f;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 50%;
}
.inbox-chat-search-nav:hover, .inbox-chat-search-close:hover { background: #e0e0e0; }
.inbox-search-count { font-size: 11px; color: #8696a0; min-width: 36px; text-align: center; }
.chat-msg.search-match .chat-bubble { outline: 2px solid #25D366; outline-offset: 2px; border-radius: 10px; }
.chat-msg.search-current .chat-bubble { outline: 2px solid #128C7E; background: rgba(37,211,102,0.06); }

/* ── Contact info panel ── */
.inbox-contact-panel {
    width: 300px;
    min-width: 300px;
    border-left: 1px solid #e0e0e0;
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.inbox-contact-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 14px;
    background: #128C7E;
    color: #fff;
}
.inbox-contact-back {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}
.inbox-contact-panel-body {
    flex: 1;
    overflow-y: auto;
}
.inbox-contact-profile {
    text-align: center;
    padding: 20px 16px 14px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9ecef;
}
.inbox-contact-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #d0d0d0;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 10px;
    overflow: hidden;
}
.inbox-contact-name {
    font-weight: 700;
    font-size: 16px;
    color: #1a1a1a;
}
.inbox-contact-phone { font-size: 12px; color: #8696a0; margin-top: 2px; }
.inbox-contact-section {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f2f5;
}
.inbox-contact-section-title { font-size: 11px; font-weight: 600; color: #128C7E; text-transform: uppercase; margin-bottom: 6px; }
.inbox-contact-about { font-size: 13px; color: #3b4a54; }

/* CI media/docs/links/starred tabs */
.ci-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.ci-media-thumb {
    aspect-ratio: 1;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #888;
}
.ci-media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ci-media-video { background: #1a1a2e; color: #fff; }
.ci-doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid #f5f5f5;
}
.ci-link-item {
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ci-starred-item {
    display: flex;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
}
.ci-starred-item:hover { background: #f9f9f9; }

/* ── Edit message ── */
.chat-edited-label {
    font-size: 10px;
    color: #8696a0;
    font-style: italic;
    margin-right: 5px;
}
.chat-edit-box {
    margin-top: 4px;
}
.chat-edit-input {
    width: 100%;
    border: 1px solid #25D366;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    resize: none;
    outline: none;
    background: #fff;
    font-family: inherit;
}
.chat-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 5px;
    justify-content: flex-end;
}
.chat-edit-save, .chat-edit-cancel {
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
}
.chat-edit-save { background: #25D366; color: #fff; }
.chat-edit-save:hover { background: #128C7E; }
.chat-edit-cancel { background: #f0f2f5; color: #54656f; }
.chat-edit-cancel:hover { background: #e0e0e0; }

/* Edit History Popup */
.edit-history-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    min-width: 260px;
    max-width: 360px;
    font-size: 13px;
    overflow: hidden;
}
.eh-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    font-weight: 600;
    font-size: 13px;
    color: #111b21;
    border-bottom: 1px solid #f0f2f5;
}
.eh-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #8696a0;
    cursor: pointer;
    padding: 0 2px;
}
.eh-close:hover { color: #111b21; }
.eh-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 0;
}
.eh-item {
    padding: 8px 14px;
    border-bottom: 1px solid #f0f2f5;
}
.eh-item:last-child { border-bottom: none; }
.eh-label {
    font-size: 11px;
    color: #8696a0;
    margin-bottom: 3px;
}
.eh-time {
    font-style: italic;
}
.eh-content {
    color: #111b21;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Contact card message bubble */
.chat-contact-card {
    min-width: 220px;
    max-width: 280px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0,0,0,0.04);
    margin-bottom: 2px;
}
.chat-contact-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}
.chat-contact-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #d0d3d8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}
.chat-contact-card-info {
    flex: 1;
    min-width: 0;
}
.chat-contact-card-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-contact-card-phone {
    font-size: 12px;
    color: #667781;
    margin-top: 1px;
}
.chat-contact-card-footer {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 0;
}
.chat-contact-card-btn {
    width: 100%;
    background: none;
    border: none;
    padding: 8px 12px;
    color: #0d6efd;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.chat-contact-card-btn:hover {
    background: rgba(13,110,253,0.07);
}

/* Group message sender name */
.chat-group-sender {
    font-size: 12px;
    font-weight: 600;
    color: #0d6efd;
    margin-bottom: 2px;
    line-height: 1.2;
}
.chat-group-sender[onclick]:hover {
    text-decoration: underline;
    color: #0a58ca;
}

/* Link Preview Card */
.chat-link-preview {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 6px;
    border: 1px solid rgba(0,0,0,0.1);
    text-decoration: none;
    background: rgba(0,0,0,0.04);
    max-width: 320px;
    cursor: pointer;
    transition: background 0.15s;
}
.chat-link-preview:hover { background: rgba(0,0,0,0.08); }
.outgoing .chat-link-preview { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.2); }
.outgoing .chat-link-preview:hover { background: rgba(255,255,255,0.25); }
.chat-link-preview-thumb {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    display: block;
}
.chat-link-preview-body {
    padding: 6px 8px;
}
.chat-link-preview-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chat-link-preview-desc {
    font-size: 11px;
    opacity: 0.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 2px;
}
.chat-link-preview-url {
    font-size: 10px;
    opacity: 0.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop: give input area and recording bar extra right padding so they clear the ichat floating bubble */
@media (min-width: 769px) {
    .inbox-input-area,
    .inbox-recording-bar {
        padding-right: 84px;
    }
}
