* {
  box-sizing: border-box;
}

/* ✨ Modern Color Palette */
:root {
  --primary-blue: #1f5db2;
  --light-blue: #5f9bff;
  --accent-teal: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --bg-light: #f8fafc;
  --text-dark: #0f172a;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 10px 35px rgba(0, 0, 0, 0.1);
  --glass-blur: 20px;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  position: relative;
  overflow-x: hidden;
}

/* 🎨 Animated Gradient Background */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.container {
  width: min(980px, 100%);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 1.3rem 1.4rem;
  animation: fadeInUp 0.6s ease-out;
}

/* 🔐 Auth Forms (Login/Register) */
#loginFormContainer,
#registerFormContainer {
  max-width: 400px;
  margin: 0 auto;
  animation: fadeInUp 0.6s ease-out;
}

#loginFormContainer h1,
#registerFormContainer h1 {
  text-align: center;
  background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5rem;
}

.auth-toggle {
  text-align: center;
  margin-top: 1.2rem;
  color: #64748b;
  font-size: 0.9rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--light-blue);
  cursor: pointer;
  text-decoration: underline;
  font-weight: 600;
  padding: 0;
  transition: color 0.3s ease;
  font-size: 0.9rem;
}

.btn-link:hover {
  color: var(--primary-blue);
}

/* 🎬 Core Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

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

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }

  100% {
    background-position: 1000px 0;
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }
}

.hidden {
  display: none;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  animation: slideInLeft 0.6s ease-out;
}

header h1 {
  margin: 0;
  background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.8rem;
}

/* 📊 Stats Cards Section */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.6s ease-out 0.1s backwards;
}

.stat-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 1.2rem;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: scaleIn 0.5s ease-out;
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 20px 20px 0 0;
}

.stat-card.total::before {
  background: var(--primary-blue);
}

.stat-card.low::before {
  background: var(--accent-amber);
}

.stat-card.out::before {
  background: var(--accent-red);
}

.stat-card.health::before {
  background: var(--accent-teal);
}

.stat-label {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 0.5rem 0;
}

.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 0;
}

/* Color-specific numbers for each card */
.stat-card.low .stat-number {
  color: var(--accent-amber);
}

.stat-card.out .stat-number {
  color: var(--accent-red);
}

.stat-card.health .stat-number {
  color: var(--accent-teal);
}

.stat-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-top: 0.8rem;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-teal), var(--light-blue));
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: slideInLeft 0.8s ease-out;
}

