/* SIABSEN PPLG SMKN 1 MAJA - DESIGN SYSTEM */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-dark: #312e81;
  --secondary: #64748b;
  --accent-cyan: #06b6d4;
  
  --success: #10b981;
  --success-light: #d1fae5;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 10px 25px -5px rgba(79, 70, 229, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Layout Grid */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Styling */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  transition: var(--transition);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.8);
}

.sidebar-logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.35rem;
  box-shadow: var(--shadow-glow);
}

.sidebar-brand h2 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
  display: block;
}

.sidebar-menu {
  padding: 1.25rem 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.menu-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  margin: 1.25rem 0.75rem 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-bottom: 0.25rem;
}

.nav-link i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  transition: var(--transition);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  transform: translateX(4px);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.nav-link.active i {
  color: #ffffff;
}

/* User Card in Sidebar */
.sidebar-user {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-info .name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .role-tag {
  font-size: 0.725rem;
  color: #94a3b8;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* Top Header Bar */
.topbar {
  height: 70px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(8px);
}

.mobile-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
  padding: 0.5rem;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-title h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.date-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-logout {
  background: var(--danger-light);
  color: var(--danger);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-logout:hover {
  background: var(--danger);
  color: white;
}

/* Main Page Body */
.page-content {
  padding: 2rem;
  flex: 1;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.info::before { background: var(--info); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-details h3 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-details p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.25rem;
}

/* Card & Content Panels */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  overflow: hidden;
}

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

.card-header h2, .card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-body {
  padding: 1.5rem;
}

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

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

.custom-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.custom-table tbody tr {
  transition: var(--transition);
}

.custom-table tbody tr:hover {
  background: #f8fafc;
}

/* Matrix Table for Monthly Recap */
.matrix-table {
  border-collapse: collapse;
  font-size: 0.8rem;
  width: 100%;
}

.matrix-table th, .matrix-table td {
  border: 1px solid #cbd5e1;
  text-align: center;
  padding: 0.4rem 0.3rem;
}

.matrix-table th {
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 700;
}

.matrix-table .sticky-col {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 10;
  text-align: left;
  padding-left: 0.75rem;
  font-weight: 600;
  box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.matrix-table th.sticky-col {
  background: #e2e8f0;
  z-index: 11;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-admin { background: #fee2e2; color: #b91c1c; }
.badge-guru { background: #e0e7ff; color: #4338ca; }
.badge-kepsek { background: #fef3c7; color: #b45309; }
.badge-seksi { background: #d1fae5; color: #047857; }

/* Status Badges Absensi */
.badge-status-H { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.badge-status-S { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }
.badge-status-I { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.badge-status-A { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.badge-status-T { background: var(--purple-light); color: #5b21b6; border: 1px solid #ddd6fe; }
.badge-status-TS { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* Form Controls & Buttons */
.form-group {
  margin-bottom: 1.25rem;
}

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

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  transition: var(--transition);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-glow); }
.btn-success { background: var(--success); color: #ffffff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: #ffffff; }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-secondary { background: var(--secondary); color: #ffffff; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: #f1f5f9; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* Radio Group Absensi */
.radio-attendance-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.radio-attendance-btn {
  position: relative;
}

.radio-attendance-btn input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.radio-attendance-btn label {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.radio-attendance-btn input[value="H"]:checked + label { background: var(--success); color: white; border-color: var(--success); }
.radio-attendance-btn input[value="S"]:checked + label { background: var(--info); color: white; border-color: var(--info); }
.radio-attendance-btn input[value="I"]:checked + label { background: var(--warning); color: white; border-color: var(--warning); }
.radio-attendance-btn input[value="A"]:checked + label { background: var(--danger); color: white; border-color: var(--danger); }
.radio-attendance-btn input[value="T"]:checked + label { background: var(--purple); color: white; border-color: var(--purple); }
.radio-attendance-btn input[value="TS"]:checked + label { background: #0284c7; color: white; border-color: #0284c7; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  color: white;
  box-shadow: var(--shadow-lg);
  margin-bottom: 0.5rem;
  animation: slideIn 0.3s forwards;
}

.toast-success { background: #059669; }
.toast-danger { background: #dc2626; }

.toast button {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: auto;
}

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

/* Progress Bar Custom */
.progress-bar-container {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

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

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-glow);
}

.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.login-brand p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.demo-account-box {
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: #475569;
}

.demo-account-box strong {
  color: #1e293b;
  display: block;
  margin-bottom: 0.3rem;
}

.demo-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.demo-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: monospace;
}

.demo-pill:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Footer Styling */
.app-footer {
  padding: 1.25rem 2rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* Overlay for Mobile Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 995;
}

/* ========================================================= */
/* COMPREHENSIVE RESPONSIVE DESIGN SYSTEM                     */
/* Supports Mobile (320-576px), Tablet (577-992px), Laptop   */
/* ========================================================= */

/* Touch & Smooth Base Adjustments */
html {
  scroll-behavior: smooth;
}

body {
  -webkit-tap-highlight-color: transparent;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Ensure images and media adapt fluidly */
img, svg, canvas {
  max-width: 100%;
  height: auto;
}

/* Responsive Table Container Enhancements */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Matrix Table Sticky Column - Mobile Solid Fix */
.matrix-table .sticky-col {
  position: sticky;
  left: 0;
  background: #ffffff !important;
  z-index: 10;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
}

.matrix-table th.sticky-col {
  background: #e2e8f0 !important;
  z-index: 11;
}

/* Tablet & Smaller Devices (max-width: 992px) */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    width: 270px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: #f1f5f9;
    color: var(--text-main);
    transition: var(--transition);
  }

  .mobile-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
  }

  .topbar {
    padding: 0 1rem;
    height: 64px;
  }

  .page-content {
    padding: 1.25rem;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }

  /* Universal Grid Collapse to 1 Column */
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(240px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile & Small Tablets (max-width: 768px) */
@media (max-width: 768px) {
  .topbar {
    padding: 0 0.75rem;
    height: 60px;
  }

  .page-title h1 {
    font-size: 1.1rem;
  }

  .date-badge {
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
  }

  .page-content {
    padding: 1rem 0.75rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 0.9rem 0.85rem;
    gap: 0.75rem;
    border-radius: var(--radius-sm);
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
  }

  .stat-details h3 {
    font-size: 1.3rem;
  }

  .stat-details p {
    font-size: 0.75rem;
  }

  /* Public Portal Header Mobile Navigation */
  .public-nav {
    padding: 0.85rem 1rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.85rem !important;
  }

  .public-brand {
    width: 100%;
    justify-content: flex-start;
  }

  .public-menu {
    width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding-bottom: 0.4rem !important;
    gap: 0.85rem !important;
    display: flex !important;
    justify-content: flex-start !important;
    -webkit-overflow-scrolling: touch;
  }

  .public-menu a {
    font-size: 0.825rem !important;
    flex-shrink: 0;
  }

  .hero-section {
    padding: 2.25rem 1rem 3.5rem !important;
  }

  .hero-title {
    font-size: 1.65rem !important;
  }

  .hero-subtitle {
    font-size: 0.9rem !important;
  }

  .hero-stats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.5rem !important;
  }

  .hero-stat-item {
    padding: 0.75rem 0.4rem !important;
    min-width: 0 !important;
    text-align: center !important;
  }

  .hero-stat-item h3 {
    font-size: 1.25rem !important;
  }

  .hero-stat-item p {
    font-size: 0.7rem !important;
  }

  .public-container {
    padding: 0 0.75rem !important;
    margin-top: -1.5rem !important;
  }

  /* Form & Filter Toolbars Responsive Collapse */
  form[style*="display: flex"],
  .card-body form {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  form[style*="display: flex"] > div,
  .card-body form > div {
    width: 100% !important;
    min-width: 100% !important;
  }

  form[style*="display: flex"] button,
  form[style*="display: flex"] .btn {
    width: 100% !important;
  }

  /* Form Modal Grid in Add/Edit Pages */
  div[style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"],
  div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }

  .form-group[style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }

  /* Action Buttons Alignment in Forms & Header */
  div[style*="justify-content: flex-end"],
  div[style*="justify-content: space-between"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }

  div[style*="justify-content: flex-end"] .btn,
  div[style*="justify-content: space-between"] .btn {
    width: 100% !important;
    justify-content: center;
  }

  .card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    padding: 1rem !important;
  }

  .card-header > div {
    width: 100%;
  }

  .card-body {
    padding: 1rem !important;
  }

  /* Radio Button Group Attendance in Input Absensi */
  .radio-attendance-group {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.35rem !important;
    width: 100% !important;
  }

  .radio-attendance-btn label {
    width: 100% !important;
    text-align: center !important;
    font-size: 0.75rem !important;
    padding: 0.45rem 0.2rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Compact Table Layout for Mobile */
  .custom-table th, .custom-table td {
    padding: 0.65rem 0.5rem !important;
    font-size: 0.825rem !important;
  }

  .custom-table .btn-sm {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.75rem !important;
  }

  .toast-container {
    top: 70px;
    right: 12px;
    left: 12px;
  }
}

/* Extra Small Phones (max-width: 480px) */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .topbar-actions .date-badge {
    display: none !important;
  }

  .topbar-actions .btn-logout span {
    display: none !important;
  }

  .topbar-actions .btn-logout {
    padding: 0.45rem 0.65rem !important;
  }

  .radio-attendance-group {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .hero-stats {
    grid-template-columns: 1fr !important;
  }

  .login-card {
    padding: 1.5rem !important;
  }

  .login-brand h1 {
    font-size: 1.3rem !important;
  }

  .login-brand p {
    font-size: 0.78rem !important;
  }
}

/* Touch Device Target Optimization */
@media (pointer: coarse) {
  .btn, .form-control, .form-select, .nav-link, .radio-attendance-btn label {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
  }
}

/* Print Styles */
@media print {
  .sidebar, .topbar, .btn-print, .filter-box, .app-footer, .no-print, .sidebar-overlay, .mobile-toggle, .public-nav {
    display: none !important;
  }

  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .page-content {
    padding: 0 !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .card-panel {
    border: none !important;
    box-shadow: none !important;
  }

  .kop-surat {
    display: block !important;
    text-align: center;
    border-bottom: 3px double #000;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }
}


