// Enterprise-Grade Call Component Styling
// Color Palette
$primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
$primary-blue: #0066cc;
$primary-blue-light: #e6f2ff;
$primary-blue-dark: #0052a3;
$accent-teal: #0099a1;
$accent-purple: #8b5cf6;
$text-dark: #1a1a1a;
$text-medium: #4a4a4a;
$text-light: #6b6b6b;
$text-lighter: #9ca3af;
$border-color: #e8eaed;
$white: #ffffff;
$success-green: #10b981;
$success-green-light: #d1fae5;
$success-green-dark: #059669;
$error-red: #ef4444;
$error-red-light: #fee2e2;
$error-red-dark: #dc2626;
$warning-orange: #f59e0b;
$shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
$shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
$shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
$shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
$shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
$border-radius-sm: 8px;
$border-radius-md: 12px;
$border-radius-lg: 16px;
$border-radius-xl: 20px;
$transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
$transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
$transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

.call-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10001;
  pointer-events: none;
  will-change: transform;
  transform: translateZ(0);
}

.call-overlay {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(30, 41, 59, 0.98) 100%);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: fadeIn 0.3s ease-out;
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
      radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
      radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
  }

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      45deg,
      transparent,
      transparent 100px,
      rgba(255, 255, 255, 0.01) 100px,
      rgba(255, 255, 255, 0.01) 200px
    );
    pointer-events: none;
    z-index: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(1.05);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.call-media-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;

  &.audio-only {
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
    position: relative;

    &::before {
      content: '';
      position: absolute;
      inset: 0;
      background: 
        radial-gradient(circle at 30% 40%, rgba(102, 126, 234, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(118, 75, 162, 0.2) 0%, transparent 50%);
      animation: pulse 4s ease-in-out infinite;
    }
  }
}

@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

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

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: $text-dark;
  filter: brightness(1.05) contrast(1.02);
  transition: filter $transition-slow;
  
  &.hidden {
    display: none;
  }
}

.local-video {
  position: absolute;
  bottom: 120px;
  right: 24px;
  width: 240px;
  height: 180px;
  border-radius: $border-radius-lg;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: $shadow-2xl, 0 0 0 1px rgba(255, 255, 255, 0.1);
  background: $text-dark;
  z-index: 10;
  transition: all $transition-base;
  backdrop-filter: blur(10px);
  
  &:hover {
    transform: scale(1.05);
    box-shadow: $shadow-2xl, 0 0 0 2px rgba(255, 255, 255, 0.2);
  }
  
  &.hidden {
    display: none;
  }
}

.audio-call-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  color: $white;
  text-align: center;
  position: relative;
  z-index: 2;
  padding: 40px;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.avatar-large {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    $shadow-2xl,
    0 0 0 8px rgba(255, 255, 255, 0.05),
    0 0 40px rgba(102, 126, 234, 0.3);
  overflow: hidden;
  position: relative;
  transition: all $transition-base;

  &::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: $primary-gradient;
    opacity: 0;
    transition: opacity $transition-base;
    z-index: -1;
    filter: blur(20px);
  }

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    pointer-events: none;
  }

  &:hover {
    transform: scale(1.05);
    box-shadow: 
      $shadow-2xl,
      0 0 0 8px rgba(255, 255, 255, 0.1),
      0 0 60px rgba(102, 126, 234, 0.5);

    &::before {
      opacity: 0.3;
    }
  }
}

.avatar-image-large {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  position: relative;
  z-index: 1;
}

.avatar-circle-large {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  font-weight: 700;
  color: $white;
  background: $primary-gradient;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  }
}

.call-user-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.call-user-name {
  font-size: 36px;
  font-weight: 700;
  margin: 0;
  color: $white;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.9) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.call-status {
  font-size: 18px;
  font-weight: 500;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  text-transform: capitalize;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);
}

.call-controls {
  padding: 32px 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.6) 100%);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 10;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.incoming-controls,
.outgoing-controls,
.active-controls {
  display: flex;
  gap: 20px;
  align-items: center;
}

.outgoing-controls {
  flex-direction: column;
  gap: 16px;
}

.call-status-text {
  color: rgba(255, 255, 255, 0.95);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  animation: pulseText 2s ease-in-out infinite;
}

@keyframes pulseText {
  0%, 100% {
    opacity: 0.9;
  }
  50% {
    opacity: 1;
  }
}

