/* Enhanced Login Page Styling */
:root {
  --color-primary: #106EBE;
  --color-primary-600: #0f60a6;
  --color-primary-700: #0d4f88;
  --color-mint: #0FFCBE;
}

.login-body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-background {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.login-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="25" cy="25" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="25" cy="75" r="1" fill="%23ffffff" opacity="0.05"/><circle cx="75" cy="25" r="1" fill="%23ffffff" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

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

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.2);
  padding: 48px 40px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.login-header {
  margin-bottom: 40px;
}

.app-icon {
  margin: 0 auto 24px;
  width: 48px;
  height: 48px;
  display: inline-block;
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.login-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  color: #2d3748;
  letter-spacing: -0.5px;
}

.login-header p {
  margin: 0;
  color: #718096;
  font-size: 16px;
  font-weight: 400;
}

.error-message {
  background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
  color: #c53030;
  border: 1px solid #fc8181;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-form {
  text-align: left;
}

.input-group {
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2d3748;
  font-size: 14px;
  letter-spacing: 0.025em;
}

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

.input-icon {
  position: absolute;
  left: 16px;
  color: #a0aec0;
  z-index: 2;
  transition: color 0.2s ease;
}

.input-wrapper input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 16px;
  background: #ffffff;
  transition: all 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.input-wrapper input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16, 110, 190, 0.15);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
  color: var(--color-primary);
}

.login-button {
  width: 100%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  position: relative;
  overflow: hidden;
}

.login-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.login-button:hover::before {
  left: 100%;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(16, 110, 190, 0.3);
}

.login-button:active {
  transform: translateY(0);
}

.login-footer {
  margin-top: 40px;
}

.divider {
  position: relative;
  text-align: center;
  margin: 32px 0;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e2e8f0;
}

.divider span {
  background: rgba(255, 255, 255, 0.95);
  padding: 0 16px;
  color: #718096;
  font-size: 14px;
  font-weight: 500;
}

.scanner-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  color: #4a5568;
  text-decoration: none;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  flex-direction: column;
}

