:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --secondary: #64748b;
  --dark-sidebar: #0f172a;
  --dark-sidebar-hover: #1e293b;
  --accent-gold: #f59e0b;
  --accent-gold-light: #fef3c7;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 56px;
  --sidebar-transition: 0.25s ease;
  --radius: 8px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* ===== Top Navigation Bar (legacy — disembunyikan, konten dipindah ke sidebar) ===== */
.katya-header {
  display: none; /* Navbar dipindah ke sidebar — header tidak lagi digunakan */
}
.katya-brand, .brand-title, .katya-nav-right, .nav-shortcut-link { display: none; }

.badge-env {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background-color: rgba(255,255,255,0.08);
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
}

.badge-counter {
  background-color: var(--danger);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
}

.user-identity-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-details .uname {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-details .urole {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== App Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--sidebar-transition);
}

.app-layout.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

/* ===== Fixed Sidebar Navigation ===== */
.katya-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background-color: var(--dark-sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
  z-index: 200;
  overflow: hidden;
  transition: width var(--sidebar-transition);
}

.katya-sidebar.sidebar-collapsed {
  width: var(--sidebar-collapsed-width);
}

/* ===== Sidebar Brand Toggle Header ===== */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #1e293b;
  cursor: pointer;
  user-select: none;
  min-height: 58px;
  flex-shrink: 0;
  background: #0a1120;
  transition: background 0.15s;
  overflow: hidden;
}
.sidebar-brand:hover { background: #1e293b; }

.sidebar-brand-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--sidebar-transition), max-width var(--sidebar-transition);
  max-width: 180px;
}

.sidebar-brand-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.sidebar-brand-env {
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  margin-top: 2px;
}

/* ===== Sidebar Scrollable Menu ===== */
.sidebar-menu {
  padding: 0.75rem 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.menu-group-header {
  padding: 0.75rem 1.25rem 0.35rem;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--sidebar-transition), max-height var(--sidebar-transition), padding var(--sidebar-transition);
}

.menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
}

.menu-link-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
  flex: 1;
}

.menu-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--sidebar-transition);
}

.menu-chevron {
  font-size: 0.75rem;
  color: #94a3b8;
  flex-shrink: 0;
  transition: opacity var(--sidebar-transition);
}

.menu-link:hover {
  background-color: var(--dark-sidebar-hover);
  color: #ffffff;
}

.menu-link.active {
  background-color: var(--primary);
  color: #ffffff;
}

/* ===== Sidebar User Footer ===== */
.sidebar-user {
  padding: 0.75rem 1rem;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  background: #0a1120;
  overflow: hidden;
  transition: padding var(--sidebar-transition);
}

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

