/* ============================================
   MODERN DARK THEME - MamaMia Secretary
   Matching Operator Design
   ============================================ */

:root {
  /* Dark Theme Colors - Matching Operator */
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.1);

  --secondary-color: #6366f1;
  --secondary-hover: #4f46e5;

  --background: #1a1d23;
  --background-primary: #1a1d23;
  --background-secondary: #242830;
  --background-tertiary: #2f3441;

  --text-primary: #e4e6eb;
  --text-secondary: #b0b3b8;
  --text-muted: #8e8ea0;

  --border-color: #3a3f4b;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Status Colors */
  --status-new: rgba(59, 130, 246, 0.2);
  --status-new-text: #60a5fa;
  --status-not-answered: rgba(107, 114, 128, 0.2);
  --status-not-answered-text: #9ca3af;
  --status-call-later: rgba(245, 158, 11, 0.2);
  --status-call-later-text: #fbbf24;
  --status-send-invoice: rgba(139, 92, 246, 0.2);
  --status-send-invoice-text: #a78bfa;
  --status-called: rgba(34, 197, 94, 0.2);
  --status-called-text: #4ade80;
  --status-bad: rgba(239, 68, 68, 0.2);
  --status-bad-text: #f87171;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--background);
  overflow-x: hidden;
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ============================================
   TYPOGRAPHY SCALE
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
  margin-bottom: var(--spacing-md);
  color: var(--text-secondary);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ============================================
   BUTTON COMPONENTS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
}

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

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-block {
  width: 100%;
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--background-secondary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 16px 32px;
  font-size: var(--font-size-lg);
}

.btn-icon {
  padding: 8px;
  border-radius: 50%;
}

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

.danger:hover, .btn-danger:hover {
  background: #dc2626;
}

/* ============================================
   FORM COMPONENTS
   ============================================ */

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label, label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.form-input, input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
  padding: 12px 16px;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-base);
}

.form-input:focus, input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--background-tertiary);
}

.form-input::placeholder, input::placeholder {
  color: var(--text-muted);
}

.form-textarea, textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 16px;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  resize: vertical;
  transition: all var(--transition-base);
}

.form-textarea:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--background-tertiary);
}

.form-select, select {
  width: 100%;
  padding: 12px 16px;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
}

.form-select:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* ============================================
   ALERT COMPONENTS
   ============================================ */

.alert, .err {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--spacing-lg);
  font-size: var(--font-size-sm);
}

.alert-error, .err {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.text-muted, .muted {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.small {
  font-size: var(--font-size-xs);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============================================
   CARD COMPONENT
   ============================================ */

.card {
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.card-body {
  padding: var(--spacing-lg);
}

.card-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--background-tertiary);
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--spacing-xs);
  color: var(--text-primary);
}

/* ============================================
   BADGE COMPONENT - Updated Categories
   ============================================ */

.badge, .status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border-radius: 12px;
  white-space: nowrap;
}

/* Category Status Badges */
.badge-new, .status-new {
  background: var(--status-new);
  color: var(--status-new-text);
}

.badge-not-answered, .status-not-answered {
  background: var(--status-not-answered);
  color: var(--status-not-answered-text);
}

.badge-call-later, .status-call-later {
  background: var(--status-call-later);
  color: var(--status-call-later-text);
}

.badge-send-invoice, .status-send-invoice {
  background: var(--status-send-invoice);
  color: var(--status-send-invoice-text);
}

.badge-called, .status-called {
  background: var(--status-called);
  color: var(--status-called-text);
}

.badge-bad, .status-bad, .status-bad-number {
  background: var(--status-bad);
  color: var(--status-bad-text);
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--background-tertiary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-inline {
  display: inline-block;
  vertical-align: middle;
  margin-right: var(--spacing-xs);
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  text-align: center;
}

.loading-text {
  margin-top: var(--spacing-md);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* Button loading states */
.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-outline.loading::after,
.btn-ghost.loading::after {
  border-color: rgba(0, 0, 0, 0.2);
  border-top-color: var(--primary-color);
}

/* Skeleton Loaders */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--background-secondary) 0%,
    var(--background-tertiary) 50%,
    var(--background-secondary) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--spacing-sm);
  border-radius: 4px;
}

.skeleton-text-lg {
  height: 20px;
}

.skeleton-text-sm {
  height: 12px;
}

/* Skeleton Call Item */
.call-item-skeleton {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid transparent;
}

.call-item-skeleton .skeleton-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xs);
}

.call-item-skeleton .skeleton-title {
  width: 60%;
  height: 18px;
  background: var(--background-tertiary);
}

.call-item-skeleton .skeleton-badge {
  width: 60px;
  height: 20px;
  background: var(--background-tertiary);
  border-radius: 12px;
}

