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

:root {
  --bg-main: #060913;
  --bg-sidebar: #0b0f19;
  --bg-card: rgba(255, 255, 255, 0.03);
  --border-color: rgba(255, 255, 255, 0.06);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --sidebar-width: 220px;
  --border-radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  display: block;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Layout */
aside.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: 24px;
  transition: var(--transition);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
}

.nav-item a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active a {
  color: #fff;
  background: var(--accent-gradient);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.nav-item a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: var(--transition);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--danger);
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.logout-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
}

.logout-btn:hover {
  background: var(--danger-glow);
}

/* Main Content Area */
main.main-content {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  padding: 40px;
  max-width: 1400px;
  transition: var(--transition);
}

.header-title-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Glass panel */
.glass-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  backdrop-filter: blur(10px);
}

/* Stats Dashboard Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
}

.stat-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper.blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-color);
}

.stat-icon-wrapper.green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-icon-wrapper.purple {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
}

.stat-icon-wrapper.orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.stat-icon-wrapper svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

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

table.data-table th, 
table.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

table.data-table th {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.1);
}

table.data-table td {
  font-size: 0.95rem;
  color: var(--text-primary);
  vertical-align: middle;
}

table.data-table tbody tr {
  transition: var(--transition);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-failed, .badge-expired, .badge-cancelled {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

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

.modal-content {
  width: 100%;
  max-width: 500px;
  background: #0b111e;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: var(--transition);
}

.modal.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Login Page Layout */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-main);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo-icon {
  margin: 0 auto 16px auto;
  width: 48px;
  height: 48px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar-toggle-btn {
    display: none !important;
  }

  aside.sidebar {
    width: 100% !important;
    height: 65px !important;
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--bg-sidebar) !important;
    border-right: none !important;
    border-top: 1px solid var(--border-color) !important;
    padding: 0 10px !important;
    z-index: 1000 !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
  }
  
  .logo-container {
    display: none !important;
  }
  
  .nav-menu {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-around !important;
    width: calc(100% - 60px) !important;
    flex-grow: 1 !important;
    gap: 0 !important;
    margin: 0 !important;
  }
  
  .nav-item {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .nav-item a {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 4px 6px !important;
    font-size: 0.65rem !important;
    color: var(--text-secondary) !important;
    background: none !important;
    box-shadow: none !important;
    height: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
  }
  
  .nav-item a svg {
    width: 20px !important;
    height: 20px !important;
  }

  .nav-item.active a {
    color: var(--accent-color) !important;
  }

  .sidebar-footer {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
    width: 60px !important;
    height: 100% !important;
  }
  
  .logout-btn {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 4px 6px !important;
    font-size: 0.65rem !important;
    color: var(--danger) !important;
    background: none !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
  }

  .logout-btn:hover {
    background: none !important;
  }
  
  main.main-content {
    margin-left: 0 !important;
    padding: 24px 20px 85px 20px !important;
    width: 100% !important;
  }
}

/* --- New Dashboard & Details UI Components --- */

.progress-bar-wrapper {
  margin-bottom: 16px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-label span:first-child {
  color: #fff;
  font-weight: 500;
}
.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 4px;
  transition: width 0.8s ease-out;
}

.status-breakdown-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.status-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-bar-label {
  width: 90px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-bar-track {
  flex-grow: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
}
.status-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s ease-out;
}
.status-bar-fill.success { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.3); }
.status-bar-fill.pending { background: var(--warning); box-shadow: 0 0 8px rgba(245, 158, 11, 0.3); }
.status-bar-fill.expired { background: var(--text-muted); }
.status-bar-fill.cancelled { background: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.3); }
.status-bar-count {
  width: 35px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}

