/* ============================================
   MODERN CSS DESIGN SYSTEM - MamaMia
   Phase 1: Foundation & Variables
   ============================================ */

:root {
  /* Color Palette - ChatGPT-inspired */
  --primary-color: #10a37f;
  --primary-hover: #0d8a6b;
  --primary-light: #e6f7f3;

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

  --background: #ffffff;
  --background-secondary: #f7f7f8;
  --background-tertiary: #ececf1;

  --text-primary: #2d2d2d;
  --text-secondary: #5e5e5e;
  --text-muted: #8e8ea0;

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

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

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

  /* Status Colors */
  --status-pending: #f59e0b;
  --status-in-progress: #3b82f6;
  --status-completed: #10b981;
  --status-failed: #ef4444;
  --status-cancelled: #6b7280;

  /* 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;
}

/* Dark mode variables (optional for future) */
@media (prefers-color-scheme: dark) {
  :root {
    --background: #1a1a1a;
    --background-secondary: #2d2d2d;
    --background-tertiary: #3a3a3a;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --text-muted: #8e8ea0;
    --border-color: #444444;
  }
}

/* ============================================
   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%;
}

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

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

.form-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 {
  width: 100%;
  padding: 12px 16px;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-base);
}

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

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

.form-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);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  resize: vertical;
  transition: all var(--transition-base);
}

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

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

.form-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;
}

.form-file {
  width: 100%;
  padding: 12px 16px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  background: var(--background-secondary);
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
}

.form-file:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

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

.alert {
  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 {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fee2e2;
}

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

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

.card {
  background: var(--background);
  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-secondary);
  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);
}

/* ============================================
   BADGE COMPONENT
   ============================================ */

.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;
}

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

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

.badge-completed {
  background: #d1fae5;
  color: #065f46;
}

.badge-failed {
  background: #fee2e2;
  color: #991b1b;
}

.badge-cancelled {
  background: #f3f4f6;
  color: #374151;
}

/* ============================================
   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);
}

/* Skeleton Card */
.card-skeleton {
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--spacing-lg);
}

.card-skeleton .skeleton-title {
  width: 50%;
  height: 24px;
  margin-bottom: var(--spacing-lg);
  background: var(--background-tertiary);
}

.card-skeleton .skeleton-paragraph {
  width: 100%;
  height: 12px;
  margin-bottom: var(--spacing-sm);
  background: var(--background-tertiary);
}

.card-skeleton .skeleton-paragraph:last-child {
  width: 70%;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--background-tertiary);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

.progress-bar-indeterminate {
  width: 30%;
  height: 100%;
  background: var(--primary-color);
  position: absolute;
  animation: progress-indeterminate 1.5s infinite;
}

@keyframes progress-indeterminate {
  0% {
    left: -30%;
  }
  100% {
    left: 100%;
  }
}

.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: linear-gradient(135deg, var(--primary-light) 0%, var(--background-secondary) 100%);
  padding: var(--spacing-md);
}

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

.login-card {
  background: var(--background);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-2xl);
  animation: fadeInUp 0.4s ease;
}

@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);
  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 rgba(255, 255, 255, 0.1);
}

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

.call-item.active {
  background: var(--primary-light);
  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(--primary-light) 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;
}

/* 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);
}

/* Modal Base (updated to work with new dashboard) */
.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;
}

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

.modal-content {
  position: relative;
  background: var(--background);
  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;
}

.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-secondary);
}

/* 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;
  }
}

@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);
  }
}

/* ============================================
   EXISTING STYLES (PRESERVED)
   ============================================ */

