/* eTimeTrackLite - Main Stylesheet */
:root {
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --secondary: #6b7280;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --orange: #ea580c;
  --purple: #7c3aed;
  --teal: #0d9488;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --nav-bg: #1e3a5f;
  --nav-text: #cbd5e1;
  --nav-active: #3b82f6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   LAYOUT
   ============================================================ */
#app { display: flex; min-height: 100vh; }

#app-nav {
  width: 220px;
  min-height: 100vh;
  background: var(--nav-bg);
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

#app-content {
  flex: 1;
  margin-left: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

/* When nav is visible push content right */
body.nav-visible #app-content { margin-left: 220px; }

#top-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  box-shadow: var(--shadow);
}

#main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav-brand {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.nav-brand .logo-text {
  color: white;
  font-size: 16px;
  font-weight: 700;
  display: block;
}

.nav-brand .logo-sub {
  color: var(--nav-text);
  font-size: 11px;
  opacity: 0.7;
}

.nav-section {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--nav-text);
  text-decoration: none;
  font-size: 13.5px;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.nav-link:hover { background: rgba(255,255,255,.07); color: white; }
.nav-link.active { background: rgba(59,130,246,.2); color: white; border-left-color: var(--nav-active); }
.nav-link .nav-icon { width: 18px; text-align: center; font-size: 15px; }

.nav-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo h2 { color: var(--primary); font-size: 22px; }
.login-logo p { color: var(--text-muted); font-size: 13px; }

.login-error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.date-badge { background: var(--primary); color: white; padding: 4px 12px; border-radius: 20px; font-size: 12px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 4px solid;
  transition: transform .15s;
}

.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-blue { border-top-color: #3b82f6; }
.stat-green { border-top-color: #10b981; }
.stat-red { border-top-color: #ef4444; }
.stat-yellow { border-top-color: #f59e0b; }
.stat-orange { border-top-color: #f97316; }
.stat-purple { border-top-color: #8b5cf6; }
.stat-teal { border-top-color: #14b8a6; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* Department bars */
.dept-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.dept-name { width: 130px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-wrap { flex: 1; background: var(--border); border-radius: 4px; height: 8px; }
.bar { background: var(--primary); height: 8px; border-radius: 4px; transition: width .3s; }
.dept-count { width: 30px; text-align: right; font-size: 12px; font-weight: 600; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
  line-height: 1;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  background: white;
  color: var(--text);
  transition: border-color .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,.1);
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
select, textarea {
  font-family: inherit;
  font-size: 13.5px;
}

.filter-bar input, .filter-bar select { width: auto; min-width: 150px; }

/* ============================================================
   TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13.5px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-secondary { background: #f3f4f6; color: #374151; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 10px;
  width: 90%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
}

@keyframes slideIn { from { transform: translateY(-20px); opacity:0; } to { transform:none; opacity:1; } }

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 8px;
  background: #1f2937;
  color: white;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
  min-width: 260px;
}

.toast-success { background: #065f46; }
.toast-error   { background: #991b1b; }
.toast-warning { background: #92400e; }
.toast-info    { background: #075985; }
.toast button  { background:none; border:none; color:white; cursor:pointer; font-size:16px; padding:0; }

@keyframes fadeIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ============================================================
   LOADING
   ============================================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 12px;
}

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

/* ============================================================
   ALERTS
   ============================================================ */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  background: white;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* ============================================================
   REPORT TITLE
   ============================================================ */
.report-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #app-nav { transform: translateX(-100%); transition: transform .2s; }
  #app-nav.open { transform: none; }
  #app-content { margin-left: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
}

/* ============================================================
   MISC
   ============================================================ */
.text-muted { color: var(--text-muted); }
a { color: var(--primary); }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
