/* ========================================
   5P Inspection - CSS
   Mobile-first, modern clean design
   ======================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ca8a04;
  --warning-light: #fef9c3;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100vh; }
[hidden] { display: none !important; }

/* ========================================
   LOGIN
   ======================================== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 50%, #ecfdf5 100%);
}

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

.login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 50%;
  color: var(--primary);
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

#login-form { display: flex; flex-direction: column; gap: 1rem; }

.error-msg {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  background: var(--danger-light);
  border-radius: var(--radius);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease-in-out; }

/* ========================================
   INPUTS & BUTTONS
   ======================================== */
.input {
  width: 100%;
  height: 40px;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input::placeholder { color: var(--text-light); }

.input-search { padding-left: 2.5rem; }

.select-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 40px;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-outline {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }
.btn-outline:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-full { width: 100%; }
.btn-sm { height: 32px; padding: 0 0.75rem; font-size: 0.8rem; }

/* ========================================
   HEADER
   ======================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========================================
   TABS
   ======================================== */
.tab-nav {
  display: flex;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}
.tab-content.active { display: block; }

/* ========================================
   CARDS
   ======================================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ========================================
   FILTERS
   ======================================== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.filter-search {
  position: relative;
  flex: 2;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.filter-dates {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
  min-width: 200px;
}

.date-sep {
  color: var(--text-light);
  font-size: 0.875rem;
}

.filter-count {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* ========================================
   STATUS MESSAGES
   ======================================== */
.status-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.status-msg.error { color: var(--danger); }

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   TABLE
   ======================================== */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead { background: var(--bg); }

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f1f5f9; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* Photo thumbnails */
.photo-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.15s;
}
.photo-thumb:hover { transform: scale(1.05); }

.cell-detail {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cell-date {
  font-size: 0.7rem;
  color: var(--text-light);
}

.cell-content {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.cell-desc { font-size: 0.8rem; line-height: 1.4; }

.cell-sender {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.cell-empty {
  color: var(--text-light);
  font-style: italic;
  font-size: 0.8rem;
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 0.5rem;
}

.page-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.page-btns {
  display: flex;
  gap: 0.5rem;
}

/* ========================================
   ABSENSI FORM
   ======================================== */
.absensi-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

#absensi-msg {
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}

#absensi-msg.msg-success {
  background: var(--success-light);
  color: var(--success);
}

#absensi-msg.msg-error {
  background: var(--danger-light);
  color: var(--danger);
}

/* ========================================
   LIGHTBOX
   ======================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s;
  color: var(--text);
  z-index: 1001;
}
.lightbox-close:hover { opacity: 1; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========================================
   RESPONSIVE - MOBILE FIRST
   ======================================== */

/* Small screens (default) */
@media (max-width: 640px) {
  .header { padding: 0.75rem 1rem; }
  .header-title { font-size: 1.1rem; }

  .tab-btn span { display: none; }
  .tab-btn { padding: 0.75rem 1.25rem; }

  .filters { flex-direction: column; }
  .filter-search,
  .filter-dates { min-width: 0; width: 100%; flex: unset; }
  .select-input { width: 100%; }

  .card { padding: 1rem; }

  th, td { padding: 0.5rem 0.6rem; font-size: 0.8rem; }

  .photo-thumb { width: 48px; height: 48px; }

  .pagination { flex-direction: column; gap: 0.75rem; }
  .page-info { order: 1; }
  .page-btns { order: 0; width: 100%; justify-content: space-between; }

  /* Absensi table: hide timestamp on mobile */
  #absensi-table th:nth-child(5),
  #absensi-table td:nth-child(5) { display: none; }
}

/* Medium screens */
@media (min-width: 641px) {
  .header { padding: 1.25rem 1.5rem; }
  .tab-content { padding: 1.25rem 1.5rem; }
  .tab-nav { padding: 0 1.5rem; }
}

/* Large screens */
@media (min-width: 1024px) {
  .filters { flex-wrap: nowrap; }
  .filter-search { flex: 2; }
  .select-input { flex: 1; max-width: 180px; }
  .filter-dates { flex: 1.5; }
}
