* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  overflow-x: hidden;
}

/* Main App Styles */
.main-app {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header Styles */
.app-header {
  background: linear-gradient(135deg, #4f7cff 0%, #7c3aed 100%);
  padding: 16px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.6s ease-out;
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-100%);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInLeft 0.8s ease-out 0.2s both;
}

@keyframes slideInLeft {
  0% {
    opacity: 0;
    transform: translateX(-30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.menu-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  margin-right: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s;
}

.menu-btn:hover {
  transform: scale(1.1);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s ease-in-out infinite;
  transition: all 0.3s ease;
}

.logo-icon:hover {
  transform: scale(1.1) rotate(5deg);
  background: rgba(255, 255, 255, 0.3);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
  }
}

.logo-section h1 {
  color: white;
  font-size: 24px;
  font-weight: 700;
  margin: 0;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
  animation: slideInRight 0.8s ease-out 0.4s both;
}

@keyframes slideInRight {
  0% {
    opacity: 0;
    transform: translateX(30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.hamburger {
  display: none;
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  margin-right: 8px;
  cursor: pointer;
}

.welcome-text {
  margin-right: 12px;
  font-size: 14px;
  font-weight: 500;
}

.upgrade-btn {
  background: linear-gradient(90deg, #ff8a00 0%, #ff3d00 100%);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.upgrade-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 77, 0, 0.18);
}

/* Main Content */
.app-main {
  padding: 40px 0;
  position: relative;
}

/* Sidebar */
.app-sidebar {
  width: 220px;
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: calc(100vh - 160px);
  transition: transform 0.25s ease, opacity 0.25s ease;
  position: fixed;
  left: 32px;
  top: 96px;
  z-index: 10;
}

.app-sidebar.closed {
  transform: translateX(-120%);
  opacity: 0;
  pointer-events: none;
}

.app-sidebar.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header-mobile {
  display: none;
}

.sidebar-close {
  display: none;
}

.sidebar-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 20px;
}

.sidebar-user {
  font-size: 13px;
}

.sidebar-name {
  font-weight: 700;
  color: #0f172a;
}

.sidebar-email {
  font-size: 12px;
  color: #6b7280;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px 0;
}

.sidebar-item {
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #374151;
  transition: all 0.2s;
}

.sidebar-item:hover {
  background: #f3f4f6;
}

.sidebar-item.active {
  background: linear-gradient(90deg, #eef2ff, #f8f6ff);
  border-left: 3px solid #667eea;
  padding-left: 10px;
  color: #667eea;
}

.sidebar-bottom {
  text-align: left;
}

.sidebar-logout {
  background: #ff4d00;
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  font-weight: 600;
  transition: background 0.2s;
}

.sidebar-logout:hover {
  background: #e63d00;
}

/* Container */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Upload Section */
.upload-section {
  background: white;
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  margin-bottom: 32px;
  text-align: center;
  animation: centerIn 420ms cubic-bezier(.2,.9,.2,1) both;
  max-width: 820px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

@keyframes centerIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  60% {
    opacity: 1;
    transform: translateY(-6px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.upload-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2, #10b981, #667eea);
  background-size: 200% 100%;
  animation: gradientMove 3s ease-in-out infinite;
  border-radius: 16px 16px 0 0;
}

@keyframes gradientMove {
  0%, 100% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 200% 0%;
  }
}

.upload-section h2 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 8px 0;
  animation: titleGlow 0.8s ease-out 0.5s both;
}

@keyframes titleGlow {
  0% {
    opacity: 0;
    transform: translateY(20px);
    text-shadow: none;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    text-shadow: 0 0 20px rgba(103, 126, 234, 0.3);
  }
}

.upload-section p {
  font-size: 16px;
  color: #6b7280;
  margin: 0 0 32px 0;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
  margin: 0 auto;
}

.quick-actions > *:nth-child(1) {
  animation: scaleIn 0.6s ease-out 0.7s both;
}

.quick-actions > *:nth-child(2) {
  animation: scaleIn 0.6s ease-out 0.9s both;
}

.quick-actions > *:nth-child(3) {
  animation: scaleIn 0.6s ease-out 1.1s both;
}

@keyframes scaleIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.handwriting-ocr-btn,
.camera-ocr-btn,
.writing-assist-btn {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 20px 24px;
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.handwriting-ocr-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 20px rgba(103, 126, 234, 0.3);
}

.handwriting-ocr-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(103, 126, 234, 0.4);
}

.camera-ocr-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.camera-ocr-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.writing-assist-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

.writing-assist-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

.btn-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  flex-shrink: 0;
  font-size: 24px;
}

.btn-content {
  flex: 1;
}

.btn-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: white;
}

.btn-content p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

.btn-arrow {
  margin-left: 16px;
  opacity: 0.7;
  transition: all 0.2s ease;
  font-size: 20px;
}

.handwriting-ocr-btn:hover .btn-arrow,
.camera-ocr-btn:hover .btn-arrow,
.writing-assist-btn:hover .btn-arrow {
  opacity: 1;
  transform: translateX(4px);
}

/* Floating Elements */
.main-app::before {
  content: '';
  position: fixed;
  top: 20%;
  left: -5%;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, rgba(103, 126, 234, 0.1), rgba(16, 185, 129, 0.1));
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
  z-index: 0;
}

.main-app::after {
  content: '';
  position: fixed;
  bottom: 20%;
  right: -5%;
  width: 150px;
  height: 150px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(103, 126, 234, 0.1));
  border-radius: 50%;
  animation: float 8s ease-in-out infinite reverse;
  z-index: 0;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  33% {
    transform: translateY(-20px) rotate(120deg);
  }
  66% {
    transform: translateY(10px) rotate(240deg);
  }
}

.app-header,
.app-main {
  position: relative;
  z-index: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    padding: 0 16px;
  }

  .logo-section h1 {
    font-size: 20px;
  }

  .hamburger {
    display: inline-block;
  }

  .menu-btn {
    display: none;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
  }

  .user-section {
    gap: 8px;
  }

  .welcome-text {
    display: none;
  }

  .container {
    padding: 0 16px;
  }

  .upload-section {
    padding: 32px 24px;
  }

  .upload-section h2 {
    font-size: 24px;
  }

  .quick-actions {
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .app-sidebar {
    position: fixed;
    left: 16px;
    top: 72px;
    z-index: 80;
    width: 260px;
    margin: 0;
    height: calc(100vh - 96px);
    border-radius: 12px;
    transform: translateX(-120%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .app-sidebar.closed {
    transform: translateX(-120%);
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-header-mobile {
    display: block;
    text-align: right;
    margin-bottom: 12px;
  }

  .sidebar-close {
    display: inline-block;
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6b7280;
  }

  .upload-section {
    padding: 28px 20px;
  }

  .upload-section h2 {
    font-size: 22px;
  }

  .handwriting-ocr-btn,
  .camera-ocr-btn,
  .writing-assist-btn {
    padding: 18px 20px;
  }

  .btn-content h3 {
    font-size: 16px;
  }

  .btn-content p {
    font-size: 13px;
  }
}