/* ============================================
   GLOBAL RESET & BASE STYLES
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ============================================
   CONNECTION SCREEN (Initial Loading)
   ============================================ */
.connection-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeIn 0.5s ease;
}

.connection-container {
  text-align: center;
  color: white;
}

.connection-icon {
  margin-bottom: 30px;
  position: relative;
  width: 80px;
  height: 80px;
  margin-left: auto;
  margin-right: auto;
}

.spinner {
  width: 80px;
  height: 80px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid #4CAF50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.connection-status {
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 20px;
  color: #e0e0e0;
  letter-spacing: 0.5px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.connection-progress {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}

.connection-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

/* ============================================
   PHONE CONTAINER & DEVICE
   ============================================ */
.phone-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  perspective: 1000px;
  animation: fadeIn 1s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.phone-device {
  position: relative;
  width: 375px;
  height: 812px;
  max-width: 90vw;
  max-height: 95vh;
  animation: phoneAppear 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes phoneAppear {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(50px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   PHONE FRAME & BODY
   ============================================ */
.phone-frame {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 45px;
  overflow: hidden;
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.5),
    0 15px 30px rgba(0, 0, 0, 0.3),
    inset 0 0 0 2px rgba(255, 255, 255, 0.1);
  border: 12px solid #1a1a1a;
}

.phone-shadow {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 30px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
  filter: blur(15px);
}

/* ============================================
   STATUS BAR
   ============================================ */
.status-bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 44px;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 100%);
  color: white;
  font-size: 15px;
  font-weight: 600;
  z-index: 100;
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.status-time {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.status-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  height: 30px;
  background: #000;
  border-radius: 0 0 20px 20px;
  z-index: 5;
}

.status-signal,
.status-wifi,
.status-battery {
  display: flex;
  align-items: center;
}

/* ============================================
   LOCK SCREEN
   ============================================ */
.lock-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #1e3c72 0%, #2a5298 50%, #7e8ba3 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  animation: lockScreenFadeIn 0.5s ease;
}

@keyframes lockScreenFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lock-screen-content {
  text-align: center;
  animation: lockIconBounce 1s ease;
}

@keyframes lockIconBounce {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.lock-icon {
  margin-bottom: 20px;
  animation: lockShake 0.5s ease 0.5s;
}

@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.lock-text {
  color: white;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ============================================
   AUTHENTICATOR APP
   ============================================ */
.authenticator-app {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #f5f5f5 0%, #e8e8e8 100%);
  animation: appSlideIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes appSlideIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  padding: 60px 20px 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
}

.app-icon {
  filter: brightness(0) invert(1);
}

/* TOTP Container */
.totp-container {
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.account-info {
  text-align: center;
}

.account-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.account-email {
  font-size: 0.9rem;
  color: #666;
}

/* Code Display */
.code-display {
  text-align: center;
  background: white;
  padding: 30px 40px;
  border-radius: 20px;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.05);
  min-width: 280px;
  animation: codeReveal 0.5s ease;
}

@keyframes codeReveal {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.totp-code {
  font-size: 3rem;
  font-weight: 700;
  color: #1976d2;
  letter-spacing: 12px;
  font-family: "Courier New", Courier, monospace;
  margin-bottom: 10px;
  text-align: center;
  transition: all 0.3s ease;
}

.totp-code.updating {
  animation: codeUpdate 0.4s ease;
}

@keyframes codeUpdate {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.95);
    opacity: 0.5;
  }
}

.code-label {
  font-size: 0.85rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

/* Circular Timer */
.timer-container {
  position: relative;
  width: 80px;
  height: 80px;
}

.timer-circle {
  transform: rotate(-90deg);
}

.timer-bg {
  fill: none;
  stroke: #e0e0e0;
  stroke-width: 6;
}

.timer-progress {
  fill: none;
  stroke: #4CAF50;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 226.195;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 700;
  color: #333;
}

/* Timer Color States */
.timer-progress.warning {
  stroke: #FF9800;
}

.timer-progress.danger {
  stroke: #f44336;
  animation: timerPulse 0.5s ease infinite;
}

@keyframes timerPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
  .phone-device {
    width: 340px;
    height: 736px;
  }

  .phone-frame {
    border-radius: 40px;
    border-width: 10px;
  }

  .totp-code {
    font-size: 2.5rem;
    letter-spacing: 8px;
  }

  .code-display {
    min-width: 240px;
    padding: 25px 30px;
  }
}

@media (max-width: 480px) {
  .phone-device {
    width: 320px;
    height: 680px;
  }

  .phone-frame {
    border-radius: 35px;
    border-width: 8px;
  }

  .status-bar {
    padding: 0 15px;
  }

  .status-notch {
    width: 150px;
    height: 25px;
  }

  .app-header {
    padding: 50px 15px 15px;
  }

  .app-title {
    font-size: 1.3rem;
  }

  .totp-container {
    padding: 30px 15px;
    gap: 25px;
  }

  .totp-code {
    font-size: 2rem;
    letter-spacing: 6px;
  }

  .code-display {
    min-width: 200px;
    padding: 20px 25px;
  }

  .connection-progress {
    width: 250px;
  }

  .connection-status {
    font-size: 1rem;
  }
}

@media (max-height: 700px) {
  .phone-device {
    height: 85vh;
  }

  .totp-container {
    padding: 25px 15px;
    gap: 20px;
  }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .phone-device {
    width: 300px;
    height: 90vh;
  }

  .totp-container {
    padding: 20px 15px;
    gap: 15px;
  }

  .code-display {
    padding: 15px 20px;
  }

  .totp-code {
    font-size: 1.8rem;
  }
}

/* High-DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .phone-frame {
    box-shadow: 
      0 40px 80px rgba(0, 0, 0, 0.6),
      0 20px 40px rgba(0, 0, 0, 0.4),
      inset 0 0 0 2px rgba(255, 255, 255, 0.1);
  }
}

/* ============================================
   FADE-OUT ANIMATIONS (for transitions)
   ============================================ */
.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.slide-up-out {
  animation: slideUpOut 0.6s ease forwards;
}

@keyframes slideUpOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}
