/* style.css - Desain UI Modern, Presisi & Responsif untuk Mobile & Desktop */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-hover: #15803d;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0284c7;
  --info-light: #f0f9ff;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* Auth / Login Page Layout */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: #f1f5f9;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-lg);
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  flex: 1;
}

.container-wide {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  flex: 1;
}

/* Top Navbar */
.navbar {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

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

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Dashboard Banner */
.dashboard-banner {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
}

.dashboard-banner-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-clock {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.1;
}

.schedule-pill {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Attendance Action Cards */
.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 140px;
}

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

.action-card:active {
  transform: scale(0.98);
}

.action-card.disabled {
  opacity: 0.7;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.action-card.disabled:hover {
  transform: none;
  box-shadow: none;
}

.action-card.disabled:active {
  transform: none;
}

.action-card-masuk {
  background: var(--success-light);
  border-color: #86efac;
}
.action-card-masuk:hover { border-color: var(--success); }

.action-card-pulang {
  background: var(--warning-light);
  border-color: #fde047;
}
.action-card-pulang:hover { border-color: var(--warning); }

.action-card-kunjungan {
  background: var(--info-light);
  border-color: #93c5fd;
}
.action-card-kunjungan:hover { border-color: var(--info); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  min-height: 42px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  gap: 0.45rem;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-success {
  background-color: var(--success);
  color: #fff;
}
.btn-success:hover {
  background-color: var(--success-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-warning {
  background-color: var(--warning);
  color: #fff;
}

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

.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  font-size: 0.825rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* Form Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

/* Minimum 16px font-size prevents iOS Safari automatic zoom-in */
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-main);
  background-color: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

@media (min-width: 641px) {
  .form-input, .form-textarea, .form-select {
    font-size: 0.925rem;
  }
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Stepper Wizard (Mathematical precision across all device widths) */
.stepper-container {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  position: relative;
}

.stepper-container::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 12.5%;
  right: 12.5%;
  height: 2px;
  background-color: var(--border-color);
  z-index: 1;
}

.stepper-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  text-align: center;
}

.stepper-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.stepper-dot.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.stepper-dot.completed {
  background: var(--success);
  color: #fff;
}

.stepper-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stepper-item.active .stepper-label {
  color: var(--primary);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-outline-success { border: 1px solid #16a34a; color: #16a34a; background: transparent; }

/* Camera UI */
.camera-box {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: #0f172a;
  position: relative;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.camera-box video, .camera-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-guide-overlay {
  position: absolute;
  width: min(200px, 55%);
  height: min(240px, 75%);
  border: 2px dashed rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.2);
}

/* History List */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}
.history-item:last-child {
  border-bottom: none;
}
.history-item-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
}
.history-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Chat bubble preview */
.chat-bubble {
  background-color: #dcf8c6;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  border-left: 4px solid #25d366;
  box-shadow: var(--shadow-sm);
}
.chat-bubble-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

/* Navigation Pills for Admin Sections */
.nav-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: #e2e8f0;
  padding: 0.35rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-pills::-webkit-scrollbar {
  display: none;
}

.nav-pill {
  padding: 0.6rem 1.1rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.nav-pill:hover {
  color: var(--text-main);
}

.nav-pill.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Admin Grids (Responsive on Laptop & Mobile) */
.admin-attendance-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.admin-user-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* Stat Cards */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 0.25rem;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Filter Box */
.filter-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.date-range-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

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

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

table.custom-table th {
  background: #f1f5f9;
  padding: 0.65rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

table.custom-table td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.table-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 0.5rem 0.85rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Standard Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-red-600 { color: #dc2626; }
.text-green-600 { color: #16a34a; }
.text-blue-600 { color: #2563eb; }
.text-orange-600 { color: #ea580c; }
.text-main { color: var(--text-main); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* ============================================================
   RESPONSIVE MEDIA QUERIES (Mobile, Tablet, Laptop & Desktop)
   ============================================================ */

/* Mobile Phones (up to 640px) */
@media (max-width: 640px) {
  .container, .container-wide {
    padding: 1rem 0.75rem;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .admin-attendance-grid, .admin-user-grid {
    grid-template-columns: 1fr;
  }

  .date-range-container {
    flex-direction: column;
    align-items: stretch;
  }

  .date-range-container span {
    text-align: center;
  }

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

  .dashboard-banner-header > div:last-child {
    text-align: left;
    margin-top: 0.5rem;
  }

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

  .history-item > div:last-child {
    text-align: left;
    margin-left: 56px; /* indent past thumbnail */
  }

  .stepper-label {
    font-size: 0.7rem;
  }
}

/* Tablets (641px - 992px) */
@media (min-width: 641px) and (max-width: 992px) {
  .admin-attendance-grid, .admin-user-grid {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}
