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

:root {
  --primary: #4361ee;
  --primary-hover: #3a56d4;
  --primary-light: #eef2ff;
  --secondary: #3f37c9;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --background: #f1f5f9;
  --surface: #ffffff;
  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: rgba(67,97,238,0.15);
  --sidebar-active-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--background);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px;
  min-width: 220px;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 10;
  height: 100vh;
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
}

.sidebar-header .subtitle {
  color: var(--sidebar-text);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.nav-section {
  padding: 12px 0 4px;
}

.nav-section-title {
  padding: 0 18px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-item {
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background-color: rgba(255,255,255,0.05);
  color: #e2e8f0;
}

.nav-item.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--primary);
}

.nav-item .icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.user-card-info {
  overflow: hidden;
}

.user-card-name {
  color: #e2e8f0;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-role {
  display: inline-block;
  padding: 1px 6px;
  background: var(--primary);
  color: white;
  border-radius: 3px;
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.btn-logout {
  width: 100%;
  padding: 6px;
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: rgba(239,68,68,0.3);
  color: #fecaca;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background-color: var(--background);
}

.header {
  height: 48px;
  min-height: 48px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.header h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.content-area {
  padding: 20px 24px;
  max-width: 1400px;
  width: 100%;
}

/* ===== LOGIN ===== */
#login-view {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-box {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 18px;
}

.login-box .login-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 20px;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 14px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition);
  background-color: #f8fafc;
  color: var(--text-main);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background-color: white;
  box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.12);
}

select.form-control {
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-align: center;
  white-space: nowrap;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-success { background-color: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background-color: var(--warning); color: white; }
.btn-warning:hover { opacity: 0.9; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background: var(--background);
  border-color: var(--text-muted);
}
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 8px; font-size: 11px; }

/* ===== DASHBOARD STATS ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  border: 1px solid var(--border);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 10px;
}

.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-title {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

/* ===== TABLES ===== */
.table-container {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.table-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header h3 {
  font-size: 13px;
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 8px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

th {
  background-color: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

tr:last-child td { border-bottom: none; }
tr:hover { background-color: #f8fafc; }

.badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-active { background: var(--success-light); color: #065f46; }
.badge-pending { background: var(--warning-light); color: #92400e; }
.badge-rejected { background: var(--danger-light); color: #991b1b; }
.badge-amend { background: #dbeafe; color: #1e40af; }
.badge-viewer { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: #dbeafe; color: #1e40af; }
.badge-superadmin { background: #fce7f3; color: #9d174d; }
.badge-user { background: var(--success-light); color: #065f46; }

/* ===== VIEW SECTIONS ===== */
.view-section { display: none; animation: fadeIn 0.25s ease; }
.view-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-lg);
  max-height: 85vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--background);
  color: var(--text-main);
}

/* ===== SETTINGS PAGE ===== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.settings-card h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ===== GRANT DETAIL ===== */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.detail-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-meta-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
}

.detail-meta-item .label {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.detail-meta-item .value {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-main);
}

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 24px; margin-bottom: 8px; }
.empty-state p { font-size: 12px; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  max-width: 320px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--info); color: white; }

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

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ===== UTILITIES ===== */
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 11px; }

/* ===== ADDITIONAL BADGES ===== */
.badge-completed { background: #d1fae5; color: #065f46; }

/* ===== HISTORY TIMELINE ===== */
.history-timeline {
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.history-timeline h4 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.history-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-left: 2px solid var(--border);
  margin-left: 8px;
  padding-left: 14px;
  position: relative;
}

.history-item::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  position: absolute;
  left: -5px;
  top: 12px;
}

.history-item.action-accepted::before { background: var(--success); }
.history-item.action-rejected::before { background: var(--danger); }
.history-item.action-amend::before { background: var(--warning); }
.history-item.action-resubmitted::before { background: var(--info); }
.history-item.action-evidence_uploaded::before { background: #7c3aed; }

.history-action {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

.history-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.history-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-style: italic;
}

/* ===== NEEDS ATTENTION ===== */
.attention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
}

.attention-item:last-child { border-bottom: none; }
.attention-item:hover { background: #f8fafc; }

.attention-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.attention-icon.amend { background: #dbeafe; }
.attention-icon.rejected { background: var(--danger-light); }
.attention-icon.accepted { background: var(--success-light); }

.attention-text { flex: 1; }
.attention-text strong { font-weight: 600; }
.attention-grant { color: var(--text-muted); font-size: 11px; }

/* ===== STORAGE BAR ===== */
.storage-bar-container {
  margin-top: 12px;
}

.storage-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 8px;
}

.storage-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.storage-stats {
  display: flex;
  gap: 20px;
  font-size: 11px;
  color: var(--text-secondary);
}

.storage-stats strong {
  font-size: 13px;
  color: var(--text-main);
}

/* ===== CLICKABLE ROW ===== */
.clickable-row {
  cursor: pointer;
}
.clickable-row:hover {
  background: #eef2ff !important;
}

/* ===== REQUEST DETAIL ===== */
.req-detail-field {
  margin-bottom: 10px;
}

.req-detail-field .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.req-detail-field .value {
  font-size: 13px;
  color: var(--text-main);
  margin-top: 2px;
  white-space: pre-wrap;
}

/* ===== DELETE CONFIRM ===== */
.delete-confirm-body {
  text-align: center;
  padding: 8px 0;
}

.delete-confirm-body .delete-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.delete-confirm-body p {
  font-size: 13px;
  color: var(--text-main);
}