/* Detail Modal UI Elements */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.detail-value {
  font-size: 0.9rem;
  color: #fff;
  font-weight: 500;
  word-break: break-all;
}
.detail-value-code {
  font-family: monospace;
  background: rgba(0,0,0,0.25);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  color: #e2e8f0;
}
.stock-delivery-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  margin-top: 20px;
}
.stock-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.stock-field-row:last-child {
  border-bottom: none;
}
.stock-field-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}
.btn-copy {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.btn-copy:hover {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}
.btn-copy svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Hover effects for clickable table rows */
table.data-table tbody tr.clickable-row {
  cursor: pointer;
}
table.data-table tbody tr.clickable-row:hover {
  background: rgba(255, 255, 255, 0.025) !important;
}

/* Glow Badge variants */
.badge.badge-success {
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}
.badge.badge-pending {
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
}
.badge.badge-failed {
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}

/* --- Sidebar Collapse System (Desktop only) --- */
@media (min-width: 769px) {
  .sidebar-hidden aside.sidebar {
    width: 70px;
    padding: 24px 12px;
  }
  
  .sidebar-hidden aside.sidebar .logo-container {
    justify-content: center;
    gap: 0;
    margin-bottom: 30px;
  }
  
  .sidebar-hidden aside.sidebar .logo-text {
    display: none;
  }
  
  .sidebar-hidden aside.sidebar .nav-item a {
    padding: 12px;
    justify-content: center;
    gap: 0;
  }
  
  .sidebar-hidden aside.sidebar .nav-item a span {
    display: none;
  }
  
  .sidebar-hidden aside.sidebar .sidebar-footer {
    padding-top: 16px;
    display: flex;
    justify-content: center;
  }
  
  .sidebar-hidden aside.sidebar .logout-btn {
    padding: 12px;
    justify-content: center;
    gap: 0;
  }
  
  .sidebar-hidden aside.sidebar .logout-btn span {
    display: none;
  }
  
  .sidebar-hidden main.main-content {
    margin-left: 70px;
  }
}

.sidebar-toggle-btn:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.05) !important;
}

/* --- Additional Responsive Styling for Page Contents --- */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.responsive-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: flex-start;
}

@media (max-width: 992px) {
  .analytics-grid,
  .responsive-grid {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
}

@media (max-width: 768px) {
  /* Header section stacking on mobile */
  .header-title-section {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
  }
  .header-title-section > div {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
  }
  
  .page-title {
    font-size: 1.3rem !important;
  }
  .page-subtitle {
    font-size: 0.75rem !important;
    line-height: 1.4 !important;
  }
  
  /* Less padding on card layouts to maximize space */
  .glass-panel {
    padding: 12px 14px !important;
  }
  
  /* Tables padding, sizes, and smooth scrolling */
  .table-container {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 8px !important;
    border-radius: 8px !important;
  }
  
  table.data-table {
    min-width: 720px !important; /* Forces enough width for columns to not squeeze */
    width: 100% !important;
  }
  
  table.data-table th {
    padding: 10px 8px !important;
    font-size: 0.72rem !important;
    letter-spacing: 0.2px !important;
    white-space: nowrap !important;
  }
  
  table.data-table td {
    padding: 10px 8px !important;
    font-size: 0.78rem !important;
  }
}

@media (max-width: 576px) {
  /* Stat cards: 2 columns on mobile for clean screen usage */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
  }
  .stat-card {
    padding: 10px 12px !important;
  }
  .stat-label {
    font-size: 0.65rem !important;
    letter-spacing: 0.2px !important;
  }
  .stat-value {
    font-size: 1.15rem !important;
  }
  .stat-icon-wrapper {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
  }
  .stat-icon-wrapper svg {
    width: 16px !important;
    height: 16px !important;
  }

  /* Modals responsiveness */
  .modal-content {
    width: calc(100% - 20px) !important;
    margin: 10px !important;
    border-radius: 12px !important;
  }
  .modal-body {
    padding: 14px !important;
  }
  .modal-header, .modal-footer {
    padding: 10px 14px !important;
  }
  .modal-title {
    font-size: 1.05rem !important;
  }
  
  /* Detail Grid stacks on mobile */
  .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .detail-item {
    grid-column: span 1 !important;
  }
  .detail-item[style*="grid-column: span 2"],
  .detail-item[style*="grid-column: 1 / -1"] {
    grid-column: span 1 !important;
  }
  
  .detail-label {
    font-size: 0.65rem !important;
  }
  .detail-value {
    font-size: 0.82rem !important;
  }
  
  /* Filter & search wrapper flex adjustments */
  .glass-panel[style*="display: flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .glass-panel[style*="display: flex"] > div {
    max-width: 100% !important;
  }
}