.stat-card.low .stat-bar-fill {
  background: linear-gradient(90deg, var(--accent-amber), #fbbf24);
}

.stat-card.out .stat-bar-fill {
  background: linear-gradient(90deg, var(--accent-red), #f87171);
}

/* 📍 Button Styles */
.buttons-row {
  margin: 1.5rem 0;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  animation: fadeInUp 0.6s ease-out 0.2s backwards;
}

.btn {
  border: none;
  background: linear-gradient(135deg, var(--light-blue), var(--primary-blue));
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 15px rgba(95, 155, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transition: left 0.3s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(95, 155, 255, 0.4);
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--primary-blue), #1e40af);
  box-shadow: 0 4px 15px rgba(31, 93, 178, 0.3);
}

.btn.secondary {
  background: rgba(178, 198, 231, 0.8);
  color: var(--primary-blue);
  box-shadow: 0 4px 15px rgba(178, 198, 231, 0.3);
}

.btn.secondary:hover {
  background: rgba(178, 198, 231, 1);
}

.btn.danger {
  background: linear-gradient(135deg, var(--accent-red), #dc2626);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn.danger:hover {
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

.form-group {
  margin-bottom: 0.9rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dark);
}

input,
select {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--light-blue);
  background: white;
  box-shadow: 0 0 0 4px rgba(95, 155, 255, 0.15);
  transform: scale(1.01);
}

/* 📋 Table Styles */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  animation: fadeInUp 0.6s ease-out 0.3s backwards;
}

th,
td {
  border: 1px solid #e2e8f0;
  padding: 0.8rem 0.7rem;
  text-align: left;
  font-size: 0.95rem;
}

th {
  background: linear-gradient(135deg, #eef5ff, #f0f9ff);
  font-weight: 700;
  color: var(--primary-blue);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.items-table tbody tr {
  transition: all 0.3s ease;
  animation: fadeInUp 0.5s ease-out backwards;
}

.items-table tbody tr:nth-child(1) {
  animation-delay: 0ms;
}

.items-table tbody tr:nth-child(2) {
  animation-delay: 100ms;
}

.items-table tbody tr:nth-child(3) {
  animation-delay: 200ms;
}

.items-table tbody tr:nth-child(4) {
  animation-delay: 300ms;
}

.items-table tbody tr:nth-child(5) {
  animation-delay: 400ms;
}

.items-table tbody tr:nth-child(6) {
  animation-delay: 500ms;
}

.items-table tbody tr:nth-child(n+7) {
  animation-delay: 600ms;
}

.items-table tr:hover {
  background: linear-gradient(90deg, rgba(95, 155, 255, 0.05), rgba(16, 185, 129, 0.05));
  transform: scale(1.01);
  box-shadow: inset 0 0 20px rgba(95, 155, 255, 0.1);
}

/* 📊 Progress Bar in Table */
.stock-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  width: var(--percentage, 0%);
  background: linear-gradient(90deg, var(--accent-teal), var(--light-blue));
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-fill.warning {
  background: linear-gradient(90deg, var(--accent-amber), #fbbf24);
}

.progress-fill.critical {
  background: linear-gradient(90deg, var(--accent-red), #f87171);
  animation: pulse 1.5s ease-in-out infinite;
}

.progress-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  min-width: 35px;
}

.info {
  color: #3f6b9e;
  font-style: italic;
}

.error {
  color: var(--accent-red);
  margin-top: 0.6rem;
  font-weight: 600;
  animation: slideInLeft 0.4s ease-out;
}

.form-card {
  background: rgba(248, 251, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(95, 155, 255, 0.2);
  border-radius: 16px;
  padding: 1.3rem;
  margin-bottom: 1.5rem;
  animation: slideInLeft 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 32px rgba(95, 155, 255, 0.1);
}

.form-card h2 {
  margin: 0 0 1rem 0;
  background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-bar {
  margin-bottom: 1.2rem;
  animation: fadeInUp 0.6s ease-out 0.25s backwards;
}

.search-bar input {
  max-width: 350px;
  border: 2px solid #e2e8f0;
  transition: all 0.3s ease;
}

.search-bar input:focus {
  box-shadow: 0 0 0 4px rgba(95, 155, 255, 0.15), 0 0 20px rgba(95, 155, 255, 0.2);
}

.status-warning {
  color: var(--accent-amber);
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 6px;
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

.status-danger {
  color: var(--accent-red);
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 6px;
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-ok {
  color: var(--accent-teal);
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 6px;
  display: inline-block;
}

.alerts-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
  border: 2px solid var(--accent-amber);
  border-radius: 16px;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  animation: slideInLeft 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(10px);
}

.alerts-box h3 {
  margin: 0 0 0.7rem 0;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.alerts-box ul {
  margin: 0;
  padding-left: 1.5rem;
  list-style: none;
}

.alerts-box li {
  color: #92400e;
  margin-bottom: 0.5rem;
  transition: all 0.3s ease;
  padding: 0.3rem 0;
  border-left: 3px solid var(--accent-amber);
  padding-left: 0.7rem;
}

.alerts-box li:hover {
  padding-left: 1rem;
}

/* 📊 Chart Container */
.chart-section {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 1.5rem;
  margin-top: 2rem;
  animation: fadeInUp 0.6s ease-out 0.4s backwards;
}

.chart-section h2 {
  margin: 0 0 1.5rem 0;
  background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#categoryChart {
  max-width: 400px;
  max-height: 400px;
  margin: 0 auto;
}

/* � Toast Notifications */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-left: 5px solid var(--primary-blue);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: slideInRight 0.4s ease-out;
  pointer-events: auto;
  font-weight: 500;
  color: #1f5db2;
}

.toast.success {
  border-left-color: var(--accent-teal);
  color: var(--accent-teal);
}

.toast.warning {
  border-left-color: var(--accent-amber);
  color: var(--accent-amber);
}

.toast.error {
  border-left-color: var(--accent-red);
  color: var(--accent-red);
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }

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

.toast-close {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(400px);
  }
}

/* 🏷️ Category Filter Tabs */
.filter-section {
  margin: 1.5rem 0;
  animation: fadeInUp 0.6s ease-out 0.15s backwards;
}

.filter-section h3 {
  margin: 0 0 0.8rem 0;
  font-size: 0.95rem;
  color: #475569;
}

.filter-tabs {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.7rem 1.2rem;
  border: 2px solid #e2e8f0;
  background: white;
  color: #475569;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.filter-tab:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background: rgba(31, 93, 178, 0.05);
}

.filter-tab.active {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
  box-shadow: 0 4px 15px rgba(31, 93, 178, 0.3);
}

/* ⚡ Quick Action Buttons */
.qty-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
}

.qty-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #cbd5e1;
  background: white;
  color: var(--primary-blue);
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:hover {
  background: var(--primary-blue);
  color: white;
  border-color: var(--primary-blue);
  transform: scale(1.1);
}

.qty-display {
  font-weight: 600;
  color: var(--text-dark);
  min-width: 25px;
  text-align: center;
  font-size: 0.9rem;
}

/* �📱 Mobile Responsive */
@media (max-width: 720px) {
  body {
    padding: 0.6rem;
  }

  .container {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.8rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .buttons-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  th,
  td {
    font-size: 0.8rem;
    padding: 0.5rem 0.3rem;
  }

  .progress-bar {
    min-width: 60px;
  }

  .progress-text {
    font-size: 0.7rem;
    min-width: 30px;
  }

  header {
    flex-direction: column;
    gap: 0.8rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  header button {
    width: 100%;
  }

  .search-bar input {
    max-width: 100%;
  }

  .form-card {
    padding: 1rem;
  }

  .chart-section {
    padding: 1rem;
  }

  #categoryChart {
    max-width: 100%;
  }
}

/* 📱 Extra Small Mobile (< 480px) */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
  }

  .container {
    padding: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .stat-card {
    padding: 0.8rem;
  }

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

  .stat-label {
    font-size: 0.75rem;
  }

  .stat-bar {
    height: 6px;
  }

  header {
    gap: 0.5rem;
  }

  header h1 {
    font-size: 1.1rem;
  }

  .buttons-row {
    gap: 0.4rem;
  }

  .btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  .search-bar {
    margin-bottom: 0.5rem;
  }

  .search-bar input {
    padding: 0.5rem;
  }

  table {
    font-size: 0.7rem;
  }

  th,
  td {
    padding: 0.3rem 0.2rem;
  }

  .list-item {
    flex-wrap: wrap;
  }

  .item-actions button {
    padding: 0.4rem 0.6rem;
  }

  .modal {
    width: 95%;
  }

  .form-card {
    padding: 0.8rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px;
    /* Prevent zoom on iOS */
  }

  .toast {
    padding: 0.8rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .alerts-container {
    max-height: 150px;
  }

  .alert-item {
    padding: 0.5rem;
  }
}