.scanner-link:hover {
  border-color: var(--color-primary);
  background: rgba(16, 110, 190, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.scanner-subtitle {
  font-size: 12px;
  color: #a0aec0;
  font-weight: 400;
}

/* Mobile Responsiveness for Login */
@media (max-width: 480px) {
  .login-background {
    padding: 16px;
  }
  
  .login-card {
    padding: 32px 24px;
    border-radius: 20px;
  }
  
  .login-header h1 {
    font-size: 24px;
  }
  
  .input-wrapper input {
    padding: 14px 14px 14px 44px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .login-button {
    padding: 14px 20px;
  }
}

/* Modern reset and typography */
* { box-sizing: border-box; }
body { 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; 
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
  color: #2d3748;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
}

.container { 
  max-width: 1600px; /* widened to avoid horizontal scroll */
  margin: 0 auto; 
  background: #fff; 
  padding: 30px; 
  border-radius: 12px; 
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@media (min-width: 1920px) {
  .container {
    max-width: 1800px; /* extra wide on very large screens */
  }
}

/* Header styling */
header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
}

header h1 {
  color: #1a202c;
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.user {
  background: #f7fafc;
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.user a {
  color: #e53e3e;
  text-decoration: none;
  font-weight: 500;
}

.user a:hover {
  text-decoration: underline;
}

/* Section styling */
section {
  margin-bottom: 40px;
  background: #f8fafc;
  padding: 25px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

section h2 {
  color: #2d3748;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 20px 0;
  border-bottom: 3px solid var(--color-primary);
  padding-bottom: 10px;
  display: inline-block;
}

/* Form styling */
form label { 
  display: block; 
  margin-top: 15px; 
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 5px;
}

input, select { 
  padding: 12px 15px; 
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  width: 100%; 
  max-width: 350px;
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(16, 110, 190, 0.15);
}

button { 
  padding: 12px 24px; 
  margin-top: 15px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

button:hover {
  background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 110, 190, 0.35);
}

button:active {
  transform: translateY(0);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
  color: #fff;
  border: 1px solid rgba(15, 96, 166, 0.2);
  padding: 8px 14px;
  font-size: 12px;
  margin: 4px 2px 0;
  border-radius: 9999px;
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(16,110,190,0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-download::before {
  content: "⬇";
  font-size: 12px;
  line-height: 1;
}

.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(16,110,190,0.25), 0 0 0 3px rgba(15,252,190,0.2);
}

.btn-download:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15,252,190,0.35);
}

/* Table styling */
table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 20px;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

thead {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
}

th { 
  padding: 15px 12px; 
  text-align: left;
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

td { 
  padding: 12px; 
  text-align: left; 
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

tr:nth-child(even) {
  background: #f8fafc;
}

tr:hover {
  background: #edf2f7;
}

/* Barcode image styling */
.barcode-cell {
  text-align: center;
}

.barcode-cell img { 
  height: 60px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  padding: 5px;
  background: white;
}

/* Status badges */
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-created { background: #bee3f8; color: #2b6cb0; }
.status-delivered { background: #c6f6d5; color: #276749; }
.status-terpakai { background: #faf089; color: #975a16; }

/* Action buttons */
.actions-cell {
  white-space: nowrap;
}

.actions-cell form {
  display: inline-block;
  margin: 0 3px;
}

.actions-cell select {
  max-width: 120px;
  padding: 4px 8px;
  font-size: 12px;
}

.actions-cell button {
  padding: 4px 8px;
  margin: 0;
  font-size: 11px;
}

.actions-cell a {
  display: inline-block;
  padding: 4px 8px;
  background: #e2e8f0;
  color: #4a5568;
  text-decoration: none;
  border-radius: 4px;
  font-size: 11px;
  margin: 2px;
  transition: background 0.2s;
}

.actions-cell a:hover {
  background: #cbd5e0;
}

/* Error styling */
.error { 
  color: #fff; 
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
  padding: 15px 20px; 
  border-radius: 8px;
  margin: 15px 0;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

/* Dashboard Toast for real-time updates */
.dashboard-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  z-index: 1001;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dashboard-toast.show {
  opacity: 1;
  transform: translateX(0);
}

.dashboard-toast-success {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.dashboard-toast-error {
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
}

.dashboard-toast-info {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
}

/* User Management Styles */
.user-form {
  background: white;
  padding: 25px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 5px;
  font-weight: 600;
  color: #4a5568;
}

.form-group input,
.form-group select {
  margin: 0;
  max-width: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
  margin-top: 10px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
}

.users-table {
  font-size: 14px;
}

.users-table th {
  font-size: 11px;
  padding: 10px 8px;
}

.users-table td {
  padding: 10px 8px;
  vertical-align: middle;
}

.inactive-user {
  opacity: 0.6;
  background: #f8f9fa !important;
}

.role-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-admin {
  background: #fed7d7;
  color: #c53030;
}

.role-operator {
  background: #bee3f8;
  color: #2b6cb0;
}

.role-viewer {
  background: #c6f6d5;
  color: #276749;
}

.status-active {
  background: #c6f6d5;
  color: #276749;
}

.status-inactive {
  background: #fed7d7;
  color: #c53030;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  margin: 1px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
}

.btn-warning {
  background: #ed8936;
  color: white;
}

.btn-warning:hover {
  background: #dd6b20;
}

.btn-success {
  background: #48bb78;
  color: white;
}

.btn-success:hover {
  background: #38a169;
}

.btn-info {
  background: var(--color-primary);
  color: white;
}

.btn-info:hover {
  background: var(--color-primary-600);
}

.btn-secondary {
  background: #a0aec0;
  color: white;
}

.btn-secondary:hover {
  background: #718096;
}

.activity-list {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  padding: 15px;
  border-bottom: 1px solid #e2e8f0;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.activity-action {
  background: #edf2f7;
  color: #4a5568;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.activity-time {
  color: #718096;
  font-size: 12px;
  margin-left: auto;
}

.activity-details {
  color: #718096;
  font-size: 13px;
}

.table-container {
  overflow-x: auto;
  background: white;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

/* Navigation enhancements */
.user a {
  margin: 0 5px;
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 10px;
  }
  
  .activity-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .activity-time {
    margin-left: 0;
  }
  
  .users-table {
    font-size: 12px;
  }
  
  .users-table th,
  .users-table td {
    padding: 6px 4px;
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .analytics-charts {
    grid-template-columns: 1fr;
  }
}

/* Advanced Analytics Styles */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: white;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.metric-icon {
  font-size: 2rem;
  opacity: 0.8;
}

.metric-content {
  flex: 1;
}

.metric-number {
  font-size: 2rem;
  font-weight: 700;
  color: #2d3748;
  line-height: 1;
  margin-bottom: 5px;
}

.metric-label {
  font-size: 12px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.analytics-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
}

.chart-wrapper {
  background: white;
  padding: 25px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-wrapper h3 {
  margin: 0 0 20px 0;
  color: #2d3748;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 2px solid #f7fafc;
  padding-bottom: 10px;
}

.chart-wrapper canvas {
  max-height: 300px;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    margin: 10px;
    padding: 20px;
  }
  
  header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  
  table {
    font-size: 14px;
  }
  
  th, td {
    padding: 8px 6px;
  }
  
  .barcode-cell img {
    height: 40px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .charts-row {
    flex-direction: column;
  }
}

/* Statistics Dashboard Styling */
.stats-controls {
  margin-bottom: 25px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.filter-form {
  margin: 0;
}

.filter-row {
  display: flex;
  gap: 20px;
  align-items: end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  margin: 0;
  font-size: 14px;
}

.filter-group input, .filter-group select {
  max-width: 150px;
  margin: 0;
}

.btn-filter {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-700) 100%);
  margin: 0;
}

.btn-filter:hover {
  background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
}

.custom-date-range {
  display: none;
  gap: 10px;
}

.custom-date-range.show {
  display: flex;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  padding: 25px 20px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card.created {
  border-left: 4px solid var(--color-primary);
}

.stat-card.delivered {
  border-left: 4px solid #48bb78;
}

.stat-card.terpakai {
  border-left: 4px solid #ed8936;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.charts-row {
  display: flex;
  gap: 30px;
  margin-top: 20px;
}

.chart-container {
  flex: 1;
  background: white;
  padding: 25px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-container h3 {
  margin: 0 0 20px 0;
  color: #2d3748;
  font-size: 1.2rem;
  font-weight: 600;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #4a5568;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.legend-color.created {
  background: var(--color-primary);
}

.legend-color.delivered {
  background: #48bb78;
}

.legend-color.terpakai {
  background: #ed8936;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.bar-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.bar-label {
  min-width: 40px;
  font-weight: 600;
  color: #2d3748;
  font-size: 14px;
}

.bar-container {
  flex: 1;
  position: relative;
  height: 25px;
  background: #f7fafc;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
  transition: width 0.3s ease;
  min-width: 2px;
}

.bar-value {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  color: #1a202c;
  background: rgba(255,255,255,0.85);
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: saturate(120%) blur(2px);
}
