/* ================================================================
   Softwave ERP – Main Stylesheet
   Modern light theme, responsive, mobile-first
================================================================ */

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

/* ── CSS Variables ── */
:root {
  --primary:       #343380;
  --primary-dark:  #242360;
  --primary-light: #F0F0FF;
  --secondary:     #6366F1;
  --accent:        #8B5CF6;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;
  --orange:        #F97316;

  --bg:        #FFFFFF;
  --bg-card:   #FFFFFF;
  --bg-hover:  #F8FAFC;
  --border:    #EDF2F7;
  --border-2:  #E2E8F0;

  --text-primary:   #1E293B;
  --text-secondary: #64748B;
  --text-muted:     #94A3B8;

  --sidebar-bg:    #343380;
  --sidebar-text:  rgba(255, 255, 255, 0.7);
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-active:#FFFFFF;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow:    0 4px 20px rgba(0,0,0,0.05);
  --shadow-md: 0 12px 30px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.08);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 28px;

  --sidebar-width: 280px;
  --topbar-height: 72px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
ul { list-style: none; }
input, select, textarea, button { font-family: inherit; }

/* ── Layout ── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid var(--border);
  transition: var(--transition);
  overflow: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 24px 20px;
}
.logo-icon {
  width: 44px; height: 44px;
  background: #fff;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.logo-text { color: #fff; font-weight: 800; font-size: 1.15rem; line-height: 1.1; letter-spacing: -0.02em; }
.logo-sub  { font-size: 0.72rem; color: rgba(255, 255, 255, 0.6); font-weight: 500; margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-section-label {
  padding: 18px 24px 8px;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  margin: 4px 12px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.nav-icon { width: 20px; height: 20px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 14px 20px;
}
.user-info-sidebar {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar-sidebar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}
.user-name-sidebar { font-size: 0.85rem; color: #fff; font-weight: 600; }
.user-role-sidebar  { font-size: 0.7rem; color: var(--sidebar-text); }

/* Close button (mobile) */
.sidebar-close {
  display: none;
  position: absolute;
  top: 14px; right: 14px;
  background: none; border: none;
  color: var(--sidebar-text);
  font-size: 1.3rem;
  cursor: pointer;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  transition: var(--transition);
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky; top: 0;
  z-index: 90;
}
.topbar-left {
  display: flex; align-items: center; gap: 16px;
}
.menu-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.1); border: none;
  cursor: pointer;
  color: #fff;
  padding: 10px;
  border-radius: 12px;
  transition: var(--transition);
}
.menu-toggle:hover { background: rgba(255, 255, 255, 0.2); }
.topbar-title { font-size: 1.1rem; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user  { display: flex; align-items: center; gap: 10px; }
.user-avatar  {
  width: 40px; height: 40px;
  background: #fff;
  color: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.user-name-top { font-size: 0.9rem; font-weight: 700; color: #fff; }
.user-role-top { font-size: 0.72rem; color: rgba(255, 255, 255, 0.7); font-weight: 500; }

/* ── Page Content ── */
.page-content { padding: 28px; flex: 1; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.page-title   { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.page-subtitle{ font-size: 0.85rem; color: var(--text-secondary); font-weight: 400; margin-top: 2px; }

/* ── Stats Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: var(--card-icon-bg, var(--primary-light));
}
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.65rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; margin-top: 3px; }
.stat-change { font-size: 0.72rem; margin-top: 4px; font-weight: 500; color: var(--success); }

/* Color variants for stat cards */
.stat-card.primary   { --card-accent: var(--primary);   --card-icon-bg: #EEF2FF; }
.stat-card.success   { --card-accent: var(--success);   --card-icon-bg: #ECFDF5; }
.stat-card.warning   { --card-accent: var(--warning);   --card-icon-bg: #FFFBEB; }
.stat-card.danger    { --card-accent: var(--danger);    --card-icon-bg: #FEF2F2; }
.stat-card.info      { --card-accent: var(--info);      --card-icon-bg: #EFF6FF; }
.stat-card.secondary { --card-accent: var(--secondary); --card-icon-bg: #ECFEFF; }
.stat-card.accent    { --card-accent: var(--accent);    --card-icon-bg: #F5F3FF; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.01em; }
.card-body  { padding: 24px; }

/* ── Table ── */
.table-container { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.865rem;
}
.table th {
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Statuses ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-present  { background: #ECFDF5; color: #059669; }
.badge-late     { background: #FFF7ED; color: #EA580C; }
.badge-absent   { background: #FEF2F2; color: #DC2626; }
.badge-leave    { background: #EFF6FF; color: #2563EB; }
.badge-holiday  { background: #F5F3FF; color: #7C3AED; }
.badge-active   { background: #ECFDF5; color: #059669; }
.badge-inactive { background: #FEF2F2; color: #DC2626; }
.badge-admin    { background: #EEF2FF; color: #4338CA; }
.badge-employee { background: #ECFEFF; color: #0891B2; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.865rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary   { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,0.3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-warning   { background: var(--warning); color: #fff; box-shadow: 0 2px 8px rgba(245,158,11,0.3); }
.btn-danger    { background: var(--danger); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.btn-info      { background: var(--info); color: #fff; }
.btn-secondary { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm        { padding: 5px 11px; font-size: 0.78rem; }
.btn-icon      { padding: 7px; width: 32px; height: 32px; justify-content: center; }
.btn-lg        { padding: 12px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn-full      { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group    { margin-bottom: 18px; }
.form-label    { display: block; font-size: 0.83rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}
.form-control:focus   { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(52, 51, 128, 0.08); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control   { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-text   { font-size: 0.75rem; color: var(--text-secondary); margin-top: 6px; }
.form-row    { display: grid; gap: 20px; }
.form-row-2  { grid-template-columns: 1fr 1fr; }
.form-row-3  { grid-template-columns: repeat(3, 1fr); }
.form-row-4  { grid-template-columns: repeat(4, 1fr); }
.input-group { position: relative; }
.input-icon  { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.1rem; }
.input-group .form-control { padding-left: 44px; }
.input-group-right .form-control { padding-right: 52px; }
.input-group-right .input-suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.85rem; }

/* ── Alerts / Flash ── */
.flash-message {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.flash-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }
.flash-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.flash-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FCD34D; }

/* ── Filter Tabs ── */
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tab {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
}
.topbar-icon-btn {
  width: 36px; height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-size: 1.05rem;
}
.topbar-icon-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.filter-tab:hover  { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Charts ── */
.chart-wrapper { position: relative; }
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Auth Pages ── */
.auth-page {
  min-height: 100vh;
  background: radial-gradient(circle at top right, var(--primary-light), #fff, var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(52, 51, 128, 0.05) 0%, transparent 70%);
  top: -150px; right: -150px;
}
.auth-page::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.03) 0%, transparent 70%);
  bottom: -100px; left: -100px;
}
.auth-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 48px 44px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn { from { opacity:0; transform: scale(0.92) translateY(20px); } to { opacity:1; transform: scale(1) translateY(0); } }
.auth-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
  justify-content: center;
}
.auth-logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 15px rgba(79,70,229,0.4);
}
.auth-title    { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); text-align: center; }
.auth-subtitle { font-size: 0.875rem; color: var(--text-secondary); text-align: center; margin-top: 4px; margin-bottom: 28px; }
.auth-divider  { text-align: center; color: var(--text-muted); font-size: 0.8rem; margin: 16px 0; position: relative; }
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%; width: 40%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* ── Misc ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 0.95rem; font-weight: 500; }

.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.72rem;
}

.text-right    { text-align: right; }
.text-center   { text-align: center; }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-muted    { color: var(--text-muted); }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.justify-between { justify-content: space-between; }

/* ── Overlay (mobile sidebar) ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.overlay.show { display: block; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }

  .sidebar {
    left: calc(-1 * var(--sidebar-width));
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 30px rgba(0,0,0,0.2);
  }
  .sidebar-close { display: block; }

  .main-content {
    margin-left: 0;
    width: 100%;
  }
  .menu-toggle { display: flex; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.35rem; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-tabs { gap: 4px; }
  .filter-tab { padding: 5px 10px; font-size: 0.75rem; }
}

/* ── Attendance status row highlighting ── */
tr.row-late  td { border-left: 3px solid var(--orange); }
tr.row-absent td { border-left: 3px solid var(--danger); }
tr.row-leave td { border-left: 3px solid var(--info); }
tr.row-holiday td { border-left: 3px solid var(--accent); }

/* ── Progress bar ── */
.progress { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.6s ease; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
