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

:root {
  /* --- Primary Brand & Neutrals --- */
  --bg-primary: #f8fafc;         /* Light, clean slate background */
  --bg-secondary: #ffffff;       /* Pure white for dashboard cards */
  --bg-tertiary: #f1f5f9;        /* Slightly darker white/slate */
  --text-main: #0f172a;          /* Dark slate for high readability */
  --text-muted: #64748b;         /* Neutral gray for captions & subtitled texts */
  
  --brand-primary: #4f46e5;      /* Royal Indigo (Buttons, primary links, active states) */
  --brand-hover: #4338ca;        /* Darker Indigo for interactive hovers */
  --brand-light: rgba(79, 70, 229, 0.1);
  
  /* --- Borders & Accents --- */
  --border-light: #e2e8f0;       /* Thin separator lines and card borders */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* --- Roles Badges --- */
  --badge-founder: #db2777;      /* Vivid Pink (Founder role marker) */
  --badge-tl: #06b6d4;           /* Cyan/Teal (Team Lead role marker) */
  --badge-intern: #f59e0b;       /* Golden Amber (Intern role marker) */

  /* --- Attendance Streak & Status (Semantic) --- */
  --color-present: #10b981;      /* Emerald Green (Present streak day, punch-in success) */
  --color-absent: #ef4444;       /* Ruby Red (Absent streak day, missed punch) */
  --color-holiday: #94a3b8;      /* Slate Gray (Sundays, holidays) */
  --color-warning: #f59e0b;      /* Pending punch-out status */
}

/* Dark Mode override */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0b0f19;       /* Deep obsidian blue */
    --bg-secondary: #111827;     /* Dark gray/blue for cards */
    --bg-tertiary: #1f2937;
    --text-main: #f8fafc;        /* High-contrast off-white */
    --text-muted: #94a3b8;       /* Subtle slate gray */
    
    --brand-primary: #6366f1;    /* Lighter violet/indigo for contrast */
    --brand-hover: #4f46e5;
    --brand-light: rgba(99, 102, 241, 0.15);
    
    --border-light: #1f2937;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Layout & Navbar --- */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-primary), #db2777);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.user-nav-info {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--bg-secondary);
}

.role-badge {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 9999px;
  color: white;
}

.role-founder { background-color: var(--badge-founder); }
.role-tl { background-color: var(--badge-tl); }
.role-intern { background-color: var(--badge-intern); }

.btn-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.btn-logout:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}

/* --- Container --- */
main.container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* --- Cards / Glassmorphism --- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-primary), #a855f7);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
}

.card-title-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* --- Typography --- */
h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

p.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1.25rem;
}

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

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background-color: var(--bg-tertiary);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--brand-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

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

.btn-danger {
  background-color: var(--color-absent);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-success {
  background-color: var(--color-present);
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-full {
  width: 100%;
}

/* --- Alert Messages --- */
.alert {
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-absent);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-present);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* --- Authentication Pages Layout --- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(circle at 10% 20%, rgba(79, 70, 229, 0.05) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(219, 39, 119, 0.05) 0%, transparent 40%),
              var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 450px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-primary), #db2777);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  margin-bottom: 0.5rem;
}

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

.auth-footer-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-footer-link a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer-link a:hover {
  text-decoration: underline;
}

/* --- Dashboard Grids --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Punch Status Display --- */
.punch-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 0;
}

.punch-status-indicator {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1.5rem;
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  position: relative;
}

.punch-status-indicator.punched-in {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
  box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.05);
}

.punch-status-indicator.punched-out {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-present);
  box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.05);
}

.punch-status-label {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.punch-status-time {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* --- Camera Modal / Video Stream --- */
.camera-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background-color: black;
  aspect-ratio: 4/3;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border-light);
}

#cameraStream {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  pointer-events: none;
  box-sizing: border-box;
}

#cameraCanvas {
  display: none;
}

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

.location-fetching-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.gps-badge {
  background-color: var(--brand-light);
  color: var(--brand-primary);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* --- Task List / Radios & Checkboxes --- */
.task-checklist {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
}

.task-item:hover {
  border-color: var(--brand-primary);
  background-color: var(--brand-light);
}

.task-item-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-top: 0.1rem;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.task-item input[type="checkbox"] {
  display: none;
}

.task-item input[type="checkbox"]:checked + .task-item-checkbox {
  background-color: var(--color-present);
  border-color: var(--color-present);
}

.task-item input[type="checkbox"]:checked + .task-item-checkbox::before {
  content: '✓';
}

.task-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

.task-item input[type="checkbox"]:checked ~ .task-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.incomplete-reason-wrapper {
  background-color: rgba(239, 68, 68, 0.05);
  border: 1px dashed rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-top: 1rem;
  display: none; /* Controlled dynamically by JS */
}

/* --- Streak Structure Calendar Grid --- */
.streak-wrapper {
  margin-top: 1rem;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.calendar-month-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.calendar-grid-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.day-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calendar-grid-dates {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

.calendar-date-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.calendar-date-cell:hover .date-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-8px);
}

/* Base states */
.date-empty {
  background-color: transparent;
  pointer-events: none;
}

.date-present {
  background-color: var(--color-present);
  color: white;
}

.date-absent {
  background-color: var(--color-absent);
  color: white;
}

.date-holiday {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px dashed var(--border-light);
}

.date-holiday-sun {
  background-color: var(--color-holiday);
  color: white;
}

.date-pending {
  background-color: var(--color-warning);
  color: white;
}

.date-future {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  opacity: 0.5;
  cursor: not-allowed;
}

.date-unpunched-past {
  background-color: var(--color-absent);
  color: white;
}

.date-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background-color: var(--text-main);
  color: var(--bg-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.date-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--text-main) transparent transparent transparent;
}

.legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

/* --- TL Dashboard Views --- */
.tl-dashboard-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
}

.tl-tab {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tl-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* Multiselect dropdown for assigning tasks */
.multi-select-interns {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  background-color: var(--bg-tertiary);
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
}

.multi-select-option:hover {
  background-color: var(--border-light);
}

/* Employee activity cards */
.employee-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.employee-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.employee-card-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.employee-card-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

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

.employee-card-body {
  padding: 1.25rem;
}

.employee-punch-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.punch-photo-container {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 0.5rem;
  background-color: #000;
  position: relative;
}

.punch-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.punch-no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.employee-card-footer {
  padding: 1rem 1.25rem;
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 450px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.show .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-close-btn {
  font-size: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

/* --- Table Styling --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin-top: 1rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th, .table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table th {
  background-color: var(--bg-tertiary);
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.table tbody tr {
  background-color: var(--bg-secondary);
}

.table tbody tr:hover {
  background-color: var(--bg-tertiary);
}

/* --- Filter layouts --- */
.filter-bar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  background-color: var(--bg-tertiary);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 180px;
}

/* --- Warnings/Counters --- */
.badge-counter {
  background-color: var(--color-absent);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  margin-left: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.reminder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 800px) {
  .reminder-grid {
    grid-template-columns: 1fr;
  }
}

.reminder-list-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  background-color: var(--bg-secondary);
}

.reminder-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.reminder-list-item:last-child {
  border-bottom: none;
}

/* --- Mobile Responsiveness Fixes --- */
@media (max-width: 640px) {
  .nav-container {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }
  
  .user-nav-info {
    width: 100%;
    justify-content: space-between;
  }

  .logo {
    font-size: 1.25rem;
    align-self: flex-start;
  }

  main.container {
    padding: 1rem;
  }
}
