/* ========== 🌟 CSS VARIABLES FOR THEME SYSTEM 🌟 ========== */
:root {
  /* Light Theme (Default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #6c757d;
  --border-color: #dee2e6;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #17a2b8;
  --primary: #007bff;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-card: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #adb5bd;
  --border-color: #495057;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --success: #00bc8c;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #3498db;
  --primary: #375a7f;
}

/* ========== BASE STYLES WITH THEME SUPPORT ========== */
body { 
  font-family: 'Poppins', sans-serif; 
  margin: 0; 
  background: var(--bg-primary); 
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}
h1, h2 { text-align: center; color: var(--text-primary); }
.container { max-width: 1200px; margin: 20px auto; padding: 20px; background: var(--bg-primary); }
.card { background: var(--bg-card); border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow); border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 16px; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); background: var(--bg-card); }
th, td { padding: 14px; text-align: center; border: 1px solid var(--border-color); }
th { background: var(--primary); color: white; font-weight: 600; }
tr:nth-child(even) { background: var(--bg-secondary); }
input, select, button, textarea { 
  padding: 12px 16px; 
  margin: 8px 4px; 
  border-radius: 12px; 
  border: 1px solid var(--border-color); 
  font-size: 1em; 
  font-family: 'Poppins', sans-serif;
  background: var(--bg-card);
  color: var(--text-primary);
}
button { 
  background: var(--primary); 
  color: white; 
  border: none; 
  cursor: pointer; 
  transition: all 0.3s ease; 
  font-weight: 500; 
}
button:hover { 
  background: var(--info); 
  transform: translateY(-2px); 
  box-shadow: 0 4px 12px rgba(52,152,219,0.3); 
}
button.danger { background: var(--danger); }
button.danger:hover { background: #c0392b; }
button.warning { background: var(--warning); color: #000; }
button.warning:hover { background: #e67e22; color: #000; }
button.success { background: var(--success); }
button.success:hover { background: #27ae60; }
button#loginBtn { background: var(--info); }
button#loginBtn:hover { background: #8e44ad; }
button#logoutBtn { background: var(--danger); }
button#logoutBtn:hover { background: #c0392b; }
.hidden { display: none !important; }
.modal { 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  background: rgba(0,0,0,0.5); 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  z-index: 1000; 
}
.modal-content { 
  background: var(--bg-card); 
  padding: 32px; 
  border-radius: 20px; 
  width: 90%; 
  max-width: 500px; 
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); 
  position: relative; 
  max-height: 90vh; 
  overflow-y: auto; 
  box-sizing: border-box; 
  color: var(--text-primary);
}

/* ========== 🌟 TOAST NOTIFICATION SYSTEM 🌟 ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
}

/* ========== 🌟 RESPONSIVE DESIGN IMPROVEMENTS 🌟 ========== */
@media (max-width: 768px) {
  .container {
    margin: 10px;
    padding: 15px;
  }
  
  .card {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 12px;
  }
  
  table {
    font-size: 0.85em;
  }
  
  th, td {
    padding: 8px 6px;
  }
  
  input, select, button, textarea {
    padding: 10px 12px;
    margin: 6px 3px;
    font-size: 0.9em;
  }
  
  .modal-content {
    padding: 20px;
    margin: 10px;
    width: calc(100% - 40px);
    border-radius: 16px;
  }
  
  .toast-container {
    right: 10px;
    left: 10px;
    max-width: none;
    top: 10px;
  }
  
  .toast {
    padding: 12px 16px;
    border-radius: 10px;
  }
  
  /* Mobile-specific button styles */
  button {
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
  }
  
  /* Stack form elements vertically on mobile */
  .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
  }
  
  .form-group input,
  .form-group select,
  .form-group textarea {
    margin: 4px 0;
    width: 100%;
    box-sizing: border-box;
  }
  
  /* Improve table scrolling on mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -10px;
    padding: 0 10px;
  }
  
  table {
    min-width: 600px; /* Minimum table width for horizontal scrolling */
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5em;
  }
  
  h2 {
    font-size: 1.2em;
  }
  
  .container {
    margin: 5px;
    padding: 10px;
  }
  
  /* Mobile navigation improvements */
  .nav-tabs {
    flex-direction: column;
    gap: 8px;
  }
  
  .nav-tabs button {
    width: 100%;
    text-align: center;
  }
  
  /* Smaller font sizes for very small screens */
  body {
    font-size: 14px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  button:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* Larger touch targets for mobile */
  input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }
}

.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.5s ease forwards;
  transform: translateX(100%);
  opacity: 0;
}

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

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

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

.toast.info {
  border-left-color: var(--info);
}

