@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Modern Indigo-Purple Color Palette */
  --primary-color: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary-color: #4c1d95;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #06b6d4;
  --light-bg: #f5f7fb;
  --very-light-bg: #fafbfc;
  --dark-text: #1f2937;
  --gray-text: #6b7280;
  --border-color: #e5e7eb;
  --light-border: #f0f1f3;
  --shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
  --shadow-md: 0 4px 12px rgba(99, 102, 241, 0.1);
  --shadow-lg: 0 10px 25px rgba(99, 102, 241, 0.12);
  --font-size-lg: 1.4rem;
  --font-size-md: 1.2rem;
  --font-size-sm: 0.7rem;
}

body {
  font-family: "Poppins", "Inter", sans-serif;
  background-color: var(--light-bg);
  color: var(--dark-text);
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: var(--font-size-sm);
  overflow-x: hidden; /* prevent horizontal scroll globally */
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
}

h1 {
  font-size: var(--font-size-lg);
  margin-bottom: 0.3rem;
}

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 1rem;
}

.main-wrapper {
  display: flex;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  margin-top: 70px;
  flex: 1;
  min-height: calc(100vh - 70px);
  align-items: stretch;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 20px;
  padding-top: 30px;
  line-height: 1.6;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
  background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
  color: white;
  padding: 0.8rem 1.5rem;
  box-shadow: var(--shadow-lg);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  z-index: 1001;
  align-items: center;
  justify-content: space-between;
}

.navbar-container {
  max-width: none;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  font-size: var(--font-size-md);
  font-weight: 600;
  text-decoration: none;
  color: white;
  letter-spacing: -0.5px;
}

.navbar-menu {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin-left: auto;
}

.navbar-menu a {
  color: white;
  text-decoration: none;
  transition: opacity 0.3s ease;
  font-size: var(--font-size-sm);
}

.navbar-menu a:hover {
  opacity: 0.7;
}

