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

:root {
  --primary: #6366f1;
  --primary-hover: #8b5cf6;
  --secondary: #a855f7;
  --accent: #22d3ee;
  --success: #34d399;
  --error: #f87171;
  
  --bg-dark-1: #0a0a1a;
  --bg-dark-2: #1a1a3e;
  --bg-dark-3: #0d0d2b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --glass-success: rgba(52, 211, 153, 0.1);
  --glass-error: rgba(248, 113, 113, 0.1);
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at top left, var(--bg-dark-2), var(--bg-dark-1) 40%, var(--bg-dark-3));
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-attachment: fixed;
  animation: gradient-shift 15s ease infinite alternate;
  overflow-x: hidden;
  position: relative;
}

/* Background Particles/Orbs */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.5;
  animation: float 20s infinite ease-in-out;
}

body::before {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

body::after {
  width: 300px;
  height: 300px;
  background: var(--secondary);
  bottom: -50px;
  right: -50px;
  animation-delay: -10s;
}

/* Utility Classes */
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-secondary);
}

/* Animations */
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

@keyframes pulse-border {
  0% { border-color: var(--glass-border); box-shadow: none; }
  50% { border-color: var(--primary); box-shadow: var(--shadow-glow); }
  100% { border-color: var(--glass-border); box-shadow: none; }
}

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

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

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

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

@keyframes glow {
  from { box-shadow: 0 0 10px var(--primary); }
  to { box-shadow: 0 0 20px var(--secondary); }
}