.sidebar-user-info {
  overflow: hidden;
  flex: 1;
  transition: opacity var(--sidebar-transition), max-width var(--sidebar-transition);
  max-width: 160px;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.68rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.sidebar-logout-form {
  margin: 0 0 0 auto;
  flex-shrink: 0;
  display: flex;
}

.sidebar-logout-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.sidebar-logout-btn:hover { color: var(--danger); background: rgba(239,68,68,0.08); }

/* ===== COLLAPSED STATE ===== */

/*
 * Fase 1 — Preload (sebelum JS aktif):
 * Inline script di <head> set class ini ke <html> langsung dari localStorage
 * agar sidebar tidak flash mengembang dulu saat navigasi antar halaman.
 * transition: none agar tidak ada animasi saat restore state awal.
 */
html.sidebar-preload .katya-sidebar {
  width: var(--sidebar-collapsed-width);
  transition: none;
}
html.sidebar-preload .app-layout {
  margin-left: var(--sidebar-collapsed-width);
  transition: none;
}
html.sidebar-preload .sidebar-brand-text  { opacity: 0; max-width: 0; overflow: hidden; }
html.sidebar-preload .menu-group-header   { opacity: 0; max-height: 0; padding: 0; overflow: hidden; }
html.sidebar-preload .menu-label          { display: none; }
html.sidebar-preload .menu-chevron        { display: none; }
html.sidebar-preload .menu-link           { padding: 0.85rem 0; justify-content: center; overflow: hidden; }
html.sidebar-preload .menu-link-inner     { flex: 0 0 16px; width: 16px; justify-content: center; gap: 0; }
html.sidebar-preload .sidebar-user        { flex-direction: column; justify-content: center; align-items: center; padding: 0.65rem 0; gap: 0.45rem; }
html.sidebar-preload .sidebar-user-avatar { width: 28px !important; height: 28px !important; font-size: 0.75rem !important; }
html.sidebar-preload .sidebar-user-info   { display: none; }
html.sidebar-preload .sidebar-logout-form { margin: 0; width: 100%; display: flex; justify-content: center; }
html.sidebar-preload .sidebar-logout-btn  { display: flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 6px; }
.katya-sidebar.sidebar-collapsed .sidebar-brand-text {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}

.katya-sidebar.sidebar-collapsed .menu-group-header {
  opacity: 0;
  max-height: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Sembunyikan label & chevron */
.katya-sidebar.sidebar-collapsed .menu-label {
  display: none;
}

.katya-sidebar.sidebar-collapsed .menu-chevron {
  display: none;
}

/* Menu link: padding simetris, ikon di tengah */
.katya-sidebar.sidebar-collapsed .menu-link {
  padding: 0.85rem 0;
  justify-content: center;
  overflow: hidden;
}

/* Inner: lebar persis ikon (16px), tidak auto agar teks panjang
   tidak mendorong layout — ikon selalu terpusat di kolom 56px */
.katya-sidebar.sidebar-collapsed .menu-link-inner {
  flex: 0 0 16px;
  width: 16px;
  justify-content: center;
  gap: 0;
  overflow: visible;
}

/* Pastikan SVG tidak tertutup */
.katya-sidebar.sidebar-collapsed .menu-link-inner svg {
  display: block;
  flex-shrink: 0;
}

/* User footer saat collapsed */
.katya-sidebar.sidebar-collapsed .sidebar-user {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.65rem 0;
  gap: 0.45rem;
}

.katya-sidebar.sidebar-collapsed .sidebar-user-avatar {
  width: 28px !important;
  height: 28px !important;
  font-size: 0.75rem !important;
}

.katya-sidebar.sidebar-collapsed .sidebar-user-info {
  display: none;
}

.katya-sidebar.sidebar-collapsed .sidebar-logout-form {
  margin: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.katya-sidebar.sidebar-collapsed .sidebar-logout-btn {
  display: flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #94a3b8;
}

.katya-sidebar.sidebar-collapsed .sidebar-logout-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}


/* ===== Main Workspace ===== */
.katya-workspace {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow-y: auto;
  max-width: 1400px;
  min-height: 100vh;
}

/* Page Headers */
.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.workspace-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #0f172a;
}

.workspace-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Tabs Navigation */
.katya-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 0.5rem;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background-color: rgba(2, 132, 199, 0.04);
  border-radius: 6px 6px 0 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafafa;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.card-body {
  padding: 1.25rem;
}

/* Stat Grid */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
}

.stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.stat-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #334155;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-input:disabled, .form-select:disabled, .form-textarea:disabled {
  background-color: #f1f5f9;
  cursor: not-allowed;
  color: #64748b;
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

.btn-primary:disabled {
  background-color: #94a3b8;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: #f1f5f9;
  color: #1e293b;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
}

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

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

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.app-table th {
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.app-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.app-table tr:hover {
  background-color: #f8fafc;
}

/* Badges & Status */
.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  font-size: 0.725rem;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-draft {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-waiting {
  background-color: var(--accent-gold-light);
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-completed {
  background-color: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-rejected {
  background-color: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Photo Thumbnail & Evidence */
.evidence-gallery {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.evidence-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s;
}

.evidence-thumb:hover {
  transform: scale(1.1);
}

/* Lock Banner */
.lock-banner {
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  padding: 0.85rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #92400e;
  font-size: 0.875rem;
}

/* Alerts */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
}

.alert-success {
  background-color: var(--success-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-error {
  background-color: var(--danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background-color: var(--primary-light);
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: inherit;
  opacity: 0.6;
}

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

/* Login Katya */
.login-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  padding: 2.25rem 2rem;
}

/* Timeline Approval */
.approval-timeline {
  position: relative;
  padding-left: 2rem;
  margin: 1rem 0;
}

.approval-timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 9px;
  width: 2px;
  background-color: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ffffff;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-content {
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
