* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; background: #f8fafc; }

/* Header with Bootstrap */
header.bg-gradient-primary { 
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important; 
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
header h1 { 
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
header .lead {
    opacity: 0.95;
}

/* Bootstrap Navbar Customization */
.navbar-brand {
    color: #d97706 !important;
    font-weight: 700;
}
.navbar-nav .nav-link {
    color: #64748b !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: color 0.3s ease;
}
.navbar-nav .nav-link:hover {
    color: #d97706 !important;
}
.navbar-toggler {
    border-color: #d97706;
}
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28217, 119, 6, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Navigation */
.nav-container {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}
.nav a {
    padding: 1rem 0;
    color: #64748b;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}
.nav a:hover,
.nav a.active {
    color: #d97706;
    border-bottom-color: #d97706;
}

/* Navigation Auth Buttons */
.nav-auth-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-auth-buttons .btn {
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-auth-buttons .btn-outline {
    background: transparent;
    border: 2px solid #d97706;
    color: #d97706;
}

.nav-auth-buttons .btn-outline:hover {
    background: #d97706;
    color: white;
}

.nav-auth-buttons .btn {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
    border: none;
}

.nav-auth-buttons .btn:hover {
    background: linear-gradient(135deg, #ea580c 0%, #9a3412 100%);
    transform: translateY(-1px);
}

/* Main Content */
main { 
    padding: 2rem 1rem; 
    max-width: 1200px; 
    margin: 0 auto; 
}

/* Hero */
.hero {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 2rem;
    align-items: center;
    background: linear-gradient(135deg, #fff 0%, #fff 60%),
                radial-gradient(1200px 500px at 0% 0%, #fff 40%, #fff0 41%),
                linear-gradient(135deg, #fffbeb 0%, #fff7ed 100%);
    border: 1px solid #fde68a;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}
.hero-content h2 {
    color: #1e293b;
    font-size: 2.2rem;
    margin: 0 0 0.75rem 0;
}
.hero-content p {
    color: #64748b;
    font-size: 1.05rem;
    margin: 0 0 1.25rem 0;
}
.hero-actions { display: flex; gap: 1rem; }
.hero-image img {
    width: 100%;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    object-fit: cover;
}

/* Features */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}
.feature-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.feature-card h3 {
    margin: 0.25rem 0 0.5rem 0;
    color: #1e293b;
}
.feature-card p {
    margin: 0;
    color: #64748b;
}

/* Sections */
.section {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}
.section h2 {
    color: #d97706;
    margin: 0 0 1rem 0;
    font-size: 1.8rem;
    border-bottom: 2px solid #fed7aa;
    padding-bottom: 0.5rem;
}

/* Section Grid Layouts */
.section-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1.5rem;
    align-items: center;
}
.section-grid.reverse { grid-template-columns: 0.9fr 1.1fr; }
.section-content p { margin-top: 0.5rem; }
.section-image img {
    width: 100%;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    object-fit: cover;
}

/* Cards */
.grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: 1.5rem; 
    margin: 1.5rem 0;
}
.card { 
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}
.card h3 {
    color: #1e293b;
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}
.card p {
    color: #64748b;
    margin: 0.5rem 0;
    line-height: 1.5;
}

/* Badges */
.badge { 
    display: inline-block; 
    padding: 0.25rem 0.75rem; 
    border-radius: 999px; 
    background: #ffedd5;
    color: #9a3412;
    font-size: 0.875rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

.admin-badge {
    background: #dcfce7;
    color: #166534;
}

.user-badge {
    background: #dbeafe;
    color: #1e40af;
}

.binary-badge {
    background: #fef3c7;
    color: #92400e;
}

.referral-badge {
    background: #ede9fe;
    color: #5b21b6;
}

/* Status indicators */
.status {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status.active {
    background: #dcfce7;
    color: #166534;
}

.status.inactive {
    background: #fef2f2;
    color: #dc2626;
}

.status.pending {
    background: #fef3c7;
    color: #92400e;
}

.status.approved {
    background: #d1fae5;
    color: #065f46;
}

.status.paid {
    background: #dcfce7;
    color: #166534;
}

.status.rejected {
    background: #fef2f2;
    color: #dc2626;
}

.status.suspended {
    background: #fee2e2;
    color: #b91c1c;
}

/* Admin Dashboard Styles */
.dashboard-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #1e293b;
    color: white;
    padding: 1rem 0;
}

.user-info {
    padding: 1rem;
    border-bottom: 1px solid #334155;
    text-align: center;
}

.user-avatar {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.user-details h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.user-role {
    background: #f59e0b;
    color: #000;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #334155;
    color: white;
    border-left-color: #f59e0b;
}

.nav-item.active {
    background: #334155;
    color: white;
    border-left-color: #f59e0b;
}

.main-content {
    background: #f8fafc;
    padding: 0;
}

.content-header {
    background: white;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-header h1 {
    margin: 0;
    color: #1e293b;
}

.section-content {
    padding: 2rem;
}

.section-content.hidden {
    display: none;
}

/* Utility: globally hide elements when 'hidden' class is applied */
.hidden {
    display: none !important;
}

/* Warning Modal visibility tweaks */
#warningModal .modal-content {
    border-width: 2px;
}
#warningModal .modal-header {
    background: #dc3545; /* Bootstrap danger */
    color: #fff;
}
#warningModal .modal-title {
    font-weight: 700;
}
#warningModal .modal-body {
    font-size: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
    color: #1e293b;
}

.stat-info p {
    margin: 0;
    color: #64748b;
    font-size: 0.875rem;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.chart-card h3 {
    margin: 0 0 1rem 0;
    color: #1e293b;
}

.chart-content {
    min-height: 200px;
}

.list-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

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

.item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.item-details {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #64748b;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin: 0;
    color: #1e293b;
}

.section-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

.data-table tr:hover {
    background: #f8fafc;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-outline {
    background: transparent;
    color: #1f2937;
    border: 1px solid #d1d5db;
}

.btn-outline:hover {
    background: #f3f4f6;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #f59e0b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    background: #10b981;
}

.notification.error {
    background: #ef4444;
}

.notification.info {
    background: #3b82f6;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.info-text {
    color: #64748b;
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.loading {
    color: #64748b;
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* Price */
.price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #059669;
    margin: 0.5rem 0;
}

/* WebSocket Status */
#ws-status { 
    padding: 1rem; 
    background: #fef3c7; 
    border: 1px solid #f59e0b; 
    border-radius: 8px; 
    margin: 1rem 0;
    font-weight: 500;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #ea580c 0%, #9a3412 100%);
}

/* Images Uploader */
.images-uploader {
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    padding: 1rem;
    background: #fff;
}
.images-uploader .upload-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.images-uploader #pf-images-upload {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem;
    background: #f8fafc;
}
.images-uploader .url-adder {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}
.image-card {
    position: relative;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.image-card img {
    display: block;
    width: 100%;
    height: 100px;
    object-fit: cover;
}
.image-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 6px;
}
.image-btn {
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 999px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.image-btn:hover { background: rgba(0,0,0,0.8); }
.primary-badge {
    position: absolute;
    left: 6px;
    top: 6px;
    background: #f59e0b;
    color: #111827;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}
.upload-hint {
    margin-top: 0.5rem;
    color: #64748b;
    font-size: 0.85rem;
}

/* Footer */
footer { 
    background: #1e293b; 
    color: #cbd5e1; 
    padding: 2rem 1rem; 
    text-align: center; 
    margin-top: 3rem;
}
footer p {
    margin: 0.5rem 0;
}

/* Bootstrap Color Overrides */
.btn-primary {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border: none;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #ea580c 0%, #9a3412 100%);
    transform: translateY(-1px);
}
.btn-outline-primary {
    border-color: #d97706;
    color: #d97706;
}
.btn-outline-primary:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border-color: #d97706;
}
.text-primary {
    color: #d97706 !important;
}
.border-bottom {
    border-color: #fed7aa !important;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    header h1 { font-size: 1.75rem; }
    header .lead { font-size: 1rem; }
    .display-5 { font-size: 1.75rem !important; }
    .section { padding: 1.5rem !important; }
    .hero { padding: 1.5rem !important; }
    .navbar-nav {
        padding-top: 1rem;
        text-align: center;
    }
    .navbar-nav .nav-link {
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid #e2e8f0;
    }
    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
    .navbar-collapse .d-flex {
        width: 100%;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid #e2e8f0;
    }
    .navbar-collapse .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .hero .btn-lg {
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }
}

@media (max-width: 576px) {
    header h1 { font-size: 1.5rem; }
    header .lead { font-size: 0.95rem; }
    .display-5 { font-size: 1.5rem !important; }
    .section { padding: 1rem !important; }
    .hero { padding: 1rem !important; }
    .feature-card {
        margin-bottom: 1rem;
    }
}

/* Lists */
ul { 
    padding-left: 1.5rem; 
    margin: 1rem 0;
}
ul li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

/* Text */
h1, h2, h3, h4, h5, h6 {
    color: #1e293b;
}

/* Links */
a {
    color: #d97706;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
/* ===== MODERN CHAT INTERFACE ===== */
.chat-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: min(600px, 85vh);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
}

/* Chat Sidebar */
.chat-sidebar {
  background: #f8fafc;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.sidebar-header .badge {
  background: #3b82f6;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin: 4px 0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

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

.conversation-item.active {
  background: #3b82f6;
  color: white;
}

.conversation-item.active .conversation-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.conversation-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  margin-right: 12px;
  flex-shrink: 0;
}

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

.conversation-name {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-preview {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.active .conversation-preview {
  color: rgba(255, 255, 255, 0.8);
}

.conversation-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.conversation-time {
  font-size: 11px;
  color: #9ca3af;
}

.conversation-item.active .conversation-time {
  color: rgba(255, 255, 255, 0.7);
}

.conversation-badge {
  background: #ef4444;
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  min-width: 18px;
  text-align: center;
}

/* Chat Main Area */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0; /* allow inner scroll areas to shrink */
  background: #fff;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  font-weight: 600;
}

.user-details h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.chat-status {
  font-size: 13px;
  color: #6b7280;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: #f8fafc;
  border-color: #d1d5db;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow: hidden;
  min-height: 0; /* ensure the scroll child can size correctly */
  position: relative;
}

.messages-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 88px; /* space so last messages aren’t covered by composer */
  background: #f8fafc;
}

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.welcome-message h3 {
  margin: 0 0 8px 0;
  color: #374151;
  font-weight: 600;
}

.welcome-message p {
  margin: 0;
  font-size: 14px;
}

/* Message Bubbles */
.message-group {
  margin-bottom: 16px;
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  margin: 4px 0;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
}

.message-bubble.user {
  background: #3b82f6;
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 6px;
}

.message-bubble.admin {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  margin-right: auto;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

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

.message-bubble.admin .message-time {
  text-align: left;
  color: #6b7280;
}

.message-bubble.user .message-time {
  color: rgba(255, 255, 255, 0.8);
}

/* Day Separator */
.day-separator {
  text-align: center;
  margin: 12px 0;
}
.day-separator .label {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
}

/* Typing Indicator */
.typing-indicator {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  font-size: 13px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Message Input */
.message-input-container {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  position: sticky;
  bottom: 0;
  z-index: 2; /* keep above messages content */
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
}

.message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  background: #f8fafc;
}

.message-input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.message-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #3b82f6;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  background: #2563eb;
  transform: scale(1.05);
}

.send-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

.message-status {
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
  text-align: center;
  min-height: 20px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: flex-end;
    margin: 12px 0;
    animation: fadeIn 0.3s ease;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-right: 8px;
    flex-shrink: 0;
}

.typing-content {
    background: #f8f9fa;
    border-radius: 18px;
    padding: 12px 16px;
    max-width: 200px;
}

.typing-text {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 4px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

/* Smooth animations for messages */
.message {
    animation: messageSlideIn 0.3s ease;
}

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

/* Conversation item animations */
.conversation-item {
    transition: all 0.2s ease;
}

.conversation-item:hover {
    background: #f8f9fa;
    transform: translateX(4px);
}

.conversation-item.active {
    background: #e3f2fd;
    border-left: 3px solid #007bff;
}

/* Button animations */
.send-button {
    transition: all 0.2s ease;
}

.send-button:active {
    transform: scale(0.95);
}

/* Message input focus animation */
.message-input {
    transition: all 0.2s ease;
}

.message-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

/* Chat container transitions */
.chat-container {
    transition: all 0.3s ease;
}

/* Loading animation */
.loading {
    animation: pulse 1.5s infinite ease-in-out;
}

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

/* Badge animations */
.conversation-badge {
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Scrollbar styling with smooth transitions */
.messages-scroll::-webkit-scrollbar {
    width: 6px;
}

.messages-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.messages-scroll::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.messages-scroll::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Search Container */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: #6b7280;
  z-index: 1;
}

.search-container .search-input {
  padding-left: 40px;
}

/* Animations */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingDots {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .chat-container {
    grid-template-columns: 280px 1fr;
  }
}

@media (max-width: 768px) {
  .chat-container {
    grid-template-columns: 1fr;
    height: min(500px, 80vh);
  }
  
  .chat-sidebar {
    display: none;
  }
  
  .chat-sidebar.mobile-visible {
    display: flex;
  }
  
  .chat-main.mobile-hidden {
    display: none;
  }
}

/* Enhanced conversation badges */
.conversation-badge.open {
  background: #10b981 !important;
}

.conversation-badge.pending {
  background: #f59e0b !important;
}

.conversation-badge.closed {
  background: #6b7280 !important;
}

/* Unread badge for conversations */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.25);
}

.conversation-item.active .unread-badge {
  background: #fb7185;
}

/* Message status indicators */
.message-status-delivered {
  color: #10b981;
}

.message-status-sent {
  color: #3b82f6;
}

.message-status-error {
  color: #ef4444;
}

.admin-chat-alert .btn.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
}
.admin-chat-alert .btn.btn-outline {
  border-color: #64748b;
  color: #e5e7eb;
}
/* Read receipts */
.message-time .message-receipt {
  margin-left: 8px;
  color: #6b7280;
  font-size: 11px;
}
.message-bubble.user .message-time .message-receipt {
  color: rgba(255, 255, 255, 0.8);
}