/* ============================================
   TELEGRAM MINI APP - SESSION MANAGER
   Premium Dark Theme with Glassmorphism
   ============================================ */

:root {
  --bg-primary: #0f0f17;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-glass: rgba(22, 33, 62, 0.7);
  --accent-primary: #6C63FF;
  --accent-secondary: #3B82F6;
  --accent-gradient: linear-gradient(135deg, #6C63FF 0%, #3B82F6 100%);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border-color: rgba(108, 99, 255, 0.15);
  --glow-primary: rgba(108, 99, 255, 0.4);
  --glow-secondary: rgba(59, 130, 246, 0.3);
  --success: #10B981;
  --error: #EF4444;
  --numpad-bg: #2a2a4a;
  --numpad-hover: #3a3a5a;
  --numpad-active: #4a4a6a;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--glow-primary);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(rgba(18, 24, 38, 0.85), rgba(18, 24, 38, 0.85)), url('images/bg.webp') no-repeat center center fixed;
  background-size: cover;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

/* ================================
   SCREENS
   ================================ */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
}

.screen.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

.screen.fade-out {
  opacity: 0;
}

/* ================================
   LOADING SCREEN
   ================================ */
.loading-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}



.loading-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.shield-icon {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 10px var(--glow-primary));
    transform: scale(1);
  }

  50% {
    filter: drop-shadow(0 0 25px var(--glow-primary));
    transform: scale(1.05);
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(108, 99, 255, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ================================
   CONFIRMATION SCREEN
   ================================ */
.confirm-container {
  width: 100%;
  max-width: 400px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  overflow-y: auto;
  max-height: 100vh;
}

.waving-hand-wrap {
  margin-top: 20px;
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
}

.waving-hand-img {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
}

.confirm-card {
  background: #242933;
  border-radius: 12px;
  padding: 20px 24px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 16px;
}

.confirm-notice {
  color: #f1f5f9;
  font-size: 15px;
  line-height: 1.6;
  font-weight: 500;
}



/* ================================
   BUTTONS
   ================================ */
.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary:disabled:hover {
  box-shadow: none;
}

.btn-primary:disabled::before {
  display: none;
}

.btn-glow {
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
}

/* ================================
   PROCESSING SCREEN
   ================================ */
.processing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px;
}

.processing-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(108, 99, 255, 0.15);
  border-top-color: var(--accent-primary);
  border-right-color: var(--accent-secondary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.processing-title {
  font-size: 22px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.processing-desc {
  color: var(--text-secondary);
  font-size: 14px;
}

.processing-dots {
  display: flex;
  gap: 8px;
}

.processing-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: bounce-dot 1.4s ease-in-out infinite;
}

.processing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.processing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce-dot {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ================================
   CODE ENTRY SCREEN
   ================================ */
.code-container {
  width: 100%;
  max-width: 400px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  overflow-y: auto;
  max-height: 100vh;
}

.code-header {
  display: flex;
  justify-content: center;
  padding: 0;
}



.code-message {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* OTP Display */
.otp-display {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 4px 0;
}

.otp-box {
  width: 48px;
  height: 52px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.otp-box.filled {
  border-color: var(--accent-primary);
  background: rgba(108, 99, 255, 0.1);
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.2);
}

.otp-box.current {
  border-color: var(--accent-secondary);
  animation: blink-border 1s ease-in-out infinite;
}

@keyframes blink-border {

  0%,
  100% {
    border-color: var(--accent-secondary);
  }

  50% {
    border-color: transparent;
  }
}

/* View Code Button */
.btn-view-code {
  width: 100%;
  padding: 14px 24px;
  background: rgba(26, 28, 35, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #2ECC71;
  border: 1px solid rgba(46, 204, 113, 0.4);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 1px;
}

.btn-view-code:hover {
  background: rgba(46, 204, 113, 0.1);
  border-color: #2ECC71;
  box-shadow: 0 0 15px rgba(46, 204, 113, 0.2);
}

.btn-view-code:active {
  transform: scale(0.98);
}

/* Number Pad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.numpad-btn {
  padding: 16px;
  background: var(--numpad-bg);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.numpad-btn:active {
  background: var(--numpad-active);
  transform: scale(0.95);
}

.numpad-empty {
  background: transparent;
  border: none;
  cursor: default;
}

.numpad-empty:hover,
.numpad-empty:active {
  background: transparent;
  transform: none;
}

.numpad-delete {
  font-size: 22px;
  color: var(--text-muted);
}

.numpad-delete:hover {
  color: var(--error);
}

/* ================================
   POPUPS
   ================================ */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fade-in 0.3s ease;
}

.popup-overlay.active {
  display: flex;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.popup-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popup-slide-up 0.4s ease;
}

@keyframes popup-slide-up {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popup-icon-error,
.popup-icon-success,
.popup-icon-2fa {
  font-size: 48px;
  line-height: 1;
}

.popup-title {
  font-size: 20px;
  font-weight: 700;
}

.popup-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.input-2fa-wrap {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

.input-2fa {
  width: 100%;
  padding: 14px 48px 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-2fa:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.btn-toggle-pw {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.btn-toggle-pw:hover {
  opacity: 1;
}

/* ================================
   RESPONSIVE
   ================================ */
@media screen and (max-height: 700px) {
  .code-container {
    gap: 8px;
    padding: 8px 16px;
  }

  .code-header {
    padding: 4px 0;
  }

  .phone-body {
    width: 56px;
    height: 80px;
  }

  .code-message {
    padding: 10px 14px;
    font-size: 12px;
  }

  .otp-box {
    width: 42px;
    height: 46px;
    font-size: 18px;
  }

  .numpad-btn {
    padding: 12px;
    font-size: 18px;
  }

  .btn-view-code {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media screen and (max-height: 580px) {
  .numpad-btn {
    padding: 10px;
    font-size: 16px;
  }

  .otp-box {
    width: 38px;
    height: 42px;
    font-size: 16px;
  }

  .code-message {
    padding: 8px 12px;
    font-size: 11px;
  }
}

/* ================================
   SCROLLBAR
   ================================ */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}