/* Profile Dropdown */
.profile-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-btn {
  background-color: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.profile-btn:hover {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

.profile-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: white;
  border: 1px solid var(--light-border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  min-width: 280px;
  display: none;
  margin-top: 0.8rem;
  z-index: 10000;
  overflow: hidden;
}

.profile-dropdown-menu.show {
  display: block;
}

.profile-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
  color: white;
  padding: 1.5rem;
  text-align: center;
}

.profile-initials {
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

.profile-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  word-break: break-word;
}

.profile-role {
  font-size: 0.8rem;
  opacity: 0.85;
  text-transform: capitalize;
}

.profile-menu-items {
  border-top: 1px solid var(--light-border);
  padding: 0.8rem 0;
}

.profile-menu-item {
  padding: 0.8rem 1.2rem;
  color: var(--dark-text);
  text-decoration: none;
  display: block;
  transition: all 0.2s ease;
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-left: 3px solid transparent;
}

.profile-menu-item:hover {
  background-color: var(--light-bg);
  border-left-color: var(--primary-color);
}

.profile-menu-divider {
  height: 1px;
  background-color: var(--light-border);
  margin: 0.5rem 0;
}

.profile-logout {
  padding: 0.8rem 1.2rem;
  color: var(--danger-color);
  text-decoration: none;
  display: block;
  transition: all 0.2s ease;
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-top: 1px solid var(--light-border);
}

.profile-logout:hover {
  background-color: rgba(239, 68, 68, 0.05);
}

.logout-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.logout-btn:hover {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
  max-width: 1300px;
  width: 100%;
}

.container-fluid {
  padding: 0.5rem 0.5rem;
  width: 100%;
}

.sidebar {
  background-color: #ffffff;
  width: 250px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: var(--shadow-md);
  border-right: 1px solid var(--light-border);
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-menu {
  list-style: none;
  padding: 0.7rem;
  flex: 1;
}

.sidebar-menu li {
  margin-bottom: 0.4rem;
}

.sidebar-menu a {
  display: block;
  padding: 0.5rem 0.5rem;
  color: var(--dark-text);
  text-decoration: none;
  transition: all 0.3s ease;
  border-radius: 8px;
  border-left: 1px solid transparent;
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.sidebar-menu a:hover {
  background-color: #f0f4ff;
  color: var(--primary-color);
  border-left-color: var(--primary-color);
}

.sidebar-menu a.active {
  background-color: #e0e7ff;
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  /* font-weight: 600; */
}

/* ============================================
   FORMS & INPUTS
   ============================================ */

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.6rem;
  font-weight: 500;
  color: var(--dark-text);
  font-size: var(--font-size-sm);
}

.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: var(--font-size-sm);
  font-family: inherit;
  transition: all 0.3s ease;
  background-color: white;
}

.form-select {
  width: 100%;
  padding: 0.8rem 2.5rem 0.8rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: var(--font-size-sm);
  font-family: inherit;
  transition: all 0.3s ease;
  background-color: white;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231f2937%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem top 50%;
  background-size: 0.65rem auto;
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background-color: white;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--danger-color);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.invalid-feedback {
  color: var(--danger-color);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.form-row {
  display: grid;
  gap: 1.5rem;
}

.form-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Password Toggle Button */
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 18px;
  color: var(--gray-text);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: var(--primary-color);
  transform: translateY(-50%) scale(1.1);
}

.toggle-icon {
  display: inline-block;
  line-height: 1;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background-color: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-success {
  background-color: var(--success-color);
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-warning {
  background-color: var(--warning-color);
  color: white;
}

.btn-warning:hover {
  background-color: #d97706;
}

.btn-info {
  background-color: var(--info-color);
  color: white;
}

.btn-info:hover {
  background-color: #0891b2;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* ============================================
   CARDS & PANELS
   ============================================ */

.card {
  background-color: white;
  border: none;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 1.2rem;
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  background-color: var(--very-light-bg);
  padding: 1.2rem;
  border-bottom: 1px solid var(--light-border);
  font-weight: 600;
  color: var(--dark-text);
  font-size: 1rem;
}

.card-header h3 {
  margin: 0;
  font-size: 1rem;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  background-color: var(--very-light-bg);
  padding: 0.8rem 1.5rem;
  border-top: 1px solid var(--light-border);
}

/* ============================================
   TABLES
   ============================================ */

.table {
  width: 100%;
  border-collapse: collapse;
  background-color: white;
}

.table thead {
  background: linear-gradient(135deg, var(--primary-color), #7c3aed);
  color: white;
}

.table th {
  padding: 1.2rem;
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.table td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--light-border);
}

.table tbody tr {
  transition: background-color 0.2s ease;
}

.table tbody tr:hover {
  background-color: #f8faff;
}

.table-striped tbody tr:nth-child(odd) {
  background-color: var(--very-light-bg);
}

/* ============================================
   ALERTS & MESSAGES
   ============================================ */

.alert {
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  border-left: 4px solid;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background-color: #f0fdf4;
  color: #166534;
  border-color: var(--success-color);
}

.alert-danger {
  background-color: #fef2f2;
  color: #991b1b;
  border-color: var(--danger-color);
}

.alert-warning {
  background-color: #fffbeb;
  color: #92400e;
  border-color: var(--warning-color);
}

.alert-info {
  background-color: #f0f9ff;
  color: #0c4a6e;
  border-color: var(--info-color);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
}

.modal.show {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 90px; /* 70px navbar + 20px extra breathing room */
  padding-bottom: 20px;
}

.modal-content {
  background-color: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  max-width: 500px;
  width: 90%;
  max-height: calc(100vh - 110px); /* Kurangi tinggi navbar + padding */
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
  /* Sembunyikan scrollbar tapi tetap bisa scroll */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE / Edge */
}

.modal-content::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--light-border);

  /* Sticky properties */
  position: sticky;
  top: -2.5rem;
  background-color: white;
  z-index: 10;

  /* Compensate for modal-content padding */
  margin: -2.5rem -2.5rem 1.5rem -2.5rem;
  padding: 2.5rem 2.5rem 1rem 2.5rem;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--dark-text);
}

.close {
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--gray-text);
  transition: color 0.3s ease;
}

.close:hover {
  color: var(--dark-text);
}

.modal-body {
  margin-bottom: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  border-top: 1px solid var(--light-border);
  padding-top: 1.5rem;
}