@keyframes checkmark-draw {
  0% { stroke-dashoffset: 48; }
  100% { stroke-dashoffset: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(10, 10, 26, 0.7);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.navbar .user-menu {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar .logout-link {
  color: var(--error);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.navbar .logout-link:hover {
  color: #fca5a5;
}

/* Main Dashboard */
.dashboard-main {
  max-width: 700px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

/* Upload Card */
.upload-card {
  padding: 2.5rem;
  text-align: center;
  position: relative;
  transition: box-shadow 0.3s ease;
}

.upload-card:hover {
  box-shadow: var(--shadow-glow);
  border-color: rgba(99, 102, 241, 0.3);
}

.upload-card h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.upload-card p.subtitle {
  margin-bottom: 1.5rem;
}

.badges {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.badge {
  background: var(--glass-hover);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid var(--glass-border);
}

/* Drag & Drop Zone */
.drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: 12px;
  padding: 3rem 2rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.drop-zone:hover {
  border-color: var(--primary);
  background: var(--glass-hover);
  transform: scale(1.02);
}

.drop-zone.active {
  animation: pulse-border 1.5s infinite;
  background: rgba(99, 102, 241, 0.1);
}

.drop-zone svg {
  width: 64px;
  height: 64px;
  stroke: var(--primary);
  transition: transform 0.3s ease;
}

.drop-zone:hover svg {
  transform: translateY(-5px);
}

/* File Info Panel */
.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  margin-bottom: 2rem;
  animation: fade-in 0.3s ease-out;
}

.file-info-details {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}

.file-info-icon svg {
  width: 32px;
  height: 32px;
  stroke: var(--accent);
}

.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}

.file-size {
  font-size: 0.8rem;
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove:hover {
  color: var(--error);
  background: rgba(248, 113, 113, 0.1);
}

/* Form Groups */
.form-group {
  text-align: left;
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
  background: rgba(0, 0, 0, 0.4);
}

/* Buttons */
.btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  color: #fff;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
  background: linear-gradient(135deg, var(--primary-hover), var(--secondary));
}

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

.btn-success {
  background: linear-gradient(135deg, var(--success), #10b981);
  box-shadow: 0 4px 15px rgba(52, 211, 153, 0.4);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 211, 153, 0.6);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--glass-border);
}

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

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  animation: fade-in 0.3s ease;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--glass-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Result Cards */
.result-section {
  animation: slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card {
  padding: 2.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.result-card.success {
  background: var(--glass-success);
  border-color: rgba(52, 211, 153, 0.3);
}

.result-card.error {
  background: var(--glass-error);
  border-color: rgba(248, 113, 113, 0.3);
  border-left: 4px solid var(--error);
}

.result-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.success .result-icon {
  background: rgba(52, 211, 153, 0.2);
  color: var(--success);
}

.success .result-icon svg {
  width: 40px;
  height: 40px;
  stroke: currentColor;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkmark-draw 0.6s ease-out forwards 0.2s;
}

.error .result-icon {
  background: rgba(248, 113, 113, 0.2);
  color: var(--error);
}

.error .result-icon svg {
  width: 40px;
  height: 40px;
  stroke: currentColor;
}

.result-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Shake Animation Class */
.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* =========================================
   STATS DASHBOARD
   ========================================= */

.stats-card {
  padding: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  text-align: center;
}

.stat-item {
  padding: 1rem 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
}

.stat-item:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* =========================================
   HISTORY TABLE
   ========================================= */

.table-responsive {
  overflow-x: auto;
  border-radius: 8px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table thead {
  background: rgba(0, 0, 0, 0.3);
}

.history-table th {
  padding: 0.75rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}

.history-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.history-table tbody tr {
  transition: background 0.2s ease;
}

.history-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.file-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* File type badges */
.badge-pdf { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.badge-xlsx, .badge-xls { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.badge-docx { background: rgba(59, 130, 246, 0.15); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.status-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.status-failed {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: auto;
}

/* =========================================
   LOGIN PAGE
   ========================================= */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-container {
  width: 100%;
  max-width: 420px;
  z-index: 10;
}

/* Floating Background Orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.4;
  pointer-events: none;
}

.bg-orb-1 {
  width: 450px;
  height: 450px;
  background: var(--primary);
  top: -150px;
  left: -100px;
  animation: float 18s infinite ease-in-out;
}

.bg-orb-2 {
  width: 350px;
  height: 350px;
  background: var(--secondary);
  bottom: -100px;
  right: -80px;
  animation: float 22s infinite ease-in-out reverse;
}

.bg-orb-3 {
  width: 250px;
  height: 250px;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: float 25s infinite ease-in-out;
  opacity: 0.2;
}

/* Login Card */
.login-card {
  padding: 2.5rem;
  text-align: center;
  transition: all 0.4s ease;
}

.login-card:hover {
  box-shadow: var(--shadow-glow);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Login Icon */
.login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* Login Form */
.login-card .form-group {
  text-align: left;
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 0.875rem;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 1;
}

.input-wrapper input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
  background: rgba(0, 0, 0, 0.5);
}

.input-wrapper input::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

.password-toggle {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.password-toggle:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Login Button */
.btn-login {
  margin-top: 0.5rem;
}

/* Login Error Alert */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-left: 3px solid var(--error);
  color: #fca5a5;
}

/* Login Footer */
.login-footer {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
  }

  .navbar .brand {
    font-size: 1rem;
  }

  .user-email {
    display: none;
  }

  .dashboard-main {
    margin: 1.5rem auto;
  }
  
  .upload-card, .result-card {
    padding: 1.5rem;
  }
  
  .upload-card h1 {
    font-size: 1.5rem;
  }
  
  .drop-zone {
    padding: 2rem 1rem;
  }
  
  .file-info {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
  
  .file-info-details {
    flex-direction: column;
    text-align: center;
  }

  .login-card {
    padding: 1.75rem;
  }

  .login-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .login-icon svg {
    width: 26px;
    height: 26px;
  }

  .login-title {
    font-size: 1.4rem;
  }

  .bg-orb-1 { width: 250px; height: 250px; }
  .bg-orb-2 { width: 200px; height: 200px; }
  .bg-orb-3 { width: 150px; height: 150px; }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .history-table {
    font-size: 0.75rem;
  }

  .history-table th,
  .history-table td {
    padding: 0.5rem;
  }

  .file-cell {
    max-width: 120px;
  }
}
