/* =============================================
   DESIGN TOKENS — KAPAL SAKTI NUSANTARA
   ============================================= */
:root {
  /* Brand Colors */
  --brand-maroon:     #6b0f1a;
  --brand-maroon-dark:#450a11;
  --brand-maroon-mid: #8b1a28;
  --brand-gold:       #d4a017;
  --brand-gold-light: #f0c040;
  --brand-gold-pale:  #fef3c7;

  /* UI Surface */
  --bg-app:     #f5f3f0;
  --bg-sidebar: #3d0812;
  --bg-card:    #ffffff;
  --bg-hover:   #f1f0ee;
  --bg-surface: #fafaf9;

  /* Text */
  --text-main:      #1a1008;
  --text-muted:     #6b6359;
  --text-light:     #ffffff;
  --text-gold:      #d4a017;
  --text-secondary: #8b7d72;

  /* UI Utility */
  --primary-color:  #6b0f1a;
  --primary-hover:  #8b1a28;
  --info-color:     #3b82f6;
  --success-color:  #10b981;
  --warning-color:  #f59e0b;
  --danger-color:   #ef4444;

  --border-color: #e8e2d8;
  --border-gold:  rgba(212, 160, 23, 0.3);

  --shadow-sm: 0 1px 2px 0 rgba(107,15,26,0.06);
  --shadow-md: 0 4px 12px -2px rgba(107,15,26,0.12), 0 2px 4px -2px rgba(107,15,26,0.08);
  --shadow-lg: 0 10px 30px -4px rgba(107,15,26,0.18), 0 4px 10px -4px rgba(107,15,26,0.12);
  --shadow-gold: 0 4px 16px rgba(212,160,23,0.25);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;

  --font-family: 'Inter', sans-serif;
  --sidebar-width: 268px;
  --topnav-height: 68px;
}

/* =============================================
   RESET & BASE
   ============================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background-color: var(--bg-app); color: var(--text-main); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(107,15,26,0.2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(107,15,26,0.45); }

/* =============================================
   LAYOUT
   ============================================= */
.app-layout { display: flex; min-height: 100vh; width: 100%; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-content { flex: 1; padding: 32px; background-color: var(--bg-app); }

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--brand-maroon-dark) 0%, var(--brand-maroon) 60%, var(--brand-maroon-mid) 100%);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(69,10,17,0.35);
}

/* Decorative top gold line */
.sidebar::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-gold), var(--brand-gold-light), var(--brand-gold), transparent);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(212,160,23,0.25);
  background: rgba(0,0,0,0.15);
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(212,160,23,0.5);
  background: var(--brand-maroon-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-gold-light);
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
  transition: opacity 0.25s ease;
}
.sidebar-header h2 small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(240,192,64,0.6);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Sidebar Nav */
.sidebar-nav { padding: 16px 12px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 3px; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(212,160,23,0.5);
  padding: 14px 16px 6px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.65);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background-color: rgba(212,160,23,0.15);
  color: var(--brand-gold-light);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(212,160,23,0.25), rgba(212,160,23,0.1));
  color: var(--brand-gold-light);
  border: 1px solid rgba(212,160,23,0.3);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--brand-gold);
  border-radius: 0 3px 3px 0;
}
.nav-item.active .nav-icon { color: var(--brand-gold); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; transition: color 0.2s; }

/* Sidebar bottom */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(212,160,23,0.2);
  font-size: 0.75rem;
  color: rgba(212,160,23,0.4);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

/* Collapsed State */
.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .sidebar-header { padding: 20px 14px 18px; justify-content: center; }
.sidebar.collapsed .sidebar-header h2 { opacity: 0; width: 0; pointer-events: none; overflow: hidden; }
.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }
.sidebar.collapsed .nav-item span { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item.active::before { display: none; }
.sidebar.collapsed .nav-icon { margin: 0; }
.sidebar.collapsed .sidebar-footer {
  padding: 12px 8px;
}
.sidebar.collapsed .sidebar-footer button,
.sidebar.collapsed .sidebar-footer a {
  padding: 10px 0;
  justify-content: center;
}
.sidebar.collapsed .sidebar-footer button span,
.sidebar.collapsed .sidebar-footer a span {
  display: none !important;
}
.sidebar.collapsed .sidebar-info-box {
  display: none !important;
}
.sidebar.collapsed .sidebar-profile-card {
  padding: 6px 0 !important;
  justify-content: center !important;
  background: transparent !important;
}
.sidebar.collapsed .sidebar-profile-details {
  display: none !important;
}

/* =============================================
   TOPNAV
   ============================================= */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
  cursor: pointer;
  width: 40px;
  height: 40px;
}
.mobile-menu-btn:hover { background: var(--bg-hover); }
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.topnav-left { display: flex; align-items: center; gap: 12px; flex: 1; }

.hamburger-btn {
  display: flex;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 7px;
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
}
.hamburger-btn:hover { background: var(--brand-maroon); border-color: var(--brand-maroon); color: white; }

.search-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-hover);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  width: 360px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.search-bar:focus-within {
  background-color: var(--bg-card);
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,0.12);
}
.search-icon { color: var(--text-muted); margin-right: 10px; width: 16px; height: 16px; flex-shrink: 0; }
.search-bar input { border: none; background: transparent; outline: none; width: 100%; color: var(--text-main); font-size: 0.9rem; }

.topnav-actions { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  width: 36px; height: 36px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-main); border-color: var(--border-color); }
.icon-btn svg { width: 18px; height: 18px; }

