// Enterprise-Grade Security 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;
$border-focus: #0066cc;
$background-light: #f8f9fa;
$background-page: #f5f7fa;
$background-elevated: #ffffff;
$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;
$warning-orange-light: #fef3c7;
$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);

.security-section {
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.4s ease-out;
}

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

.section-header {
  margin-bottom: 32px;
}

.section-title {
  font-size: 32px;
  font-weight: 700;
  color: $text-dark;
  margin: 0 0 8px 0;
  letter-spacing: -0.5px;
  background: $primary-gradient;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.section-description {
  font-size: 16px;
  color: $text-medium;
  margin: 0;
  letter-spacing: 0.1px;
  line-height: 1.5;
}

.error-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, $error-red-light 0%, rgba(254, 226, 226, 0.5) 100%);
  color: $error-red-dark;
  border: 1.5px solid $error-red;
  border-radius: $border-radius-md;
  margin-bottom: 24px;
  box-shadow: $shadow-md;
  font-size: 14px;
  font-weight: 600;
  animation: slideDown 0.3s ease-out;

  strong {
    font-weight: 700;
    margin-right: 8px;
  }

  button {
    background: transparent;
    border: none;
    color: $error-red-dark;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all $transition-base;
    flex-shrink: 0;

    &:hover {
      background: $error-red;
      color: $white;
      transform: rotate(90deg) scale(1.1);
    }
  }
}

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

.card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 251, 252, 0.98) 100%);
  backdrop-filter: blur(10px);
  border-radius: $border-radius-lg;
  box-shadow: $shadow-xl;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 32px;
  margin-bottom: 24px;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: $primary-gradient;
    opacity: 0.8;
  }

  h3 {
    font-size: 24px;
    font-weight: 700;
    color: $text-dark;
    margin: 0 0 16px 0;
    letter-spacing: -0.3px;
  }
}

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

.security-status {
  margin-bottom: 24px;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;

  > div:first-child {
    flex: 1;
    min-width: 300px;
  }

  h3 {
    font-size: 22px;
    font-weight: 700;
    color: $text-dark;
    margin: 0 0 8px 0;
    letter-spacing: -0.2px;
  }
}

.security-description {
  font-size: 15px;
  color: $text-medium;
  margin: 0;
  line-height: 1.6;
  letter-spacing: 0.1px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: $border-radius-md;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: $shadow-md;
  flex-shrink: 0;
  white-space: nowrap;

  svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
    flex-shrink: 0;
  }

  &.status-enabled {
    background: linear-gradient(135deg, $success-green 0%, $success-green-dark 100%);
    color: $white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  }

  &.status-disabled {
    background: linear-gradient(135deg, $text-lighter 0%, #6b7280 100%);
    color: $white;
    box-shadow: 0 4px 12px rgba(156, 163, 175, 0.3);
  }
}

.status-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: $border-radius-md;
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: all $transition-base;

  &:hover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: $shadow-sm;
    transform: translateX(4px);
  }

  svg {
    width: 20px;
    height: 20px;
    color: $success-green;
    stroke-width: 2.5;
    flex-shrink: 0;
  }

  span {
    font-size: 14px;
    font-weight: 500;
    color: $text-dark;
    letter-spacing: 0.1px;
  }
}

.security-actions {
  display: flex;
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
}

.primary-button,
.danger-button,
.secondary-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: $border-radius-md;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all $transition-base;
  border: none;
  box-shadow: $shadow-md;
  position: relative;
  overflow: hidden;
  white-space: nowrap;

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity $transition-base;
  }

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

  span {
    position: relative;
    z-index: 1;
  }

  &:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: $shadow-lg;

    &::before {
      opacity: 1;
    }

    svg {
      transform: scale(1.1);
    }
  }

  &:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: $shadow-md;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: $shadow-sm;

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

.primary-button {
  background: $primary-gradient;
  color: $white;

  &:hover:not(:disabled) {
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  }
}

.danger-button {
  background: linear-gradient(135deg, $error-red 0%, $error-red-dark 100%);
  color: $white;

  &:hover:not(:disabled) {
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
  }
}

.secondary-button {
  background: $white;
  color: $text-medium;
  border: 1.5px solid $border-color;

  &:hover:not(:disabled) {
    background: $background-light;
    border-color: $text-light;
    color: $text-dark;
  }

  &.copied {
    background: linear-gradient(135deg, $success-green-light 0%, rgba(209, 250, 229, 0.5) 100%);
    border-color: $success-green;
    color: $success-green-dark;
  }
}

// Modal Styles
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
  padding: 20px;
}

.modal-content {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 251, 252, 0.98) 100%);
  backdrop-filter: blur(20px);
  border-radius: $border-radius-lg;
  box-shadow: $shadow-2xl;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

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

.modal-header {
  padding: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 251, 252, 0.98) 100%);
  position: sticky;
  top: 0;
  z-index: 10;

  h2 {
    font-size: 24px;
    font-weight: 700;
    color: $text-dark;
    margin: 0;
    letter-spacing: -0.3px;
    background: $primary-gradient;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: $border-radius-sm;
  border: none;
  background: transparent;
  color: $text-light;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all $transition-base;
  flex-shrink: 0;

  svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
    transition: transform $transition-base;
  }

  &:hover {
    background: $background-light;
    color: $text-dark;
    transform: rotate(90deg);
  }
}

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