.call-btn {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all $transition-base;
  box-shadow: $shadow-xl;
  position: relative;
  overflow: hidden;
  font-family: inherit;
  
  &::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity $transition-base;
  }

  &::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: inherit;
    opacity: 0;
    transition: opacity $transition-base;
    filter: blur(12px);
    z-index: -1;
  }

  svg {
    width: 28px;
    height: 28px;
    position: relative;
    z-index: 1;
    transition: transform $transition-base;
    stroke-width: 2.5;
  }

  &:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: $shadow-2xl;

    &::before {
      opacity: 1;
    }

    &::after {
      opacity: 0.4;
    }

    svg {
      transform: scale(1.1);
    }
  }

  &:active:not(:disabled) {
    transform: scale(1.05);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;

    &:hover {
      transform: none;
      box-shadow: $shadow-xl;
    }
  }
}

.call-btn-answer {
  background: linear-gradient(135deg, $success-green 0%, $success-green-dark 100%);
  color: $white;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);

  &:hover:not(:disabled) {
    background: linear-gradient(135deg, $success-green-dark 0%, #047857 100%);
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.5);

    &::after {
      background: linear-gradient(135deg, $success-green 0%, $success-green-dark 100%);
    }
  }

  &:active:not(:disabled) {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
  }
}

.call-btn-reject,
.call-btn-end {
  background: linear-gradient(135deg, $error-red 0%, $error-red-dark 100%);
  color: $white;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);

  &:hover:not(:disabled) {
    background: linear-gradient(135deg, $error-red-dark 0%, #b91c1c 100%);
    box-shadow: 0 12px 32px rgba(239, 68, 68, 0.5);

    &::after {
      background: linear-gradient(135deg, $error-red 0%, $error-red-dark 100%);
    }
  }

  &:active:not(:disabled) {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
  }
}

.call-btn-secondary {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  background: rgba(255, 255, 255, 0.15);
  color: $white;
  backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);

  svg {
    width: 24px;
    height: 24px;
  }

  &:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transform: scale(1.08);

    &::before {
      opacity: 1;
    }
  }

  &:active:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  }

  &.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);

    svg {
      color: $white;
    }

    &:hover {
      background: rgba(255, 255, 255, 0.35);
      border-color: rgba(255, 255, 255, 0.6);
    }
  }
}

// Animation for incoming call
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 
      $shadow-2xl,
      0 0 0 8px rgba(255, 255, 255, 0.05),
      0 0 40px rgba(102, 126, 234, 0.3);
  }
  50% {
    transform: scale(1.05);
    opacity: 0.95;
    box-shadow: 
      $shadow-2xl,
      0 0 0 12px rgba(255, 255, 255, 0.1),
      0 0 60px rgba(102, 126, 234, 0.5);
  }
}

.isRinging {
  .avatar-large {
    animation: pulse 2s ease-in-out infinite;
  }

  .call-btn-answer {
    animation: pulseButton 2s ease-in-out infinite;
  }
}

@keyframes pulseButton {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.6);
    transform: scale(1.05);
  }
}

// Responsive Design
@media (max-width: 768px) {
  .call-user-name {
    font-size: 28px;
  }

  .call-status {
    font-size: 16px;
  }

  .avatar-large {
    width: 160px;
    height: 160px;
    border-width: 3px;
  }

  .avatar-circle-large {
    font-size: 64px;
  }

  .call-btn {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;

    svg {
      width: 24px;
      height: 24px;
    }
  }

  .call-btn-secondary {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;

    svg {
      width: 20px;
      height: 20px;
    }
  }

  .local-video {
    width: 180px;
    height: 135px;
    bottom: 100px;
    right: 16px;
  }

  .call-controls {
    padding: 24px 20px;
    gap: 16px;
  }

  .incoming-controls,
  .outgoing-controls,
  .active-controls {
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .avatar-large {
    width: 140px;
    height: 140px;
  }

  .avatar-circle-large {
    font-size: 56px;
  }

  .call-user-name {
    font-size: 24px;
  }

  .call-btn {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;

    svg {
      width: 22px;
      height: 22px;
    }
  }

  .call-btn-secondary {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;

    svg {
      width: 18px;
      height: 18px;
    }
  }
}

// Enhanced focus states for accessibility
.call-btn:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.6);
  outline-offset: 4px;
  border-radius: 50%;
}

// Smooth transitions
.call-container * {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

// Performance optimizations
.call-overlay,
.call-media-area,
.remote-video,
.local-video {
  will-change: transform;
  transform: translateZ(0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