.toast-icon {
  font-size: 1.5em;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.toast-message {
  font-size: 0.9em;
  opacity: 0.9;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.7;
  padding: 0;
  margin: 0;
  color: var(--text-primary);
}

.toast-close:hover {
  opacity: 1;
}

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

@keyframes toastOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; align-items: center; }
.backup-section { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.toggle-switch { position: relative; display: inline-block; width: 60px; height: 30px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 30px; }
.slider:before { position: absolute; content: ""; height: 24px; width: 24px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #3498db; }
input:checked + .slider:before { transform: translateX(30px); }
.low-stock-alert { background: #ffebee; color: #c62828; padding: 16px; border-radius: 12px; margin: 16px 0; font-weight: 600; border-left: 6px solid #e53935; }
.expired-alert { background: #fff3e0; color: #ef6c00; padding: 16px; border-radius: 12px; margin: 16px 0; font-weight: 600; border-left: 6px solid #f57c00; }
.category-alert { background: #e8f5e9; color: #2e7d32; padding: 16px; border-radius: 12px; margin: 16px 0; font-weight: 600; border-left: 6px solid #4caf50; }
.low-stock-row { background: #ffebee !important; }
.expired-row { background: #fff3e0 !important; }
.expired-soon-row { background: #fff8e1 !important; }
#chartContainer { margin: 20px 0; }
.header-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; justify-content: space-between; align-items: center; }
.admin-only-section { border-top: 1px solid #eee; padding-top: 24px; margin-top: 24px; }
footer { text-align: center; padding: 20px; color: #7f8c8d; font-size: 0.9em; margin-top: 40px; }
.gambar-cell { text-align: center; vertical-align: middle; }
.gambar-cell img { transition: transform 0.2s; max-width: 50px; max-height: 50px; object-fit: cover; border-radius: 6px; }
.gambar-cell img:hover { transform: scale(1.1); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
#imagePreview img, #editImagePreview img { max-height: 150px; object-fit: contain; margin: 10px 0; border-radius: 8px; }
.image-badge { position:absolute; bottom:-5px; right:-5px; background:#3498db; color:white; border-radius:50%; width:18px; height:18px; font-size:10px; display:flex; align-items:center; justify-content:center; }
.image-container { position:relative; display:inline-block; }
.status-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.85em; font-weight: 600; margin: 2px; }
.status-active { background: #e8f5e9; color: #2e7d32; }
.status-expired { background: #ffebee; color: #c62828; }
.status-warning { background: #fff3e0; color: #ef6c00; }
.status-scrap { background: #efebe9; color: #6d4c41; }
.category-indicator { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
.category-temporary { background: #ff9800; }
.category-long { background: #4caf50; }
.category-custom { background: #9b59b6; }
.category-barang-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.8em; font-weight: 600; margin: 2px; }
.category-asset { background: #e3f2fd; color: #1565c0; }
.category-part { background: #f3e5f5; color: #7b1fa2; }
.category-general { background: #e8f5e9; color: #2e7d32; }
.extend-buttons { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; justify-content: center; }
.extend-btn { padding: 4px 8px; font-size: 0.8em; border-radius: 4px; background: #9b59b6; color: white; border: none; cursor: pointer; }
.extend-btn:hover { background: #8e44ad; }
.category-preview { background: #e3f2fd; padding: 10px 15px; border-radius: 8px; margin: 10px 0; border-left: 4px solid #2196f3; display: flex; justify-content: space-between; align-items: center; }
.category-preview.hidden { display: none; }
.expired-date-preview { font-weight: 600; color: #1565c0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.priority-indicator { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 5px; }
.priority-high { background: #e74c3c; }
.priority-medium { background: #f39c12; }
.priority-low { background: #2ecc71; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0; }
.stat-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 3px 10px rgba(0,0,0,0.08); text-align: center; }
.stat-card h3 { margin: 0 0 10px 0; font-size: 1.1em; color: #7f8c8d; }
.stat-card .value { font-size: 2em; font-weight: 700; margin: 10px 0; }
.stat-card.asset { border-top: 4px solid #3498db; }
.stat-card.part { border-top: 4px solid #9b59b6; }
.stat-card.general { border-top: 4px solid #2ecc71; }
.stat-card.expired { border-top: 4px solid #e74c3c; }
.pic-modal-content { background: white; padding: 32px; border-radius: 20px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); position: relative; }
.pic-card { background: white; border-radius: 12px; padding: 15px; margin-bottom: 15px; box-shadow: 0 3px 10px rgba(0,0,0,0.08); border-left: 4px solid #3498db; transition: transform 0.2s; }
.pic-card:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.pic-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 0.8em; font-weight: 600; background: #e3f2fd; color: #1565c0; margin: 2px; }
.pic-table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 0.9em; }
.pic-table th { background: #3498db; color: white; padding: 12px; text-align: left; }
.pic-table td { padding: 10px; border-bottom: 1px solid #eee; }
.pic-table tr:hover { background: #f8f9fa; }
.pic-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 15px 0; }
.pic-form-grid input, .pic-form-grid select, .pic-form-grid textarea { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #ddd; box-sizing: border-box; }
.pic-stats { display: flex; gap: 20px; margin: 15px 0; flex-wrap: wrap; }
.pic-stat-item { background: #f8f9fa; padding: 10px 15px; border-radius: 8px; text-align: center; min-width: 120px; }
.pic-stat-value { font-size: 1.5em; font-weight: bold; margin: 5px 0; }
.pic-stat-label { font-size: 0.85em; color: #7f8c8d; }
.btn-sm { padding: 5px 10px !important; font-size: 0.85em !important; margin: 2px !important; }
.status-aktif { color: #2ecc71; font-weight: 600; }
.status-nonaktif { color: #e74c3c; font-weight: 600; }
.scrollable-container { max-height: 300px; overflow-y: auto; border: 1px solid #eee; border-radius: 8px; padding: 10px; margin: 10px 0; }
.guest-mode-info { background: #e8f4fd; border-left: 4px solid #3498db; padding: 12px 20px; border-radius: 8px; margin: 15px 0; display: flex; align-items: center; gap: 10px; }
.guest-mode-info .icon { font-size: 1.5em; }
.guest-mode-info .text { flex: 1; }
.admin-mode-info { background: #e8f5e9; border-left: 4px solid #2ecc71; padding: 12px 20px; border-radius: 8px; margin: 15px 0; display: flex; align-items: center; gap: 10px; }
.admin-mode-info .icon { font-size: 1.5em; }
.admin-mode-info .text { flex: 1; }
.app-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.main-content { min-width: 0; }
.sidebar { position: sticky; top: 20px; height: fit-content; }
.sidebar .sidebar-user { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.sidebar .avatar { width:40px; height:40px; border-radius:50%; background:#e8f4fd; display:flex; align-items:center; justify-content:center; font-size:1.2em; }
.sidebar .sidebar-actions button { width:100%; }
.sidebar-nav a { display:block; padding:10px 12px; color:#2c3e50; text-decoration:none; border-radius:8px; margin:4px 0; }
.sidebar-nav a:hover { background:#f0f4f8; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#transactionSection { overflow-x: auto; }
#transactionSection .table-responsive { margin-top: 10px; }
#tabelInventory { min-width: 1000px; }

/* Dashboard Kategori Lokasi Penyimpanan */
.storage-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.storage-location-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border: 2px solid #e8f4fd;
  transition: all 0.3s ease;
}

.storage-location-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  border-color: #3498db;
}

.storage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.storage-header h3 {
  margin: 0;
  font-size: 1.2em;
  color: #2c3e50;
}

.storage-badge {
  background: #3498db;
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
}

.storage-progress {
  margin-bottom: 15px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #ecf0f1;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.storage-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  color: #7f8c8d;
}

.filled-slots {
  color: #27ae60;
  font-weight: 600;
}

.empty-slots {
  color: #3498db;
  font-weight: 600;
}

.storage-status {
  text-align: center;
  margin-bottom: 15px;
}

.status-indicator {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
}

.status-available {
  background: #e8f5e9;
  color: #27ae60;
}

.status-warning {
  background: #fff3e0;
  color: #f39c12;
}

.status-full {
  background: #ffebee;
  color: #e74c3c;
}

.storage-select-btn {
  width: 100%;
  padding: 12px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.storage-select-btn:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52,152,219,0.3);
}

/* Styling untuk Modal Detail Lokasi */
.location-items-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.location-item {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e9ecef;
  transition: all 0.2s ease;
}

.location-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.location-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #dee2e6;
}

.item-date {
  font-size: 0.85em;
  color: #6c757d;
  font-weight: 500;
}

.item-status {
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
}

.status-expired {
  background: #e74c3c;
  color: white;
}

.status-warning {
  background: #f39c12;
  color: white;
}

.status-safe {
  background: #2ecc71;
  color: white;
}

.status-unknown {
  background: #95a5a6;
  color: white;
}

.location-item-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.item-info {
  flex: 1;
}

.item-name {
  margin: 0 0 8px 0;
  color: #2c3e50;
  font-size: 1.1em;
}

.item-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.item-category {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 500;
}

.category-asset {
  background: #3498db;
  color: white;
}

.category-part {
  background: #9b59b6;
  color: white;
}

.category-general {
  background: #2ecc71;
  color: white;
}

.item-time, .item-expiry {
  font-size: 0.85em;
  color: #6c757d;
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 8px;
}

.item-pic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 60px;
}

.pic-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #3498db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: white;
}

.pic-name {
  font-size: 0.75em;
  color: #6c757d;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-image {
  margin-top: 12px;
  text-align: center;
}

.item-image img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.item-image img:hover {
  transform: scale(1.05);
}

.no-items-message {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
  font-size: 1.1em;
}

/* Responsive design */
@media (max-width: 768px) {
  .storage-dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .storage-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .storage-header h3 {
    font-size: 1.1em;
  }
}