/* ============================================
   SCHEDULE TABLE
   ============================================ */

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background-color: white;
  margin-top: 1rem;
  /* Kunci layout tabel agar tidak melar secara horizontal */
  table-layout: fixed;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--light-border);
  padding: 0.5rem;
  text-align: center;
  font-size: var(--font-size-sm);
  vertical-align: middle;

  /* Kunci tinggi sel agar tidak membengkak ke bawah */
  height: 60px;
  max-height: 60px;

  /* Mencegah isi berlebih merusak ukuran sel */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.schedule-table th {
  background: linear-gradient(135deg, var(--primary-color), #7c3aed);
  color: white;
  font-weight: 600;
  height: 45px; /* Tinggi khusus untuk header */
}

.schedule-table tbody tr:nth-child(odd) {
  background-color: var(--very-light-bg);
}

.schedule-table .time-cell {
  background-color: #f0f4ff;
  font-weight: 600;
  color: var(--primary-color);
  width: 150px; /* Lebar tetap untuk kolom jam */
}

.schedule-cell {
  height: 60px;
  max-height: 60px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  vertical-align: middle;
  overflow: hidden;
}

.schedule-cell:hover {
  background-color: #e0e7ff;
}

.schedule-cell.occupied {
  font-weight: 500;
}

/* Matkul: ungu */
.schedule-cell.occupied.matkul {
  background: linear-gradient(
    135deg,
    rgba(109, 40, 217, 0.12),
    rgba(109, 40, 217, 0.06)
  );
  color: #5b21b6;
  border-left: 3px solid #7c3aed;
}

.schedule-cell.occupied.matkul:hover {
  background-color: rgba(109, 40, 217, 0.18);
}

/* Pengajuan: hijau */
.schedule-cell.occupied.pengajuan {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.15),
    rgba(16, 185, 129, 0.08)
  );
  color: var(--success-color);
  border-left: 3px solid var(--success-color);
}

.schedule-cell.occupied.pengajuan:hover {
  background-color: rgba(16, 185, 129, 0.2);
}

/* Fallback jika ada multi-item campuran */
.schedule-cell.occupied:not(.matkul):not(.pengajuan) {
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.12),
    rgba(99, 102, 241, 0.06)
  );
  color: #4338ca;
  border-left: 3px solid #6366f1;
}

.schedule-cell.null {
  color: var(--gray-text);
  font-style: italic;
}

.schedule-cell-content {
  padding: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   PC SELECTOR
   ============================================ */

.pc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.pc-item {
  padding: 1.2rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: white;
  font-size: var(--font-size-sm);
}

.pc-item:hover {
  border-color: var(--primary-color);
  background-color: #f0f4ff;
  transform: translateY(-2px);
}

.pc-item.selected {
  background: linear-gradient(135deg, var(--primary-color), #7c3aed);
  color: white;
  border-color: var(--primary-dark);
  font-weight: 600;
}

.pc-item.disabled {
  background-color: #f5f5f5;
  color: var(--gray-text);
  cursor: not-allowed;
  border-color: var(--light-border);
  opacity: 0.6;
}

.pc-label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.3rem;
}

.pc-status {
  font-size: var(--font-size-sm);
  opacity: 0.8;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-primary {
  background-color: #e0e7ff;
  color: var(--primary-color);
}

.badge-success {
  background-color: #dcfce7;
  color: #166534;
}

.badge-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-info {
  background-color: #cffafe;
  color: #164e63;
}

/* ============================================
   UTILITIES
   ============================================ */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--gray-text);
}

.text-success {
  color: var(--success-color);
}

.text-danger {
  color: var(--danger-color);
}

.text-warning {
  color: var(--warning-color);
}

.text-info {
  color: var(--info-color);
}

.mt {
  margin-top: 1rem;
}

.mt-2 {
  margin-top: 2rem;
}

.mb {
  margin-bottom: 1rem;
}

.mb-2 {
  margin-bottom: 2rem;
}

.p {
  padding: 1rem;
}

.p-2 {
  padding: 2rem;
}

.d-none {
  display: none;
}

.d-block {
  display: block;
}

.d-flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-gap {
  gap: 1rem;
}

/* ============================================
   HAMBURGER BUTTON
   ============================================ */

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  padding: 4px;
  transition: background 0.2s ease;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Sidebar overlay (backdrop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.sidebar-overlay.active {
  display: block;
}

/* ============================================
   DESKTOP OVERRIDE (> 768px) - ensure layout is not broken by mobile CSS
   ============================================ */

@media (min-width: 769px) {
  .hamburger-btn {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100%;
    min-height: 100vh;
    align-self: stretch;
    width: 250px;
    transform: none !important;
    flex-shrink: 0;
  }

  .main-wrapper {
    flex-direction: row;
  }

  .main-content {
    width: auto;
    max-width: none;
    padding: 20px;
    padding-top: 30px;
  }
}

/* ============================================
   RESPONSIVE - MEDIUM DEVICES (481px - 768px)
   ============================================ */

@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --font-size-lg: 1.3rem;
    --font-size-md: 1.1rem;
  }

  .hamburger-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 999;
    padding-top: 70px;
  }

  .sidebar.active {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  }

  /* Key fix: make main wrapper and content full width since sidebar is now fixed/overlay */
  .main-wrapper {
    flex-direction: column;
  }

  .main-content {
    width: 100vw;
    max-width: 100%;
    min-width: 0;
    padding: 1.2rem;
  }

  .container,
  .container-fluid {
    padding: 1rem;
    max-width: 100%;
  }

  /* Navbar: truncate brand text if too long */
  .navbar-brand {
    font-size: 0.8rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55vw;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .schedule-table {
    min-width: 600px;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 0.7rem 0.4rem;
    font-size: 0.72rem;
  }

  .table th,
  .table td {
    padding: 0.7rem 0.5rem;
    font-size: 0.72rem;
  }

  .btn {
    font-size: 0.72rem;
    padding: 0.5rem 0.9rem;
  }

  .pc-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.7rem;
  }

  .modal-content {
    padding: 1.5rem;
    width: 95%;
    max-width: 100%;
  }

  .card-body {
    padding: 1.3rem;
  }

  .flex-between {
    flex-wrap: wrap;
    gap: 0.8rem;
  }
}

