@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0b0d;
  --bg-secondary: #13151a;
  --bg-tertiary: #1c1f26;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.15);
  --accent-blue: #3b82f6;
  --accent-red: #ef4444;
  --border-color: #2a2f3a;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;
  --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
  --bg-primary: #f3f4f6;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f9fafb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --accent-green: #059669;
  --accent-green-glow: rgba(5, 150, 105, 0.15);
  --accent-blue: #2563eb;
  --accent-red: #dc2626;
  --border-color: #d1d5db;
}

body.light-theme .auth-container {
  background: radial-gradient(circle at center, #e6f4ea 0%, #f3f4f6 70%);
}

body.light-theme .modal {
  background-color: rgba(0, 0, 0, 0.4);
}

/* Employee Dashboard Tabs */
.emp-tab-btn.active {
  background: var(--bg-primary) !important;
  color: var(--accent-green) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.emp-tab-btn:hover:not(.active) {
  color: var(--text-primary) !important;
}

body.light-theme .emp-tab-btn.active {
  background: var(--bg-primary) !important;
  color: var(--accent-green) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Segmented Control Active State */
.active-type {
  background: var(--bg-primary) !important;
  color: var(--accent-green) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.light-theme .active-type {
  background: var(--bg-primary) !important;
  color: var(--accent-green) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Auth Screens */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1b2820 0%, var(--bg-primary) 70%);
}

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2.5rem;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-green-glow);
  text-align: center;
}

.logo-header {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-green);
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
  margin-bottom: 0.5rem;
}

.logo-subheader {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  outline: none;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.form-input:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green-glow);
}

.btn {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--accent-green);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.btn:hover {
  background: #059669;
  box-shadow: 0 0 12px var(--accent-green-glow);
}

.btn-secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  margin-top: 0.5rem;
}

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

/* Sidebar */
aside.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  z-index: 100;
  /* GPU-accelerated slide — no width animation (jank) */
  transform: translateX(0);
  transition: transform var(--sidebar-transition);
  overflow: hidden;
  will-change: transform;
}

/* Collapsed: slide off-screen except for icon strip */
aside.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width) + var(--sidebar-collapsed-width)));
}

/* Hide text labels smoothly when collapsing */
aside.sidebar .nav-label,
aside.sidebar .sidebar-logo-text,
aside.sidebar .sidebar-footer .user-badge,
aside.sidebar .sidebar-footer #btn-theme-toggle,
aside.sidebar .sidebar-footer #btn-admin-logout {
  transition: opacity 0.2s ease;
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  max-width: 200px;
}

aside.sidebar.collapsed .nav-label,
aside.sidebar.collapsed .sidebar-logo-text,
aside.sidebar.collapsed .sidebar-footer .user-badge,
aside.sidebar.collapsed .sidebar-footer #btn-theme-toggle,
aside.sidebar.collapsed .sidebar-footer #btn-admin-logout {
  opacity: 0;
  max-width: 0;
  pointer-events: none;
}

aside.sidebar.collapsed .nav-item a {
  justify-content: center;
  padding: 0.75rem;
}

aside.sidebar.collapsed .sidebar-footer {
  align-items: center;
}

/* Sidebar toggle button */
#sidebar-toggle {
  position: absolute;
  top: 1.25rem;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  z-index: 200;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#sidebar-toggle:hover {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 2rem;
  padding-left: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  transition: opacity 0.2s ease, width 0.3s ease;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item a .nav-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.nav-item a .nav-label {
  transition: opacity 0.2s ease;
}

.nav-item.active a, .nav-item a:hover {
  color: var(--text-primary);
  background: rgba(16, 185, 129, 0.08);
  border-left: 3px solid var(--accent-green);
  padding-left: calc(0.9rem - 3px);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.user-badge {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
}

.user-badge .name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-badge .role {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Main Panel */
main.main-content {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  padding: 2rem;
  min-height: 100vh;
  transition: margin-left var(--sidebar-transition);
  will-change: margin-left;
}

main.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Cards & Grid Widgets */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.card-title {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.card-stat {
  font-size: 0.8rem;
  color: var(--accent-green);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--accent-green);
  opacity: 0.7;
}

/* Spreadsheet Grid View */
.grid-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.select-control {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  outline: none;
}

.grid-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: auto;
  max-height: 600px;
}

table.attendance-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: center;
}

table.attendance-grid th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.65rem 0.6rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

table.attendance-grid td {
  padding: 0.5rem 0.5rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid rgba(42, 47, 58, 0.4);
  height: 38px;
}

table.attendance-grid tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.015);
}

table.attendance-grid tbody tr:hover td {
  background: rgba(16, 185, 129, 0.04);
}

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

/* Sticky first column (date) */
table.attendance-grid th:first-child,
table.attendance-grid td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-secondary);
  z-index: 5;
  text-align: left;
  padding-left: 0.9rem;
  border-right: 2px solid var(--border-color);
  min-width: 80px;
  font-weight: 600;
}

table.attendance-grid th:first-child {
  background: var(--bg-tertiary);
  z-index: 15;
}