.badge {
  position: absolute;
  top: 2px; right: 2px;
  background: linear-gradient(135deg, var(--brand-maroon), var(--brand-maroon-mid));
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  height: 15px; min-width: 15px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid white;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all 0.2s;
}
.user-profile:hover { background: var(--bg-hover); border-color: var(--border-color); }
.avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand-maroon), var(--brand-maroon-mid));
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(212,160,23,0.4);
}
.avatar svg { width: 16px; height: 16px; }
.user-name { font-size: 0.9rem; font-weight: 600; color: var(--text-main); }

/* =============================================
   PAGE HEADER
   ============================================= */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.text-muted { color: var(--text-muted); font-size: 0.88rem; }

/* =============================================
   BUTTONS
   ============================================= */
.primary-btn {
  background: linear-gradient(135deg, var(--brand-maroon), var(--brand-maroon-mid));
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(107,15,26,0.3);
}
.primary-btn:hover {
  background: linear-gradient(135deg, var(--brand-maroon-mid), var(--brand-maroon));
  box-shadow: 0 4px 14px rgba(107,15,26,0.4);
  transform: translateY(-1px);
}
.primary-btn svg { width: 16px; height: 16px; }

.secondary-btn {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 22px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 8px;
  transition: all 0.2s;
}
.secondary-btn:hover { background: var(--bg-hover); border-color: #ccc; }
.secondary-btn.active { background: var(--brand-maroon); color: white; border-color: var(--brand-maroon); }

/* =============================================
   PROJECT GRID & CARDS
   ============================================= */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  margin-top: 8px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
/* Gold top accent on card */
.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-maroon), var(--brand-gold), var(--brand-maroon-mid));
  opacity: 0;
  transition: opacity 0.25s;
}
.project-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(212,160,23,0.3);
}
.project-card:hover::before { opacity: 1; }

.pc-header { display: flex; justify-content: space-between; align-items: flex-start; }
.pc-id {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-maroon);
  letter-spacing: 0.05em;
  background: rgba(107,15,26,0.07);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(107,15,26,0.12);
}
.pc-title { font-size: 1.15rem; font-weight: 700; color: var(--text-main); margin-top: 8px; line-height: 1.3; }
.pc-date { display: flex; align-items: center; gap: 6px; font-size: 0.83rem; color: var(--text-muted); margin-top: 4px; }
.pc-date svg { width: 13px; height: 13px; }

/* Badges */
.pc-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-pill {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex; align-items: center; gap: 5px;
}
.badge-pill::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
}
.badge-planning   { background: #fef3c7; color: #92400e; }
.badge-planning::before   { background: #f59e0b; }
.badge-active     { background: rgba(107,15,26,0.08); color: var(--brand-maroon); border: 1px solid rgba(107,15,26,0.15); }
.badge-active::before     { background: var(--brand-maroon); }
.badge-completed  { background: #d1fae5; color: #065f46; }
.badge-completed::before  { background: #10b981; }
.badge-on_hold    { background: #fee2e2; color: #991b1b; }
.badge-on_hold::before    { background: #ef4444; }

/* Priority */
.prio-high   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.prio-medium { background: var(--brand-gold-pale); color: #92400e; border: 1px solid #fde68a; }
.prio-low    { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* Progress */
.pc-progress-section { margin-top: auto; padding-top: 14px; }
.pc-progress-header { display: flex; justify-content: space-between; font-size: 0.83rem; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.pc-progress-bar-bg { width: 100%; height: 7px; background: #ede8e0; border-radius: 4px; overflow: hidden; }
.pc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-maroon), var(--brand-gold));
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Card Footer */
.pc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

/* =============================================
   TOPNAV EXTRAS
   ============================================= */

/* Sidebar close button — mobile only */
.sidebar-close-btn {
  display: none;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(212,160,23,0.3);
  color: var(--brand-gold-light);
  padding: 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-left: auto;
  width: 28px; height: 28px;
  align-items: center;
  justify-content: center;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,0.2); }

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(69,10,17,0.5);
  z-index: 200;
  backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

/* =============================================
   RESPONSIVE — TABLET (≤ 1024px)
   ============================================= */
@media (max-width: 1024px) {
  .search-bar { width: 240px; }
  .main-content { padding: 24px; }
}

/* =============================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================= */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--sidebar-width) !important;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(69,10,17,0.4);
  }
  .sidebar-close-btn { display: flex; }
  .topnav { padding: 0 16px; height: 60px; }
  .search-bar { width: 100%; max-width: none; }
  .user-name { display: none; }
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; padding-right: 48px; }
  .page-header button { width: 100%; justify-content: center; }
  .project-grid { grid-template-columns: 1fr; gap: 14px; }
  .modal-content { width: 95% !important; margin: 4% auto !important; padding: 18px !important; }
}

@media (max-width: 480px) {
  .topnav { padding: 0 12px; }
  .main-content { padding: 12px; }
  .topnav-actions { gap: 8px; }
  .search-bar { display: none; }
}

/* =============================================
   QUALITY & SENSORY DASHBOARD
   ============================================= */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

.quality-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: grab;
  position: relative;
  min-height: 480px;
}

.quality-card:active {
  cursor: grabbing;
}

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

.quality-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-maroon);
  display: flex;
  align-items: center;
  gap: 10px;
}

.quality-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.quality-report-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 4px;
}

.quality-report-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.quality-report-item:hover {
  transform: translateY(-2px);
  border-color: var(--brand-gold);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
  .quality-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}



