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

:root {
  --bg-dark: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.7);
  --border-light: rgba(0, 0, 0, 0.1);
  --text-main: #111827;
  --text-muted: #4b5563;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --glass-blur: blur(20px);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background: var(--bg-dark);
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
}

/* Glassmorphism Classes */
.glass {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
}

.glass:hover {
  border-color: rgba(148, 163, 184, 0.3);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--border-light);
  border-radius: 0 16px 16px 0;
  overflow-y: auto;
  background-color: lightgrey;
  box-shadow: none;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 2.5rem;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.nav-links a i {
  font-size: 1.25rem;
  transition: transform 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.nav-links a:hover i {
  transform: translateX(3px);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
  transition: all 0.3s ease;
  color: var(--danger) !important;
}

.logout-btn i {
  font-size: 1.25rem;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  border-left: 3px solid var(--danger) !important;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2.5rem 3.5rem;
  max-width: calc(100% - 280px);
  animation: fadeIn 0.5s ease;
}

/* Page Headers */
.page-header {
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #111827, #4b5563);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Cards & Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.metric-card {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

.metric-title {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-title i {
  font-size: 1.2rem;
}

.metric-value {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-top: 5px;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  margin-bottom: 2rem;
  border: 1px solid var(--border-light);
  position: relative;
  /* For floating button */
}

.download-table-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  background: var(--success);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(-10px);
}

.table-container:hover .download-table-btn {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

th {
  background: rgba(240, 240, 240, 0.9);
  backdrop-filter: blur(5px);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
}

tr:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.5rem;
  position: relative;
  /* For cancel button */
}

.cancel-upload-btn {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  background: var(--danger);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
}

.cancel-upload-btn:hover {
  background: #dc2626;
  transform: translateY(-50%) scale(1.1);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: rgba(255, 255, 255, 0.8);
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}

/* Flashes */
.flash-messages {
  margin-bottom: 1.5rem;
}

.flash {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  font-weight: 500;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  border-left: 4px solid;
}

.flash.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.flash.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.flash.warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning);
  color: var(--warning);
}

.flash.info {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

/* Login Page Only */
.login-body {
  justify-content: center;
  align-items: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 3rem 2.5rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.progress-bar-bg {
  width: 100%;
  background: var(--border-light);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.progress-bar-indeterminate {
  width: 50%;
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  animation: progress-indeterminate 1.5s infinite linear;
}

/* Grid Layouts for views */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}

.empty-state {
  text-align: center;
  padding: 4rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.6;
  color: var(--primary);
}

/* Pagination Component */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 12px 12px;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pagination-btn {
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  min-width: 40px;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.05);
}

.pagination-current {
  font-weight: 700;
  color: var(--primary);
  padding: 0 0.5rem;
}

/* Full Export Button Styling */
.btn-full-export {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: var(--success);
  color: white !important;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none !important;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
}

.table-container:hover .btn-full-export {
  opacity: 1;
  pointer-events: auto;
}

.btn-full-export:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
  color: white !important;
}

.btn-full-export i {
  font-size: 1.1rem;
}

/* Ensure container has relative positioning for the button and loading overlay */
.table-container {
  position: relative;
}

/* Table Loading State Overlay */
.table-container.table-loading::after {
    content: "Updating records...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 2rem;
    border-radius: 30px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border-light);
}