/* Factory Timesheet Admin Dashboard */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f1123;
  --surface: #1a1d35;
  --surface-2: #232847;
  --border: #2d3258;
  --text: #e4e6f0;
  --text-muted: #8b8fa8;
  --primary: #6c5ce7;
  --primary-hover: #7e70f0;
  --green: #00b894;
  --red: #e94560;
  --yellow: #fdcb6e;
  --blue: #0984e3;
  --orange: #ff6b35;
  --sidebar-w: 240px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ─── Login ───────────────────────────────────────── */
.login-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1123 0%, #1a1d35 100%);
}

.login-card {
  background: var(--surface);
  padding: 48px 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 4px;
  color: var(--primary);
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
}

.login-error {
  color: var(--red);
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 20px;
}

/* ─── Buttons ─────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

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

.btn-view {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ─── Layout ──────────────────────────────────────── */
#main-app {
  display: flex;
  height: 100%;
}

/* ─── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 20px;
  color: var(--primary);
}

.user-name {
  font-size: 13px;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(108, 92, 231, 0.15);
  color: var(--primary);
  border-right: 3px solid var(--primary);
  font-weight: 600;
}

.nav-icon {
  margin-right: 12px;
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  width: 100%;
  cursor: pointer;
  font-size: 14px;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ─── Content ─────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page h1 {
  font-size: 26px;
  margin-bottom: 24px;
  font-weight: 700;
}

/* ─── Stats Grid ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 4px;
}

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

.stat-green .stat-value { color: var(--green); }
.stat-red .stat-value { color: var(--red); }
.stat-yellow .stat-value { color: var(--yellow); }
.stat-blue .stat-value { color: var(--blue); }
.stat-orange .stat-value { color: var(--orange); }

/* ─── Toolbar ─────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar select, .toolbar input[type="date"] {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-range span {
  color: var(--text-muted);
}

/* ─── Data Table ──────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th {
  background: var(--surface-2);
  padding: 14px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(108, 92, 231, 0.05);
}

.data-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ─── Status Badges ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-complete { background: rgba(0,184,148,0.2); color: var(--green); }
.badge-incomplete { background: rgba(253,203,110,0.2); color: var(--yellow); }
.badge-missing { background: rgba(233,69,96,0.2); color: var(--red); }
.badge-edited { background: rgba(9,132,227,0.2); color: var(--blue); }
.badge-approved { background: rgba(0,184,148,0.2); color: var(--green); }
.badge-pending { background: rgba(253,203,110,0.2); color: var(--yellow); }
.badge-rejected { background: rgba(233,69,96,0.2); color: var(--red); }

/* ─── Cards Grid ──────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 4px;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

/* ─── Report Cards ────────────────────────────────── */
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}

.report-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.report-card h3 {
  color: var(--primary);
  margin-bottom: 8px;
}

.report-card p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Live Feed ───────────────────────────────────── */
.live-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  align-items: start;
}

.live-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  border-left: 4px solid var(--green);
}

.live-card-out {
  border-left-color: var(--red);
  opacity: 0.7;
}

.live-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.live-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.live-card-name {
  flex: 1;
  min-width: 0;
}

.live-card-name strong {
  display: block;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-emp-num {
  font-size: 12px;
  color: var(--text-muted);
}

.live-status-badge {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.live-card-details {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.live-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text-muted);
}

.live-detail-row span:last-child {
  color: var(--text);
  font-weight: 500;
}

.live-detail-total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 600;
}

.live-detail-total span {
  color: var(--text) !important;
  font-size: 14px !important;
}

/* ─── Activity Feed ───────────────────────────────── */
.activity-feed {
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-dot.clock_in { background: var(--green); }
.activity-dot.clock_out { background: var(--red); }
.activity-dot.break_start { background: var(--yellow); }
.activity-dot.break_end { background: var(--blue); }

.activity-text {
  flex: 1;
  font-size: 14px;
}

.activity-time {
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── Section ─────────────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.section h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

/* ─── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 20px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-body .form-row {
  display: flex;
  gap: 12px;
}

.modal-body .form-row .form-group {
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn-primary {
  width: auto;
}

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .sidebar-header h2, .user-name, .nav-item span:not(.nav-icon) {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 14px;
  }
  .nav-icon {
    margin-right: 0;
  }
  .content {
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
