/* ============================================================================
   UBISA ABSENSI — Web Frontend Styles
   Modern, clean, responsive design
   ============================================================================ */

/* --- CSS Variables --- */
:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --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 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --transition: all 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* --- Sidebar --- */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--gray-900) 0%, #1a1a2e 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-header h1 .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.sidebar-header .subtitle {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 2px;
  margin-left: 46px;
}
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--gray-300);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  transition: var(--transition);
  font-size: 0.9rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-nav a.active { background: var(--primary); color: white; }
.sidebar-nav a .nav-icon { width: 20px; text-align: center; font-size: 1.1rem; }
.sidebar-nav .nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  padding: 16px 14px 6px;
  font-weight: 600;
}
.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sidebar-footer .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}
.sidebar-footer .user-name { font-size: 0.85rem; font-weight: 500; }
.sidebar-footer .user-role { font-size: 0.7rem; color: var(--gray-400); }
.sidebar-footer .btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--gray-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}
.sidebar-footer .btn-logout:hover { background: rgba(255,255,255,0.12); color: white; }

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
  min-height: 100vh;
}
.page-header {
  margin-bottom: 24px;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.page-header p { color: var(--gray-500); font-size: 0.9rem; margin-top: 4px; }

/* --- Cards --- */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 1.1rem; font-weight: 600; }
.card-header .badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-card .stat-info { flex: 1; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--gray-500); font-weight: 500; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 2px; }
.stat-card .stat-detail { font-size: 0.78rem; color: var(--gray-400); margin-top: 2px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* --- Clock In/Out --- */
.clock-section {
  text-align: center;
  padding: 40px 20px;
}
.clock-section .date-display {
  font-size: 1.1rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.clock-section .time-display {
  font-size: 3rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.clock-section .day-display {
  font-size: 0.9rem;
  color: var(--gray-400);
  margin-bottom: 32px;
}
.clock-btn-wrap {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.clock-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  font-weight: 600;
  color: white;
}
.clock-btn .clock-btn-icon { font-size: 2.5rem; }
.clock-btn .clock-btn-label { font-size: 1.1rem; }
.clock-btn .clock-btn-time { font-size: 0.8rem; opacity: 0.8; }
.clock-btn-in { background: linear-gradient(135deg, var(--primary), #3b82f6); }
.clock-btn-in:hover { transform: scale(1.05); box-shadow: 0 8px 25px rgba(29,78,216,0.4); }
.clock-btn-out { background: linear-gradient(135deg, var(--warning), #f97316); }
.clock-btn-out:hover { transform: scale(1.05); box-shadow: 0 8px 25px rgba(245,158,11,0.4); }
.clock-btn:disabled { opacity: 0.5; transform: none !important; cursor: not-allowed; }
.clock-status {
  margin-top: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.clock-status.success { background: var(--success-light); color: var(--success); }
.clock-status.error { background: var(--danger-light); color: var(--danger); }
.clock-status.info { background: var(--primary-light); color: var(--primary); }
.clock-status.loading { background: var(--gray-100); color: var(--gray-600); }

/* --- Today's Record --- */
.today-records { margin-top: 24px; }
.record-timeline { position: relative; padding-left: 32px; }
.record-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.record-item {
  position: relative;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.record-item::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
}
.record-item.in::before { background: var(--primary); }
.record-item.out::before { background: var(--warning); }
.record-item .record-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.record-item .record-type.in { color: var(--primary); }
.record-item .record-type.out { color: var(--warning); }
.record-item .record-time { font-size: 1.1rem; font-weight: 600; margin-top: 2px; }
.record-item .record-status { font-size: 0.8rem; color: var(--gray-500); }
.record-item .record-geo { font-size: 0.75rem; color: var(--gray-400); margin-top: 4px; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}
.status-badge.ontime { background: var(--success-light); color: var(--success); }
.status-badge.late { background: var(--warning-light); color: var(--warning); }
.status-badge.present { background: var(--primary-light); color: var(--primary); }
.status-badge.absent { background: var(--danger-light); color: var(--danger); }
.status-badge.permission { background: #f3e8ff; color: #9333ea; }
.status-badge.holiday { background: var(--gray-100); color: var(--gray-500); }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: var(--transition);
  background: white;
  color: var(--gray-900);
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,0.15); }
.form-input.error { border-color: var(--danger); }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-900) 0%, #1a1a2e 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.login-card .login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-card .login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 12px;
}
.login-card .login-logo h1 { font-size: 1.4rem; font-weight: 700; }
.login-card .login-logo p { font-size: 0.85rem; color: var(--gray-500); margin-top: 4px; }
.login-card .login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}
.login-card .login-error.show { display: block; }
.login-card .btn-login {
  margin-top: 8px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: var(--transition);
}
.modal-overlay.show .modal { transform: scale(1); }
.modal h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.modal p { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* --- Loading --- */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}
.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.info { background: var(--primary); color: white; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-input { width: auto; min-width: 160px; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; }
  .sidebar.open { width: 260px; }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .clock-btn { width: 140px; height: 140px; }
  .clock-btn .clock-btn-icon { font-size: 2rem; }
  .clock-btn .clock-btn-label { font-size: 0.95rem; }
  .filter-bar .form-input { width: 100%; }
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2rem;
    margin-right: 12px;
  }
}
.mobile-menu-btn { display: none; }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p { font-size: 0.9rem; }

/* --- SSO Login Button --- */
.btn-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: var(--gray-900);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}
.btn-sso:hover { background: #2d2d44; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--gray-400);
  font-size: 0.8rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}