.call-item-skeleton .skeleton-details {
  width: 90%;
  height: 14px;
  background: var(--background-tertiary);
  margin-bottom: var(--spacing-xs);
}

.call-item-skeleton .skeleton-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.call-item-skeleton .skeleton-meta-item {
  width: 40%;
  height: 12px;
  background: var(--background-tertiary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: var(--spacing-md);
}

.empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.empty-state-description {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--spacing-lg);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
  padding: var(--spacing-md);
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card, .panel {
  background: var(--background-secondary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-2xl);
  animation: fadeInUp 0.4s ease;
  border: 1px solid var(--border-color);
}

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

.login-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 50%;
  margin-bottom: var(--spacing-md);
}

.login-title {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 0;
}

.login-form {
  margin-bottom: var(--spacing-lg);
}

.login-footer {
  text-align: center;
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

/* Mobile Responsive for Login */
@media (max-width: 480px) {
  .login-card {
    padding: var(--spacing-xl);
  }

  .login-title {
    font-size: var(--font-size-2xl);
  }
}

/* ============================================
   DASHBOARD SIDEBAR LAYOUT
   ============================================ */

.dashboard-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--background);
}

/* Sidebar */
.dashboard-sidebar {
  width: 320px;
  height: 100vh;
  background: var(--background);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-base);
  z-index: 100;
}

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--background);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  color: var(--primary-color);
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

/* Search */
.sidebar-search {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--background);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-base);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--background-tertiary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* Call List */
.call-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-xs) 0;
}

.call-list::-webkit-scrollbar {
  width: 6px;
}

.call-list::-webkit-scrollbar-track {
  background: transparent;
}

.call-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.call-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.call-item {
  padding: var(--spacing-md) var(--spacing-lg);
  cursor: pointer;
  transition: background var(--transition-fast), border var(--transition-fast);
  border-bottom: 1px solid var(--border-color);
  border-left: 3px solid transparent;
  position: relative;
}

.call-item:hover {
  background: var(--background-secondary);
}

.call-item.active {
  background: var(--background-tertiary);
  border-left: 3px solid var(--primary-color);
}

/* SUNAT calls - greenish border */
.call-item-sunat {
  border-left: 3px solid #10b981 !important;
  background: linear-gradient(to right, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
}

.call-item-sunat.active {
  background: linear-gradient(to right, rgba(16, 185, 129, 0.1) 0%, var(--background-tertiary) 100%);
}

.call-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xs);
  gap: var(--spacing-sm);
}

.call-item-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-item-details {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.call-item-phone {
  display: flex;
  align-items: center;
}

.call-item-date {
  white-space: nowrap;
}

.call-item-subject {
  font-size: 13px;
  color: #d1d5db;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-item-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Main Content Area */
.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--background-secondary);
}

.mobile-header {
  display: none;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--background);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  gap: var(--spacing-md);
}

.mobile-title {
  flex: 1;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  color: var(--text-primary);
}

/* Details Panel */
#detailsPanel {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
}

.welcome-content {
  text-align: center;
  max-width: 400px;
  padding: var(--spacing-2xl);
}

.welcome-icon {
  color: var(--primary-color);
  margin-bottom: var(--spacing-lg);
}

.welcome-content h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

.welcome-content p {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-lg);
}

/* ============================================
   TELEGRAM-LIKE CHAT STYLES - Dark Theme
   ============================================ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  max-width: 900px;
  margin: 0 auto;
  background: var(--background-secondary);
  box-shadow: var(--shadow-lg);
  position: relative;
  border-radius: var(--border-radius);
  overflow: hidden;
}

.chat-header {
  background: var(--primary-color);
  color: #fff;
  padding: 14px 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  min-height: 56px;
}

.chat-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  background: var(--background);
  scroll-behavior: smooth;
}

/* Custom scrollbar for chat */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* New Messages Indicator */
.new-messages-indicator {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 100;
  animation: slideUpBounce 0.3s ease-out;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 600;
}