.setup-step {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setup-step h3 {
  font-size: 20px;
  font-weight: 700;
  color: $text-dark;
  margin: 0 0 8px 0;
  letter-spacing: -0.2px;
}

.step-instructions {
  font-size: 15px;
  color: $text-medium;
  margin: 0 0 20px 0;
  line-height: 1.6;
  letter-spacing: 0.1px;

  &.important-notice {
    padding: 16px;
    background: linear-gradient(135deg, $warning-orange-light 0%, rgba(254, 243, 199, 0.5) 100%);
    border: 1.5px solid $warning-orange;
    border-radius: $border-radius-md;
    color: darken($warning-orange, 20%);
    font-weight: 500;

    strong {
      font-weight: 700;
    }
  }
}

.qr-code-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: $white;
  border-radius: $border-radius-md;
  border: 2px solid $border-color;
  box-shadow: $shadow-md;
  margin: 0 auto;
  max-width: 300px;
}

.qr-code-image {
  width: 100%;
  max-width: 250px;
  height: auto;
  border-radius: $border-radius-sm;
}

.loading-placeholder {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 250px;
  height: 250px;

  .spinner {
    width: 48px;
    height: 48px;
    color: $primary-blue;
    animation: spin 1s linear infinite;
  }
}

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

.secret-key-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);

  h4 {
    font-size: 16px;
    font-weight: 600;
    color: $text-dark;
    margin: 0 0 12px 0;
    letter-spacing: 0.1px;
  }
}

.secret-key-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: $background-light;
  border-radius: $border-radius-md;
  border: 1.5px solid $border-color;
  box-shadow: $shadow-sm;

  .secret-key-text {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    color: $text-dark;
    letter-spacing: 2px;
    background: $white;
    padding: 12px;
    border-radius: $border-radius-sm;
    border: 1px solid $border-color;
  }
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: $border-radius-md;
  background: $white;
  border: 1.5px solid $border-color;
  color: $text-medium;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all $transition-base;
  flex-shrink: 0;
  box-shadow: $shadow-sm;

  svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
    transition: transform $transition-base;
  }

  &:hover {
    background: $primary-blue-light;
    border-color: $primary-blue;
    color: $primary-blue;
    transform: scale(1.1);
    box-shadow: $shadow-md;

    svg {
      transform: scale(1.1);
    }
  }

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

  &.copied {
    background: $success-green-light;
    border-color: $success-green;
    color: $success-green-dark;

    &:hover {
      background: $success-green-light;
      border-color: $success-green;
      color: $success-green-dark;
    }
  }
}

.copied-message {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: $success-green-dark;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.verification-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: $text-dark;
  letter-spacing: 0.1px;
}

.form-input {
  padding: 12px 16px;
  border: 1.5px solid $border-color;
  border-radius: $border-radius-md;
  font-size: 15px;
  font-weight: 400;
  color: $text-dark;
  background: $white;
  transition: all $transition-base;
  font-family: inherit;
  box-shadow: $shadow-sm;

  &::placeholder {
    color: $text-lighter;
    font-weight: 400;
  }

  &:focus {
    outline: none;
    border-color: $primary-blue;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1), $shadow-md;
    transform: translateY(-1px);
    background: $white;
  }

  &:hover:not(:focus) {
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: $shadow-sm;
  }

  &.code-input {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 8px;
    text-align: center;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    padding: 16px;
    max-width: 200px;
    margin: 0 auto;
  }
}

.form-hint {
  font-size: 12px;
  color: $text-lighter;
  font-weight: 400;
  letter-spacing: 0.1px;
  text-align: center;
}

.backup-codes-step {
  text-align: center;
}

.backup-codes-container {
  margin: 24px 0;
}

.backup-codes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.backup-code-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: $white;
  border: 1.5px solid $border-color;
  border-radius: $border-radius-md;
  box-shadow: $shadow-sm;
  transition: all $transition-base;

  &:hover {
    background: $background-light;
    box-shadow: $shadow-md;
    transform: translateY(-2px);
  }

  .code-number {
    font-size: 14px;
    font-weight: 700;
    color: $text-medium;
    min-width: 24px;
  }

  .backup-code-text {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    color: $text-dark;
    letter-spacing: 1px;
    text-align: left;
  }
}

.backup-codes-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: $background-light;
  flex-wrap: wrap;
}

// Security Tips
.security-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;

  li {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: $border-radius-md;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: all $transition-base;

    &:hover {
      background: rgba(255, 255, 255, 0.9);
      box-shadow: $shadow-sm;
      transform: translateX(4px);
    }

    svg {
      width: 24px;
      height: 24px;
      color: $success-green;
      stroke-width: 2.5;
      flex-shrink: 0;
      margin-top: 2px;
    }

    span,
    &::before {
      font-size: 15px;
      font-weight: 400;
      color: $text-dark;
      line-height: 1.6;
      letter-spacing: 0.1px;
    }

    // Text content is directly in li, so we style it
    &:not(:has(span)) {
      &::before {
        content: attr(data-text);
      }
    }
  }
}

// Responsive Design
@media (max-width: 1024px) {
  .security-section {
    padding: 24px;
  }

  .card {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .security-section {
    padding: 20px;
  }

  .status-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .primary-button,
  .danger-button,
  .secondary-button {
    width: 100%;
    justify-content: center;
  }

  .modal-content {
    max-width: 100%;
    margin: 0;
  }

  .backup-codes-list {
    grid-template-columns: 1fr;
  }

  .backup-codes-actions {
    flex-direction: column;
    width: 100%;
  }

  .backup-codes-actions .secondary-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .section-title {
    font-size: 24px;
  }

  .card {
    padding: 20px;
  }

  .code-input {
    font-size: 20px;
    letter-spacing: 6px;
    max-width: 180px;
  }
}

// Enhanced focus states for accessibility
button:focus-visible,
input:focus-visible {
  outline: 2px solid $primary-blue;
  outline-offset: 2px;
  border-radius: $border-radius-sm;
}

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

// Performance optimizations
.security-section,
.card,
.modal-content {
  will-change: transform;
  transform: translateZ(0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