.top { display:flex; align-items:center; justify-content:space-between; padding:10px 16px; background:#111827; color:#fff; }
.top a, .top .link { color:#e5e7eb; margin-left:10px; text-decoration:none; background:none; border:none; cursor:pointer; }
main { padding:16px; }
.panel { max-width:380px; margin:40px auto; background:#fff; padding:16px; border-radius:8px; box-shadow:0 1px 4px rgba(0,0,0,.08);}
label { display:block; margin:8px 0; }
input, textarea, select { width:100%; padding:8px; border:1px solid #cbd5e1; border-radius:6px; }
button { padding:8px 12px; border:1px solid #0ea5e9; background:#0284c7; color:#fff; border-radius:6px; cursor:pointer; }
button.danger { background:#b91c1c; border-color:#ef4444; }
.row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:10px;}
.grid { width:100%; border-collapse:collapse; background:#fff; }
.grid th, .grid td { border:1px solid #e5e7eb; padding:6px; vertical-align:top; }
.grid th { background:#f3f4f6; text-align:left; }
.err { background:#fee2e2; padding:8px; border:1px solid #ef4444; color:#991b1b; margin-bottom:10px; }
.small { font-size:12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color:#6b7280; font-size:12px; }

/* === Telegram-like Chat Styles === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  max-width: 900px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  position: relative;
}

.chat-header {
  background: #5288c1;
  color: #fff;
  padding: 14px 20px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  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: #0d1418;
  background-image:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.03"><rect width="100" height="100" fill="%23fff"/><path d="M25 25 L75 75 M75 25 L25 75" stroke="%23000" stroke-width="0.5"/></svg>');
  background-size: 100px 100px;
  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: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

/* 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: #5288c1;
  color: #fff;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  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: #4a7db0;
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

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

.new-messages-count {
  background: #fff;
  color: #5288c1;
  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: 0 1px 1px rgba(0,0,0,0.15);
  backdrop-filter: blur(10px);
}

.msg-own .msg-bubble {
  background: #2b5278;
  color: #fff;
  border-radius: 10px 10px 2px 10px;
}

.msg-other .msg-bubble {
  background: #182533;
  color: #e9edef;
  border-radius: 10px 10px 10px 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.msg-user {
  font-weight: 600;
  font-size: 13px;
  color: #8774e1;
  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.45);
  text-align: right;
  margin-top: 2px;
  user-select: none;
}

.msg-own .msg-time {
  color: rgba(255,255,255,0.5);
}

.msg-pending {
  opacity: 0.65;
}

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

.msg-error {
  opacity: 0.5;
}

.msg-error .msg-bubble {
  background: #4a2020;
  border: 1px solid #8b3535;
}

.chat-form {
  display: flex;
  padding: 10px 16px 12px 16px;
  background: #1e2a32;
  border-top: 1px solid #2a3942;
  align-items: center;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  background: #2a3942;
  color: #e9edef;
  font-family: system-ui, -apple-system, sans-serif;
}

.chat-input::placeholder {
  color: #8696a0;
}

.chat-input:focus {
  background: #2f3b44;
}

.chat-send-btn {
  background: #00a884;
  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: #06cf9c;
  transform: scale(1.05);
}

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

/* === Call Status Badges === */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-draft {
  background: #9ca3af;
  color: #fff;
}

.status-dialing {
  background: #fbbf24;
  color: #78350f;
}

.status-in-progress {
  background: #3b82f6;
  color: #fff;
}

.status-completed {
  background: #10b981;
  color: #fff;
}

.status-failed {
  background: #ef4444;
  color: #fff;
}

/* === Call Duration === */
.call-duration {
  font-size: 12px;
  color: #6b7280;
  font-family: ui-monospace, monospace;
}

/* === Transcript Modal === */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  animation: fadeIn 0.2s;
}

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

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fff;
  padding: 0;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: slideUp 0.3s ease-out;
}

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

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #111;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body pre {
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #111;
}

/* === Audio Test Modal === */
.audio-test-section {
  margin-bottom: 20px;
  padding: 16px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.audio-test-section h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #111;
}

.audio-test-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.audio-test-controls button {
  font-size: 14px;
}

#audioVisualizer {
  width: 100%;
  height: 80px;
  background: #000;
  border-radius: 6px;
  margin: 12px 0;
}

.latency-result {
  padding: 12px;
  background: #fff;
  border-radius: 6px;
  margin-top: 12px;
  border-left: 4px solid #10b981;
}

.latency-result.fair {
  border-left-color: #fbbf24;
}

.latency-result.poor {
  border-left-color: #ef4444;
}

.latency-result strong {
  font-size: 24px;
  display: block;
  margin-bottom: 4px;
}

/* === Notification Badge === */
.notification-badge {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0088cc;
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 999;
  display: none;
  align-items: center;
  gap: 8px;
  animation: bounceIn 0.4s ease-out;
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.notification-badge.show {
  display: flex;
}

.notification-badge:hover {
  background: #006699;
}

.notification-count {
  background: #fff;
  color: #0088cc;
  border-radius: 12px;
  padding: 2px 8px;
  font-weight: 700;
  font-size: 12px;
}

/* === Call Row Highlighting === */
.call-row-updated {
  animation: rowHighlight 1.5s ease-out;
}

@keyframes rowHighlight {
  0% {
    background-color: #fef3c7;
  }
  100% {
    background-color: transparent;
  }
}

/* === Mobile Responsiveness Polish === */

/* Ensure minimum touch target sizes (44x44px for accessibility) */
.btn-icon,
.modal-close,
.attachment-modal-close,
.btn-view-attachment,
.btn-delete-attachment,
.pdf-fullscreen-btn {
  min-width: 44px;
  min-height: 44px;
}

/* Prevent horizontal scrolling on mobile */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Touch-friendly form inputs */
@media (max-width: 768px) {
  .form-input,
  .form-textarea,
  .form-select,
  .search-input,
  .chat-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px 16px;
  }

  /* Larger buttons on mobile */
  .btn {
    padding: 14px 24px;
    font-size: 16px;
  }

  .btn-sm {
    padding: 10px 18px;
    font-size: 14px;
  }

  /* Chat specific mobile improvements */
  .chat-container {
    height: calc(100vh - 80px);
    border-radius: 0;
    max-width: 100vw;
  }

  .msg-bubble {
    max-width: 85%;
    font-size: 15px;
  }

  .chat-input {
    padding: 12px 16px;
    font-size: 16px;
  }

  .chat-send-btn {
    width: 44px;
    height: 44px;
  }

  /* Modal improvements */
  .modal-content {
    width: 95%;
    max-width: 95vw;
    max-height: 92vh;
    margin: 4vh auto;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Dashboard sidebar mobile improvements */
  .dashboard-sidebar {
    width: 85%;
    max-width: 320px;
  }

  .call-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
  }

  .call-item:active {
    background: var(--primary-light);
  }

  /* Attachment modal mobile */
  .attachment-modal-content {
    width: 95vw;
    max-width: 95vw;
    max-height: 95vh;
    margin: 2.5vh auto;
  }

  .attachment-preview-pdf {
    height: 60vh;
  }

  .attachment-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .attachment-viewer-actions {
    flex-direction: column;
    width: 100%;
  }

  .btn-download,
  .btn-delete-in-viewer {
    width: 100%;
  }

  /* SIP controls in modal */
  .modal-sip-controls {
    flex-direction: column;
    width: 100%;
  }

  #modalSipPhoneNumber {
    width: 100%;
  }

  .btn-call-modal,
  .btn-hangup-modal {
    width: 100%;
  }

  /* New messages indicator on mobile */
  .new-messages-indicator {
    bottom: 70px;
    font-size: 13px;
    padding: 8px 16px;
  }

  /* Welcome screen adjustments */
  .welcome-content {
    padding: var(--spacing-lg);
  }

  .welcome-icon {
    width: 64px;
    height: 64px;
  }

  /* Card adjustments on mobile */
  .card {
    border-radius: var(--border-radius-sm);
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-md);
  }

  /* Better spacing for call details on mobile */
  .call-item-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* Very small screens (≤480px) */
@media (max-width: 480px) {
  /* Reduce padding on very small screens */
  .dashboard-sidebar {
    width: 100%;
  }

  .sidebar-header,
  .sidebar-footer {
    padding: 12px;
  }

  .sidebar-search {
    padding: 8px 12px;
  }

  .call-item {
    padding: 12px;
  }

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

  .modal-content {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .attachment-modal-content {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .attachment-preview-pdf {
    height: calc(100vh - 300px);
  }

  /* Larger touch targets on very small screens */
  .btn-icon,
  .modal-close,
  .attachment-modal-close {
    min-width: 48px;
    min-height: 48px;
  }

  /* Stack form groups more compactly */
  .form-group {
    margin-bottom: var(--spacing-md);
  }
}

/* Landscape mode adjustments for mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .chat-container {
    height: calc(100vh - 60px);
  }

  .attachment-preview-pdf {
    height: calc(100vh - 200px);
  }

  .dashboard-main {
    height: 100vh;
  }

  .welcome-screen {
    min-height: 300px;
  }
}

/* === Original Responsive Styles (Preserved) === */
@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 80px);
    border-radius: 0;
  }

  .msg-bubble {
    max-width: 80%;
  }

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

/* === Test Audio Button === */
.test-audio-btn {
  background: #8b5cf6;
  border-color: #7c3aed;
  margin-left: 8px;
}

.test-audio-btn:hover {
  background: #7c3aed;
}

/* === View Full Transcript Button === */
.btn-view-transcript {
  background: #0ea5e9;
  border: 1px solid #0284c7;
  color: #fff;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-view-transcript:hover {
  background: #0284c7;
}

/* Voice Feminization Controls */
.voice-controls {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.voice-controls input[type="range"] {
  flex: 1;
}

.voice-controls .range-value {
  min-width: 40px;
  text-align: right;
  font-weight: 600;
  color: #0088cc;
}

/* === SIP Calling & Attachments Layout === */
.sip-attachment-container {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.sip-sidebar {
  width: 350px;
  flex-shrink: 0;
}

.calls-main-area {
  flex: 1;
  min-width: 0;
}

/* === SIP Controls Card === */
.sip-controls-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.sip-controls-card h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #111;
}

.sip-status {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  text-align: center;
  transition: all 0.3s;
}

.sip-status-connecting {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #6366f1;
  animation: pulse 1.5s ease-in-out infinite;
}

.sip-status-ready {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.sip-status-calling {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fbbf24;
  animation: pulse 1.5s ease-in-out infinite;
}

.sip-status-connected {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #3b82f6;
}

.sip-status-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.sip-status-disconnected {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #9ca3af;
}

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

.sip-timer {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  font-family: ui-monospace, monospace;
  color: #111;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.sip-call-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sip-phone-input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.sip-phone-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.sip-button-group {
  display: flex;
  gap: 8px;
}

.btn-sip-call {
  flex: 1;
  padding: 12px;
  background: #10b981;
  border: none;
  color: #fff;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-sip-call:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sip-call:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-sip-hangup {
  flex: 1;
  padding: 12px;
  background: #ef4444;
  border: none;
  color: #fff;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-sip-hangup:hover:not(:disabled) {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-sip-hangup:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

/* === Attachment Upload Card === */
.attachment-upload-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.attachment-upload-card h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #111;
}

#attachmentUploadForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.attachment-file-input {
  padding: 8px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.3s;
}

.attachment-file-input:hover {
  border-color: #3b82f6;
}

.btn-upload-attachment {
  padding: 10px 16px;
  background: #3b82f6;
  border: none;
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-upload-attachment:hover:not(:disabled) {
  background: #2563eb;
}

.btn-upload-attachment:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* === Attachment Grid === */
.attachment-grid {
  max-height: 400px;
  overflow-y: auto;
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.3s;
  border: 1px solid #e5e7eb;
}

.attachment-card:hover {
  background: #f3f4f6;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.attachment-icon {
  font-size: 32px;
  flex-shrink: 0;
}

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

.attachment-name {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.attachment-actions {
  display: flex;
  gap: 6px;
}

.btn-view-attachment,
.btn-delete-attachment {
  padding: 6px 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-view-attachment:hover {
  background: #dbeafe;
}

.btn-delete-attachment:hover {
  background: #fee2e2;
}

/* === Attachment Viewer Modal === */
.attachment-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
}

.attachment-modal.show {
  display: block;
}

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

.attachment-modal-content {
  position: relative;
  background: #fff;
  margin: 5% auto;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  animation: modalSlideIn 0.3s ease-out;
}

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

.attachment-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.attachment-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  flex: 1;
  word-break: break-word;
}

.attachment-modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-sip-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

#modalSipPhoneNumber {
  width: 180px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}

.btn-call-modal {
  padding: 6px 12px;
  background: #10b981;
  border: none;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-call-modal:hover:not(:disabled) {
  background: #059669;
}

.btn-call-modal:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.btn-hangup-modal {
  padding: 6px 12px;
  background: #ef4444;
  border: none;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-hangup-modal:hover:not(:disabled) {
  background: #dc2626;
}

.btn-hangup-modal:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.attachment-modal-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #6b7280;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.attachment-modal-close:hover {
  background: #f3f4f6;
  color: #111;
}

.attachment-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 300px;
}

.attachment-preview-image {
  text-align: center;
}

.attachment-preview-image img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.attachment-preview-pdf {
  width: 100%;
  height: 70vh;
  position: relative;
  background: #f3f4f6;
  border-radius: 8px;
}

.attachment-preview-pdf iframe {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.pdf-fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pdf-fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.05);
}

.pdf-fullscreen-btn:active {
  transform: scale(0.95);
}

/* Fullscreen mode styles */
.attachment-preview-pdf:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.attachment-preview-pdf:fullscreen iframe {
  border-radius: 0;
}

.attachment-preview-pdf:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.attachment-preview-pdf:-webkit-full-screen iframe {
  border-radius: 0;
}

.attachment-preview-default {
  text-align: center;
  padding: 40px 20px;
}

.file-icon-large {
  font-size: 80px;
  margin-bottom: 20px;
}

.attachment-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.attachment-viewer-meta {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.6;
}

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

.btn-download {
  padding: 8px 16px;
  background: #3b82f6;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.3s;
}

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

.btn-delete-in-viewer {
  padding: 8px 16px;
  font-size: 14px;
}

/* === Toast Notifications === */
.toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 10000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #10b981;
  color: #fff;
}

.toast-error {
  background: #ef4444;
  color: #fff;
}

.toast-info {
  background: #3b82f6;
  color: #fff;
}

/* === Responsive Design === */
@media (max-width: 1024px) {
  .sip-attachment-container {
    flex-direction: column;
  }

  .sip-sidebar {
    width: 100%;
  }

  .calls-main-area {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .attachment-modal-content {
    margin: 2% auto;
    max-width: 95vw;
    max-height: 95vh;
  }

  .modal-sip-controls {
    flex-direction: column;
    align-items: stretch;
  }

  #modalSipPhoneNumber {
    width: 100%;
  }

  .attachment-modal-header {
    flex-direction: column;
  }

  .attachment-modal-actions {
    width: 100%;
    flex-direction: column;
  }

  .attachment-modal-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .attachment-viewer-actions {
    width: 100%;
  }

  .btn-download,
  .btn-delete-in-viewer {
    flex: 1;
  }
}
