/* ==========================================================================
   Timenia Workforce OS - Modern SaaS Design System & Mobile App UI
   ========================================================================== */

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

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Primary & Accents */
  --primary: #4f46e5;
  --primary-rgb: 79, 70, 229;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --accent: #06b6d4;
  --accent-rgb: 6, 182, 212;

  --secondary: #475569;
  --secondary-light: #f1f5f9;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #0ea5e9;
  --info-light: #f0f9ff;

  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #0b101d;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 4px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 12px -2px rgba(15, 23, 42, 0.08), 0 3px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.1), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 30px -6px rgba(15, 23, 42, 0.12), 0 8px 12px -4px rgba(15, 23, 42, 0.06);

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  --sidebar-width: 260px;
  --topbar-height: 70px;
  --mobile-bottom-nav-height: 68px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  font-size: 0.935rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  overflow-y: auto;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.app-sidebar .sidebar-brand {
  padding: 1.5rem 1.25rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.sidebar-nav {
  list-style: none;
  padding: 1rem 0.75rem;
  margin: 0;
  flex-grow: 1;
}

.nav-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: #64748b;
  padding: 1.15rem 0.75rem 0.4rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.18s ease;
  margin-bottom: 3px;
  min-height: 44px;
}

.sidebar-link i {
  font-size: 1.2rem;
  width: 22px;
  text-align: center;
}

.sidebar-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.07);
  transform: translateX(2px);
}

.sidebar-link.active {
  color: #fff;
  background: linear-gradient(90deg, #4f46e5, #4338ca);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  font-weight: 600;
}

.app-main {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Top Navigation
   -------------------------------------------------------------------------- */
.app-topbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  backdrop-filter: blur(12px);
}

.topbar-search {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.topbar-search input {
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 0.5rem 1rem 0.5rem 2.4rem;
  font-size: 0.875rem;
  width: 100%;
  transition: all 0.2s;
  min-height: 42px;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background-color: #fff;
}

.topbar-search i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 38px;
  transition: all 0.2s ease;
}

.timer-pill.running {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.app-content {
  padding: 1.75rem;
  flex-grow: 1;
}

/* --------------------------------------------------------------------------
   Cards & Widgets
   -------------------------------------------------------------------------- */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 1.5rem;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.15rem 1.35rem;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 1.35rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.35rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info    { background: var(--info-light); color: var(--info); }
.stat-icon.danger  { background: var(--danger-light); color: var(--danger); }

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Tables & Density Controls
   -------------------------------------------------------------------------- */
.table-responsive {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.table {
  margin-bottom: 0;
  color: var(--text-main);
  vertical-align: middle;
}

.table thead th {
  background-color: #f8fafc;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.9rem 1rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.895rem;
}

/* Density Classes */
.table-compact thead th { padding: 0.6rem 0.8rem; font-size: 0.725rem; }
.table-compact tbody td { padding: 0.6rem 0.8rem; font-size: 0.825rem; }

.table-comfortable thead th { padding: 1.1rem 1.25rem; }
.table-comfortable tbody td { padding: 1.1rem 1.25rem; }

.table tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.025);
}

/* --------------------------------------------------------------------------
   Buttons & Badges
   -------------------------------------------------------------------------- */
.btn {
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 0.55rem 1.15rem;
  font-size: 0.885rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.16s ease-in-out;
  min-height: 40px;
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.badge {
  font-weight: 700;
  padding: 0.4em 0.75em;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.badge-draft     { background: #f1f5f9; color: #475569; }
.badge-submitted { background: #e0f2fe; color: #0369a1; }
.badge-approved  { background: #dcfce7; color: #15803d; }
.badge-rejected  { background: #fee2e2; color: #b91c1c; }
.badge-locked    { background: #f3f4f6; color: #374151; }

/* --------------------------------------------------------------------------
   Mobile App Ergonomics & Bottom Navigation
   -------------------------------------------------------------------------- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  height: var(--mobile-bottom-nav-height);
  z-index: 1030;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  gap: 3px;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  position: relative;
}

.mobile-nav-item i {
  font-size: 1.35rem;
  transition: transform 0.2s ease;
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-item.active i {
  transform: translateY(-2px);
}

.mobile-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  width: 18px;
  height: 3px;
  background-color: var(--primary);
  border-radius: 9999px;
}

/* Floating Action Button for Mobile */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: calc(var(--mobile-bottom-nav-height) + 16px);
  right: 18px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  border: none;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
  z-index: 1025;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.2s ease;
}

.mobile-fab:active {
  transform: scale(0.92);
}

/* Mobile Adaptive Table Cards */
@media (max-width: 767.98px) {
  .table-mobile-cards thead {
    display: none;
  }
  .table-mobile-cards tbody tr {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.85rem;
    padding: 0.85rem;
    box-shadow: var(--shadow-xs);
  }
  .table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
  }
  .table-mobile-cards tbody td:last-child {
    border-bottom: none;
    padding-top: 0.75rem;
    justify-content: flex-end;
  }
  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-right: 0.5rem;
  }
}

/* Responsive Offcanvas Sidebar Breakpoint */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
    padding-bottom: calc(var(--mobile-bottom-nav-height) + 1rem);
  }
  .app-content {
    padding: 1rem;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .mobile-fab {
    display: flex;
  }
}