/* ============================================
   RESPONSIVE - SMALL DEVICES (< 480px)
   ============================================ */

@media (max-width: 480px) {
  :root {
    --font-size-lg: 1.2rem;
    --font-size-md: 1rem;
    --font-size-sm: 0.75rem;
  }

  .hamburger-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 999;
    padding-top: 70px;
  }

  .sidebar.active {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
  }

  /* Key fix: sidebar is now fixed overlay, not in flex flow */
  .main-wrapper {
    flex-direction: column;
  }

  .main-content {
    width: 100vw;
    max-width: 100%;
    min-width: 0;
    padding: 1rem 0.8rem;
  }

  .container,
  .container-fluid {
    padding: 0.8rem;
    max-width: 100%;
  }

  /* Truncate long navbar title */
  .navbar-brand {
    font-size: 0.72rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50vw;
  }

  .profile-btn {
    width: 36px;
    height: 36px;
    font-size: 0.65rem;
  }

  .profile-dropdown-menu {
    min-width: 240px;
    right: 0;
  }

  h1 {
    font-size: 1.3rem;
  }

  h2 {
    font-size: 1.1rem;
  }

  h3 {
    font-size: 0.9rem;
  }

  /* Stats grid: 2 kolom di mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-card .stat-icon {
    font-size: 1.1rem;
  }

  .stat-card .stat-number {
    font-size: 1.4rem;
  }

  .stat-card .stat-label {
    font-size: 0.7rem;
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.8rem;
  }

  .menu-item {
    padding: 1rem;
  }

  .menu-item .menu-icon {
    font-size: 1.4rem;
  }

  .menu-item .menu-title {
    font-size: 0.8rem;
  }

  .menu-item .menu-desc {
    font-size: 0.65rem;
  }

  /* Login card */
  .login-card {
    padding: 2rem 1.5rem;
  }

  /* Scrollable table wrapper */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.4rem;
    font-size: 0.7rem;
  }

  /* Tabel jadwal horizontal scroll */
  .schedule-table {
    min-width: 520px;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 0.4rem 0.3rem;
    font-size: 0.65rem;
  }

  .time-cell strong {
    font-size: 0.6rem;
  }

  .badge {
    padding: 0.2rem 0.4rem;
    font-size: 0.65rem;
  }

  .btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.72rem;
  }

  .btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.68rem;
  }

  .btn-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group .btn {
    width: 100%;
  }

  /* Modal full-width on mobile */
  .modal.show {
    padding-top: 75px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .modal-content {
    padding: 1.2rem;
    width: 100%;
    max-height: calc(100vh - 90px);
  }

  .modal-header {
    top: -1.2rem;
    margin: -1.2rem -1.2rem 1rem -1.2rem;
    padding: 1.2rem 1.2rem 0.8rem 1.2rem;
  }

  .modal-title {
    font-size: 1rem;
  }

  .card-body {
    padding: 1rem;
  }

  .pc-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.5rem;
  }

  .form-row.cols-2,
  .form-row.cols-3 {
    grid-template-columns: 1fr;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  /* Flex layouts wrap on mobile */
  .flex-between {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  /* Card header with button: stack vertically */
  .card-header > div[style*="flex"] {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
  padding: 2rem;
}

.login-card {
  background-color: white;
  padding: 3.5rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  letter-spacing: -0.5px;
}

.login-subtitle {
  text-align: center;
  color: var(--gray-text);
  margin-bottom: 2.5rem;
  font-size: var(--font-size-sm);
  font-weight: 400;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .navbar,
  .sidebar,
  .btn-group,
  .no-print {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid #000;
  }

  body {
    background-color: white;
  }
}
