/* ==========================================================================
   Sistem Absensi & Penilaian Gerakan Kepanduan Hizbul Wathan
   SMA Muhammadiyah 1 Palembang - PWA 100% Android & Apple iOS Compatible
   ========================================================================== */

:root {
  --primary-green: #006837;
  --primary-green-hover: #004f29;
  --accent-gold: #f5a623;
  --accent-gold-hover: #d98e16;
  --bg-dark: #0f172a;
  --bg-card: #ffffff;
  --bg-slate: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --border-color: #cbd5e1;
  --border-focus: #006837;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-family);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: #f1f5f9;
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container Layout */
#app {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #0b2e1b 0%, #051a0e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  z-index: 50;
  transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-top: max(24px, env(safe-area-inset-top));
}

.brand-logo {
  width: 48px;
  height: 48px;
  background: var(--accent-gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #004f29;
  box-shadow: 0 0 12px rgba(245, 166, 35, 0.4);
}

.brand-text h2 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.brand-text p {
  font-size: 11px;
  color: #a3e635;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-menu {
  padding: 20px 12px;
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item button {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

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

.nav-item button.active {
  background: linear-gradient(90deg, var(--primary-green) 0%, #059669 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 104, 55, 0.3);
}

.nav-item button i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #f8fafc;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

@media (min-width: 769px) {
  .main-wrapper {
    padding-bottom: 0;
  }
}

/* Topbar Header */
.topbar {
  background: #ffffff;
  padding: 14px 24px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 18px;
  color: var(--text-main);
  cursor: pointer;
}

.topbar-title h1 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-title p {
  font-size: 12px;
  color: var(--text-muted);
}

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

.officer-selector-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  padding: 6px 12px;
  border-radius: 30px;
  box-shadow: 0 2px 8px rgba(0, 104, 55, 0.08);
}

.officer-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-gold) 0%, #d98e16 100%);
  color: #004f29;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.officer-dropdown {
  padding: 5px 10px;
  border: 1px solid #86efac;
  border-radius: 20px;
  background: #ffffff;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  color: #065f46;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-group input {
  padding-right: 42px !important;
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s ease;
}

.password-toggle-btn:hover {
  color: var(--primary-green);
}

/* TikTok / Instagram Style Bottom Navigation Bar for Mobile (Apple iOS Safe-Area Notch Compliant) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 150;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.mobile-bottom-nav-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 64px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.mobile-nav-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: all 0.2s ease;
}

.mobile-nav-btn i {
  font-size: 20px;
  transition: transform 0.2s ease;
}

.mobile-nav-btn.active {
  color: #a3e635;
  font-weight: 700;
}

.mobile-nav-btn.active i {
  transform: scale(1.18);
  color: #a3e635;
}

.btn-officer-logout {
  padding: 6px 12px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.btn-officer-logout:hover {
  background: #fca5a5;
  color: #7f1d1d;
}

.admin-auth-btn {
  padding: 8px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.admin-auth-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.admin-auth-btn.logged-in {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.content-area {
  padding: 24px;
  flex: 1;
}

.card-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 14px;
  flex-wrap: wrap;
}

.card-title h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.green { background: #dcfce7; color: #15803d; }
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.amber { background: #fef3c7; color: #b45309; }
.stat-icon.purple { background: #f3e8ff; color: #7e22ce; }

.stat-info h4 {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--text-main);
  line-height: 1.1;
}

.stat-info p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  min-width: 600px;
}

.custom-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
  vertical-align: middle;
}

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

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: #f8fafc;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.form-control {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 13px;
  background: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(0, 104, 55, 0.12);
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-green-hover);
  box-shadow: 0 4px 12px rgba(0, 104, 55, 0.25);
}

.btn-accent {
  background: var(--accent-gold);
  color: #004f29;
}

.btn-accent:hover {
  background: var(--accent-gold-hover);
}

.btn-outline {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-danger {
  background: #ef4444;
  color: #ffffff;
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.upload-dropzone {
  border: 2px dashed #a7f3d0;
  background: #f0fdf4;
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-dropzone:hover {
  border-color: var(--primary-green);
  background: #ecfdf5;
}

.upload-dropzone i {
  font-size: 36px;
  color: var(--primary-green);
  margin-bottom: 10px;
}

.upload-dropzone h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.upload-dropzone p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalSlide 0.2s ease;
}

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

.modal-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.toast-container {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  max-width: 90vw;
}

@media (min-width: 769px) {
  .toast-container {
    bottom: 20px;
  }
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  border-left: 5px solid var(--primary-green);
  animation: toastIn 0.3s ease;
}

.toast.toast-error {
  border-left-color: #ef4444;
}

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

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

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

@media (max-width: 992px) {
  .topbar {
    padding: 12px 16px;
  }
  .content-area {
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }

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

  .mobile-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-actions {
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    justify-content: space-between;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .officer-selector-box {
    width: 100%;
    justify-content: space-between;
  }

  .officer-dropdown {
    flex: 1;
    max-width: 180px;
  }

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

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-group {
    width: 100%;
  }

  .filter-bar .btn {
    width: 100%;
    justify-content: center;
  }

  .card-header-flex {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-header-flex > div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .card-header-flex .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .modal-body {
    grid-template-columns: 1fr !important;
  }
}
