@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #08090f;
  --bg-device: #11131c;
  --bg-card: rgba(22, 25, 41, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.3);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.2);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.2);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  font-family: var(--font-sans);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Ambient glow backgrounds */
body::before, body::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.35;
}

body::before {
  background: var(--primary);
  top: 15%;
  left: 20%;
}

body::after {
  background: var(--accent);
  bottom: 15%;
  right: 20%;
}

/* Mock Device Frame for Desktop, Fullscreen on Mobile */
.device-container {
  width: 390px;
  height: 844px;
  background-color: var(--bg-device);
  border: 12px solid #2e303e;
  border-radius: 48px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.05),
              inset 0 0 20px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Device notch / Dynamic Island */
.device-notch {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 30px;
  background-color: #000;
  border-radius: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.1);
}

.device-notch::after {
  content: '';
  width: 10px;
  height: 10px;
  background-color: #1a1a2e;
  border-radius: 50%;
  position: absolute;
  right: 15px;
  box-shadow: inset 0 0 2px rgba(255,255,255,0.4);
}

/* Status Bar */
.status-bar {
  height: 48px;
  padding: 12px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 99;
}

.status-bar-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-bar-icons svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Main App Wrapper inside the device */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 32px;
  position: relative;
  overflow-y: auto;
  scrollbar-width: none; /* Hide standard scrollbars */
}

.app-content::-webkit-scrollbar {
  display: none;
}

/* Header styling */
header {
  margin-top: 10px;
  margin-bottom: 24px;
  text-align: center;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

header p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Screen Layouts */
.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  position: absolute;
  inset: 16px 24px 32px;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  position: relative;
  inset: auto;
}

/* Screen Specific Styles */

/* 1. Upload Screen */
.upload-screen {
  justify-content: space-between;
}

.upload-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 32px 20px;
  cursor: pointer;
  transition: var(--transition-bounce);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 25px var(--primary-glow);
}

.upload-area.drag-over .upload-icon {
  transform: scale(1.15) translateY(-5px);
}

.upload-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  transition: var(--transition-bounce);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.upload-icon svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.2;
}

.upload-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.upload-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  max-width: 200px;
  line-height: 1.5;
}

#file-input {
  display: none;
}

/* Modern buttons */
.btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 8px 20px -6px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -4px var(--primary-glow);
  opacity: 0.95;
}

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

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 2. Processing Screen */
.processing-screen {
  justify-content: center;
  align-items: center;
  gap: 32px;
}

.loader-container {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.03);
  border-top-color: var(--primary);
  border-left-color: var(--accent);
  animation: spin 1.4s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

.loader-inner-ring {
  position: absolute;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.02);
  border-bottom-color: var(--accent);
  animation: spin-reverse 2s linear infinite;
}

.loader-icon {
  z-index: 2;
  animation: pulse-icon 2s ease-in-out infinite;
}

.loader-icon svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.progress-info {
  text-align: center;
  width: 100%;
}

.progress-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  min-height: 18px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 10px;
  transition: width 0.3s ease-out;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* 3. Password Bottom Sheet Modal */
.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #141724;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px 28px 0 0;
  padding: 24px 24px 40px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 101;
}

.modal-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  margin: 0 auto 20px;
}

.sheet-header {
  text-align: center;
  margin-bottom: 24px;
}

.sheet-icon {
  width: 52px;
  height: 52px;
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.sheet-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--warning);
  stroke-width: 2;
}

.sheet-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.sheet-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.input-group {
  position: relative;
  margin-bottom: 20px;
  width: 100%;
}

.input-field {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 48px 16px 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  outline: none;
  transition: var(--transition-smooth);
}

.input-field:focus {
  border-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.input-field.input-error {
  border-color: var(--error);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}

.input-toggle-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-toggle-btn:hover {
  color: var(--text-secondary);
}

.input-toggle-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.error-message {
  color: var(--error);
  font-size: 12px;
  margin-top: 6px;
  display: none;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.error-message.show {
  display: flex;
  animation: shake 0.4s ease;
}

/* 4. Success Screen */
.success-screen {
  justify-content: space-between;
}

.success-card {
  flex: 1;
  background-color: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.checkmark-container {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--success-glow);
  border: 2px solid var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.3);
  position: relative;
}

.checkmark-container svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: draw-check 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.2s;
}

.success-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.success-filename {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
  word-break: break-all;
  max-width: 90%;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
}

.stat-item {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Pulsing effect for main download button */
.pulse-glow {
  position: relative;
}

.pulse-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 0 15px var(--primary-glow);
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  z-index: -1;
}

/* Home indicator line on mobile mock */
.home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  z-index: 100;
}

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes spin-reverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; filter: drop-shadow(0 0 8px var(--accent-glow)); }
}

@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

@keyframes pulse-ring {
  0% { transform: scale(0.97); opacity: 0.5; }
  50% { transform: scale(1.02); opacity: 0.8; }
  100% { transform: scale(0.97); opacity: 0.5; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Responsiveness: True fullscreen on mobile */
@media (max-width: 480px) {
  body {
    background-color: var(--bg-device);
  }
  
  body::before, body::after {
    display: none;
  }
  
  .device-container {
    width: 100%;
    height: 100vh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  
  .device-notch {
    display: none;
  }
  
  .status-bar {
    padding-top: 16px;
  }
}
