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

:root {
  --bg-primary: #111111;
  --bg-secondary: #1a1a1a;
  --bg-card: #1e1e1e;
  --bg-card-hover: #252525;
  --bg-glass: rgba(255,255,255,0.03);
  --border: #2a2a2a;
  --border-light: #333;
  --accent: #E31E24;
  --accent-hover: #c91a1f;
  --accent-subtle: rgba(227,30,36,0.12);
  --accent-glow: rgba(227,30,36,0.2);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-primary: #f5f5f5;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ============ LOGIN ============ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.login-card .logo { text-align: center; margin-bottom: 28px; }
.login-card .logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.login-card .logo .brand-accent { color: var(--accent); }
.login-card .logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ============ FORM ELEMENTS ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group .error-text { color: var(--danger); font-size: 0.72rem; margin-top: 3px; }
.form-group.has-error input, .form-group.has-error .file-upload-area { border-color: var(--danger); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-light); }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.18); }
.btn-success { background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.btn-success:hover { background: rgba(34,197,94,0.18); }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.sidebar-header .brand-accent { color: var(--accent); }
.sidebar-header small { color: var(--text-muted); font-size: 0.65rem; display: block; margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--bg-glass); color: var(--text-primary); }
.sidebar-nav a.active { background: var(--accent-subtle); color: var(--accent); }
.sidebar-nav .badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 8px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-footer .user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-subtle); display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--accent); font-size: 0.78rem;
}
.sidebar-footer .user-name { font-weight: 600; font-size: 0.8rem; }
.sidebar-footer .user-role { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 28px;
  min-height: 100vh;
}
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.3px; }
.page-header p { color: var(--text-muted); margin-top: 2px; font-size: 0.83rem; }

/* ============ STATS ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
}
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.yellow::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card:hover { border-color: var(--border-light); }
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ============ TABLE ============ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
.table-header h3 { font-size: 0.9rem; font-weight: 600; }
.table-filters { display: flex; gap: 8px; align-items: center; }
.table-filters select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-family: inherit;
}

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 12px 18px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid rgba(255,255,255,0.03); transition: var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 12px 18px; font-size: 0.82rem; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.active { background: rgba(34,197,94,0.1); color: var(--success); }
.status-badge.expiring { background: rgba(245,158,11,0.1); color: var(--warning); }
.status-badge.expired { background: rgba(239,68,68,0.1); color: var(--danger); }

.actions-cell { display: flex; gap: 4px; }
.action-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: var(--transition); font-size: 0.8rem;
}
.action-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-light); }
.action-btn.delete:hover { border-color: var(--danger); color: var(--danger); }
.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 700px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.97) translateY(8px); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-glass); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ============ FORM PAGE ============ */
.form-wrapper {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 16px;
}
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.form-card-header {
  padding: 14px 22px;
  background: var(--accent-subtle);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.form-card-header h2 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.form-card-body { padding: 22px; }
.form-card-body .form-group { margin-bottom: 20px; }
.form-card-body .form-group:last-child { margin-bottom: 0; }
.form-card-body .form-group label {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 6px;
}
.form-card-body .form-group .required { color: var(--accent); margin-left: 2px; }

/* Radio */
.radio-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.radio-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  color: var(--text-secondary);
  user-select: none;
}
.radio-option:hover { border-color: var(--border-light); color: var(--text-primary); }
.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  margin: 0;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}
.radio-option input[type="radio"]:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg-primary);
}
.radio-option:has(input:checked) {
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 600;
  background: var(--accent-subtle);
}

/* File Upload */
.file-upload-area {
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.file-upload-area:hover, .file-upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.file-upload-area .upload-icon { font-size: 2rem; margin-bottom: 6px; }
.file-upload-area p { color: var(--text-secondary); font-size: 0.82rem; }
.file-upload-area .browse-link { color: var(--accent); font-weight: 600; cursor: pointer; }
.file-upload-area input[type="file"] { display: none; }
.file-upload-area .helper-text { font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; }

.file-preview-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.file-preview-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}
.file-preview-item .file-thumb {
  width: 36px; height: 36px; border-radius: 4px;
  object-fit: cover; background: var(--bg-secondary);
}
.file-preview-item .file-info { flex: 1; overflow: hidden; }
.file-preview-item .file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.file-preview-item .file-size { color: var(--text-muted); font-size: 0.68rem; }
.file-preview-item .file-remove {
  background: none; border: none;
  color: var(--danger); cursor: pointer; font-size: 1rem;
  padding: 2px; transition: var(--transition);
}

/* Progress */
.progress-bar-wrapper {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-primary);
  padding: 14px 0 10px;
}
.progress-bar-container { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }
.progress-text { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; text-align: right; }

/* ============ DETAIL VIEW ============ */
.detail-section { margin-bottom: 20px; }
.detail-section h4 {
  font-size: 0.85rem; font-weight: 600; color: var(--accent);
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.detail-field { margin-bottom: 12px; }
.detail-field .field-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }
.detail-field .field-value { font-size: 0.85rem; font-weight: 500; }
.detail-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin-top: 6px; }
.detail-images img {
  width: 100%; height: 90px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition);
}
.detail-images img:hover { border-color: var(--accent); opacity: 0.9; }

/* Lightbox */
.lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  display: none; align-items: center; justify-content: center;
  z-index: 2000; cursor: pointer;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 90%; max-height: 90%; object-fit: contain; border-radius: var(--radius); }

/* ============ TOAST ============ */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.2s ease;
  box-shadow: var(--shadow);
  max-width: 360px;
}
.toast.success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.2); color: var(--success); }
.toast.error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.2); color: var(--danger); }
.toast.warning { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.2); color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }

/* ============ EMPTY / LOADING ============ */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); font-size: 0.82rem; }

.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75); display: none;
  align-items: center; justify-content: center; z-index: 5000;
  flex-direction: column; gap: 12px;
}
.loading-overlay.active { display: flex; }
.loading-overlay p { color: var(--text-secondary); font-size: 0.85rem; }

/* ============ RESPONSIVE ============ */
.sidebar-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 200;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 1rem; cursor: pointer;
  align-items: center; justify-content: center;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; padding: 16px; padding-top: 52px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .table-wrapper { overflow-x: auto; }
  table { min-width: 550px; }
  .form-wrapper { padding: 14px 8px; }
  .form-card-body { padding: 16px; }
  .modal { max-width: 95%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .radio-group { flex-direction: column; }
}