table.attendance-grid tbody tr:nth-child(even) td:first-child {
  background: var(--bg-secondary);
}

/* Status chip badges — only show on IN and CUTI */
.cell-status-in {
  cursor: pointer;
  background-color: rgba(16, 185, 129, 0.07) !important;
}

.cell-status-in::after {
  content: 'IN';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #10b981;
  color: #fff;
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  letter-spacing: 0.06em;
  min-width: 28px;
}

.cell-status-off {
  cursor: pointer;
  /* Empty — no dash, no carpet */
}

.cell-status-leave {
  cursor: pointer;
  background-color: rgba(59, 130, 246, 0.07) !important;
}

.cell-status-leave::after {
  content: 'CUTI';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  border: 1px solid rgba(59,130,246,0.3);
  min-width: 32px;
}

.input-cell {
  background: transparent;
  border: none;
  color: var(--text-primary);
  width: 80px;
  outline: none;
  font-family: inherit;
  text-align: center;
}

.input-cell:focus {
  background: var(--bg-tertiary);
  outline: 1px solid var(--accent-green);
  border-radius: 4px;
}

/* Employee Check-in Portal layout */
.checkin-wrapper {
  max-width: 500px;
  margin: 0 auto;
  padding: 1.5rem;
}

.camera-preview {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--border-color);
  margin-bottom: 1rem;
}

.camera-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-preview canvas {
  display: none;
}

.preview-snapshot {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
}

.location-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.location-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.status-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 0.25rem;
}

.status-ok { background-color: var(--accent-green); }
.status-error { background-color: var(--accent-red); }

/* Slips list layout */
.slips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

.slip-card {
  background: #ffffff;
  color: #000000;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid #ddd;
}

.slip-title {
  text-align: center;
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.slip-subtitle {
  text-align: center;
  margin-bottom: 1rem;
}

.slip-divider {
  border-bottom: 1px dashed #000;
  margin: 0.75rem 0;
}

.slip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.slip-row-bold {
  font-weight: bold;
}

/* Modal form style */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
}

/* Chart Styles */
.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  width: 70px;
}

.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-green) 0%, rgba(16, 185, 129, 0.2) 100%);
  border-radius: 6px 6px 0 0;
  transition: all 0.3s ease;
  min-height: 5px;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.chart-bar:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.chart-value-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
  margin-bottom: 0.25rem;
}

.chart-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  text-align: center;
  font-weight: 500;
}

/* Print CSS */
@media print {
  body {
    background: white;
    color: black;
  }
  aside.sidebar, main.main-content .grid-controls, main.main-content .page-header, .btn, .no-print {
    display: none !important;
  }
  main.main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .page {
    display: none !important;
  }
  #page-slips.active {
    display: block !important;
  }
  .slips-grid {
    display: block !important;
  }
  .slip-card {
    box-shadow: none !important;
    border: none !important;
    page-break-after: always;
    max-width: 80mm; /* standard POS receipt width */
    margin: 0 auto;
    padding: 0 !important;
  }
}

/* Responsive Mobile Style Enhancements */
@media screen and (max-width: 768px) {
  body {
    padding: 0.25rem;
  }

  .sidebar {
    position: relative;
    width: 100% !important;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  main.main-content {
    margin-left: 0 !important;
    padding: 1rem 0.5rem;
    min-height: calc(100vh - 120px);
  }

  .grid-controls {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .grid-controls select, .grid-controls button {
    width: 100% !important;
  }

  .employee-tabs-nav {
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .emp-tab-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
  }

  .camera-preview {
    border-radius: 12px;
    overflow: hidden;
    max-height: 350px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  }

  .btn, .form-input, .select-control {
    min-height: 44px;
    font-size: 0.95rem;
  }

  .attendance-type-toggle {
    margin-bottom: 1.5rem !important;
  }
}

/* Mobile hamburger toggle (shown on small screens) */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 300;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

@media screen and (max-width: 768px) {
  .mobile-toggle {
    display: flex;
  }
}

/* Light theme sticky column overrides */
body.light-theme table.attendance-grid th:first-child {
  background: #f1f5f9;
}

body.light-theme table.attendance-grid th {
  background: #f1f5f9;
  border-bottom-color: #cbd5e1;
  border-right-color: #cbd5e1;
  color: #475569;
}

body.light-theme table.attendance-grid td {
  border-bottom-color: #e2e8f0;
  border-right-color: #e2e8f0;
}

body.light-theme table.attendance-grid tbody tr:nth-child(even) td {
  background: #f8fafc;
}

body.light-theme table.attendance-grid tbody tr:nth-child(even) td:first-child {
  background: #f8fafc;
}

body.light-theme table.attendance-grid td:first-child {
  background: #ffffff;
  border-right-color: #cbd5e1;
}

body.light-theme table.attendance-grid tbody tr:hover td {
  background: rgba(16, 185, 129, 0.04);
}

body.light-theme table.attendance-grid tbody tr:hover td:first-child {
  background: rgba(16, 185, 129, 0.04);
}


/* Grid wrapper max height increase for more visible rows */
.grid-wrapper {
  max-height: calc(100vh - 220px) !important;
}