.new-messages-indicator:hover {
  background: var(--primary-hover);
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

.new-messages-indicator:active {
  transform: translateX(-50%) translateY(0px);
}

.new-messages-count {
  background: #fff;
  color: var(--primary-color);
  border-radius: 12px;
  padding: 2px 8px;
  font-weight: 700;
  font-size: 12px;
  min-width: 20px;
  text-align: center;
}

@keyframes slideUpBounce {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  60% {
    transform: translateX(-50%) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.msg {
  display: flex;
  margin-bottom: 4px;
  padding: 0 12px;
  animation: slideIn 0.15s ease-out;
}

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

.msg-own {
  justify-content: flex-end;
}

.msg-other {
  justify-content: flex-start;
}

.msg-bubble {
  max-width: 70%;
  min-width: 60px;
  padding: 6px 10px 8px 10px;
  border-radius: 10px;
  position: relative;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}

/* Operator messages - Blue */
.msg-own .msg-bubble {
  background: #2563eb;
  color: #fff;
  border-radius: 10px 10px 2px 10px;
}

/* Secretary/AI messages - Green */
.msg-other .msg-bubble {
  background: #059669;
  color: #fff;
  border-radius: 10px 10px 10px 2px;
}

.msg-user {
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 3px;
  letter-spacing: 0.2px;
}

.msg-content {
  font-size: 14.5px;
  line-height: 1.5;
  margin-bottom: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-time {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  text-align: right;
  margin-top: 2px;
  user-select: none;
}

.msg-pending {
  opacity: 0.65;
}

.msg-pending .msg-bubble {
  box-shadow: none;
}

.msg-error {
  opacity: 0.5;
}

.msg-error .msg-bubble {
  background: #7f1d1d;
  border: 1px solid #991b1b;
}

.chat-form {
  display: flex;
  padding: 10px 16px 12px 16px;
  background: var(--background-tertiary);
  border-top: 1px solid var(--border-color);
  align-items: center;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  background: var(--background-secondary);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, sans-serif;
  border: 1px solid var(--border-color);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:focus {
  background: var(--background);
  border-color: var(--primary-color);
}

.chat-send-btn {
  background: var(--primary-color);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

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

/* ============================================
   TABLES & GRIDS
   ============================================ */

.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--background-secondary);
}

.grid th, .grid td {
  border: 1px solid var(--border-color);
  padding: var(--spacing-sm);
  vertical-align: top;
  color: var(--text-primary);
}

.grid th {
  background: var(--background-tertiary);
  text-align: left;
  font-weight: var(--font-weight-semibold);
}

.grid tr:hover {
  background: var(--background-tertiary);
}

/* ============================================
   MODAL BASE
   ============================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

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

.modal-backdrop {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
}

.modal-content {
  position: relative;
  background: var(--background-secondary);
  border-radius: var(--border-radius);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border-color);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--background-tertiary);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.row {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--background-tertiary);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.top a, .top .link {
  color: var(--primary-color);
  margin-left: var(--spacing-md);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
}

.top a:hover, .top .link:hover {
  color: var(--primary-hover);
}

main {
  padding: var(--spacing-lg);
  background: var(--background);
  min-height: 100vh;
}

/* Responsive Design */
@media (max-width: 768px) {
  .dashboard-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
  }

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

  .mobile-header {
    display: flex;
  }

  .dashboard-main {
    width: 100%;
  }

  #detailsPanel {
    padding: var(--spacing-md);
  }

  .modal-content {
    max-width: 95%;
    max-height: 95vh;
  }

  .chat-container {
    border-radius: 0;
  }
}

@media (max-width: 480px) {
  .dashboard-sidebar {
    width: 100%;
  }

  .sidebar-header {
    padding: var(--spacing-md);
  }

  .sidebar-search {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .call-item {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .welcome-content {
    padding: var(--spacing-lg);
  }

  .welcome-content h2 {
    font-size: var(--font-size-xl);
  }

  main {
    padding: var(--spacing-md);
  }
}

/* Category Menu Bar - Matching Operator Style */
.category-menu {
  background: #242830;
  border-bottom: 1px solid #3a3f4b;
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  flex-wrap: wrap;
}

.category-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #2f3441;
  color: #b4b7c0;
  border: 1px solid #3a3f4b;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-btn:hover {
  background: #3a3f4b;
  border-color: #4a9eff;
}

.category-btn.active {
  background: #1d4ed8;
  border-color: #3b82f6;
  color: white;
}

.category-count {
  background: #1f2937;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.category-btn.active .category-count {
  background: #1e40af;
}

/* New Message Badge */
.new-message-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ef4444;
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  animation: pulse 2s infinite;
}

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

/* ===================================================================
   CONVERSATION WINDOW - MATCHING OPERATOR DESIGN
   =================================================================== */

/* Conversation Card Container */
.conversation-card,
.call-conversation-card {
  display: flex;
  flex-direction: column;
  height: 600px;
  background: var(--background-secondary);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

/* Conversation Header */
.conversation-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 16px 20px;
  background: var(--background-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Messages Container - DARK BACKGROUND */
.conversation-messages,
#conversation-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--background-primary);
}
/* Individual Message */
.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 80%;
}

/* Operator Messages (Left-aligned) */
.message-operator {
  align-items: flex-start;
}

/* Secretary Messages (Right-aligned) */
.message-secretary {
  align-items: flex-end;
  align-self: flex-end;
}

/* Message Header (sender + time) */
.message-header {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.message-sender {
  font-weight: 600;
  color: var(--text-primary);
}

.message-time {
  color: #6b7280;
}

/* Message Bubbles - Already correct in existing CSS, but ensuring consistency */
.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 100%;
}

/* Operator bubble - Blue with pointed top-left */
.message-operator .message-bubble {
  background: #2563eb;
  color: white;
  border-top-left-radius: 4px;
}

/* Secretary bubble - Green with pointed top-right */
.message-secretary .message-bubble {
  background: #059669;
  color: white;
  border-top-right-radius: 4px;
}

/* Message Content */
.message-content {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Message Input Container */
.message-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* Message Input Textarea */
.message-input,
textarea.message-input {
  flex: 1;
  padding: 12px;
  background: var(--background-tertiary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px;
  color: var(--text-primary) !important;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.message-input::placeholder {
  color: var(--text-muted);
}

/* Send Button */
.send-btn {
  padding: 12px 24px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.send-btn:hover {
  background: var(--primary-hover);
}

/* Call Details Content Area */
.details-content,
#detailsPanel {
  background: var(--background-primary);
  color: var(--text-primary);
}

/* Call Details Card */
.call-details-card,
.call-card {
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

/* Card Headers */
.call-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.call-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

/* Meta Information Grid */
.call-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.meta-value {
  font-size: 15px;
  color: var(--text-primary);
}

/* Email Body Content - WHITE BACKGROUND, BLACK TEXT */
.email-body-content,
.email-content,
.details-body {
  background: #ffffff !important;
  color: #000000 !important;
  padding: 16px;
  border-radius: 6px;
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

/* Action Buttons */
.category-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.action-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Scrollbar for conversation messages */
.conversation-messages::-webkit-scrollbar,
#conversation-messages::-webkit-scrollbar {
  width: 8px;
}

.conversation-messages::-webkit-scrollbar-track,
#conversation-messages::-webkit-scrollbar-track {
  background: var(--background-primary);
}

.conversation-messages::-webkit-scrollbar-thumb,
#conversation-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.conversation-messages::-webkit-scrollbar-thumb:hover,
#conversation-messages::-webkit-scrollbar-thumb:hover {
  background: #4a5568;
}

/* Message timestamp styling */
.msg-time {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

/* Fix for chat container if using old structure */
.chat-container {
  background: var(--background-primary);
  color: var(--text-primary);
}

.chat-messages {
  background: var(--background-primary) !important;
  color: var(--text-primary);
}

/* Ensure all text in details panel is visible */
#detailsPanel * {
  color: inherit;
}

#detailsPanel h1, 
#detailsPanel h2, 
#detailsPanel h3,
#detailsPanel h4,
#detailsPanel h5,
#detailsPanel h6 {
  color: var(--text-primary);
}

#detailsPanel p,
#detailsPanel span:not(.badge):not(.category-count),
#detailsPanel div {
  color: var(--text-primary);
}

/* New message highlight */
.message-new {
  animation: messageHighlight 2s ease-in-out;
}

@keyframes messageHighlight {
  0% { background: rgba(59, 130, 246, 0.3); }
  100% { background: transparent; }
}

/* ===================================================================
   ADDITIONAL STYLES FOR SECRETARY DASHBOARD
   Email Actions & Category Action Button Colors
   =================================================================== */

/* Email Actions Section */
.email-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.email-btn {
  padding: 10px 20px;
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.email-btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
}

/* Category Action Button Colors */
.btn-new {
  background: #3b82f6;
  color: white;
}

.btn-new:hover {
  background: #2563eb;
}

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

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

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

.btn-call-later:hover {
  background: #d97706;
}

.btn-send-invoice {
  background: #8b5cf6;
  color: white;
}

.btn-send-invoice:hover {
  background: #7c3aed;
}

.btn-bad {
  background: #ef4444;
  color: white;
}

.btn-bad:hover {
  background: #dc2626;
}

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

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

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

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

.btn-push {
  background: #7c3aed;
  color: white;
}

.btn-push:hover {
  background: #6d28d9;
}

.btn-pull {
  background: #f97316;
  color: white;
}

.btn-pull:hover {
  background: #ea580c;
}

/* Details Content Wrapper */
.details-content {
  background: var(--background);
  color: var(--text-primary);
}

/* Override any max-width constraints in email content */
.call-card table,
.call-card img,
.call-card div[style*='max-width'] {
  max-width: 100% !important;
  width: auto !important;
}

/* Ensure email content area can expand fully */
.call-card > div[style*='Email Content'] + div {
  max-width: none !important;
}

/* Mistral AI Prompt - Preserve line breaks and formatting */
.meta-label + div {
  white-space: pre-wrap;
  word-wrap: break-word;
}
