/* RITMAX - Main Stylesheet */

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

html { scroll-behavior: smooth; }

body.app-body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--background);
  line-height: 1.5;
  overflow-x: hidden;
}

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

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .nav-section-title,
.app-sidebar.collapsed .nav-badge,
.app-sidebar.collapsed .nav-arrow {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.app-sidebar.collapsed .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-sidebar.collapsed .submenu {
  display: none !important;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-primary);
  transition: opacity var(--transition);
  white-space: nowrap;
}

.sidebar-brand-text span {
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

.nav-section-title {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  transition: opacity var(--transition);
}

.nav-item { list-style: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-subtle);
  border-left-color: var(--primary);
  font-weight: 600;
}

.nav-link i.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.nav-label { transition: opacity var(--transition); white-space: nowrap; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  border-radius: 10px;
  font-weight: 600;
  transition: opacity var(--transition);
}

.nav-arrow {
  margin-left: auto;
  font-size: 0.625rem;
  transition: transform var(--transition), opacity var(--transition);
}

.nav-link[aria-expanded="true"] .nav-arrow { transform: rotate(90deg); }

.submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(241, 245, 249, 0.5);
}

.submenu .nav-link {
  padding-left: 3rem;
  font-size: 0.8125rem;
  border-left: none;
}

.submenu .nav-link.active {
  border-left: none;
  background: transparent;
  color: var(--primary);
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.app-sidebar.collapsed ~ .app-main,
body.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.header-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.125rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-toggle:hover {
  background: var(--background);
  color: var(--primary);
}

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--background);
  font-size: 0.875rem;
  transition: all var(--transition);
}

.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.header-search i {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.header-action-btn {
  position: relative;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 1.0625rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-action-btn:hover {
  background: var(--background);
  color: var(--primary);
}

.header-action-btn .badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.user-profile-dropdown {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.75rem 0.375rem 0.375rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: none;
}

.user-profile-dropdown:hover { background: var(--background); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.user-info { text-align: left; }
.user-info .user-name { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); display: block; line-height: 1.2; }
.user-info .user-role { font-size: 0.75rem; color: var(--text-muted); }

/* ===== Content Area ===== */
.app-content {
  flex: 1;
  padding: 1.5rem;
}

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

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
}

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

.breadcrumb-nav {
  margin-bottom: 1rem;
}

.breadcrumb-nav .breadcrumb {
  margin: 0;
  padding: 0;
  background: none;
  font-size: 0.8125rem;
}

.breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-muted); }

/* ===== Footer ===== */
.app-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ===== Cards ===== */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  height: 100%;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

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

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card-trend {
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-card-trend.up { color: var(--success); }
.stat-card-trend.down { color: var(--danger); }

.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.content-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

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

/* ===== Tables ===== */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.table-search {
  position: relative;
  max-width: 280px;
  flex: 1;
}

.table-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.table-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 81, 81, 0.1);
}

.table-search i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.data-table {
  width: 100%;
  margin: 0;
  font-size: 0.875rem;
}

.data-table thead th {
  background: var(--background);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover { color: var(--primary); }

.data-table thead th .sort-icon {
  margin-left: 0.25rem;
  opacity: 0.4;
  font-size: 0.625rem;
}

.data-table thead th.sorted .sort-icon { opacity: 1; color: var(--primary); }

.data-table tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(241, 245, 249, 0.6); }

.table-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8125rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active { background: var(--success-bg); color: #047857; }
.status-badge.inactive { background: var(--danger-bg); color: #B91C1C; }
.status-badge.pending { background: var(--warning-bg); color: #B45309; }
.status-badge.processing { background: var(--info-bg); color: var(--info); }

/* ===== Forms ===== */
.form-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
}

.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control.is-valid { border-color: var(--success); }
.form-control.is-invalid { border-color: var(--danger); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
}

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

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
}

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

.btn-light-custom {
  background: var(--background);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-light-custom:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* ===== Notification Panel ===== */
.notification-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  max-width: 100%;
  height: 100vh;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 1055;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.notification-panel.open { right: 0; }

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

.notification-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.notification-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem;
  border-radius: var(--radius);
  transition: background var(--transition);
  cursor: pointer;
}

.notification-item:hover { background: var(--background); }
.notification-item.unread { background: var(--primary-subtle); }

.notification-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.notification-icon.payroll { background: var(--primary-subtle); color: var(--primary); }
.notification-icon.attendance { background: var(--success-bg); color: var(--success); }
.notification-icon.alert { background: var(--warning-bg); color: var(--warning); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Activity Feed ===== */
.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.activity-dot.blue { background: var(--primary); }
.activity-dot.green { background: var(--success); }
.activity-dot.orange { background: var(--warning); }

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Profile Page ===== */
.profile-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 2rem;
  color: #fff;
  margin-bottom: 1.5rem;
}

.profile-avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 3px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
}

.info-list .info-item {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.info-list .info-item:last-child { border-bottom: none; }
.info-list .info-label { color: var(--text-secondary); }
.info-list .info-value { font-weight: 500; }

.document-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: border-color var(--transition);
}

.document-item:hover { border-color: var(--primary); }

.document-icon {
  width: 40px;
  height: 40px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Auth Pages ===== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
}

.auth-brand-panel {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.auth-brand-panel::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  top: -100px;
  right: -100px;
}

.auth-brand-panel::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  bottom: -50px;
  left: -50px;
}

.auth-brand-content { position: relative; z-index: 1; max-width: 420px; text-align: center; }

.auth-brand-logo {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 1.5rem;
}

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--surface);
  max-width: 560px;
}

.auth-form-container { width: 100%; max-width: 400px; }

.auth-form-container h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-form-container .auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.9375rem;
}

.input-group-icon {
  position: relative;
}

.input-group-icon i {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  z-index: 4;
}

.input-group-icon .form-control {
  padding-left: 2.5rem;
}

.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 4;
}

/* ===== Calendar / Holiday ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  cursor: default;
}

.calendar-day.today { background: var(--primary-subtle); color: var(--primary); font-weight: 700; }
.calendar-day.holiday { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.calendar-day.weekend { color: var(--text-muted); }
.calendar-day.other-month { color: var(--border-dark); }

/* ===== Permission Matrix ===== */
.permission-matrix th, .permission-matrix td {
  text-align: center;
  vertical-align: middle;
}

.permission-matrix .module-name {
  text-align: left;
  font-weight: 500;
}

/* ===== Chart Container ===== */
.chart-container {
  position: relative;
  height: 280px;
}

.chart-container-sm { height: 200px; }

/* ===== Pagination ===== */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ===== Mobile Sidebar ===== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1035;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-main { margin-left: 0 !important; }

  .sidebar-backdrop.active { display: block; }

  .header-search { display: none; }

  .user-info { display: none; }
}

@media (max-width: 575.98px) {
  .app-content { padding: 1rem; }

  .page-title { font-size: 1.25rem; }

  .stat-card-value { font-size: 1.375rem; }

  .auth-brand-panel { display: none; }

  .auth-form-panel { max-width: 100%; }
}

/* ===== Utilities ===== */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-subtle { background: var(--primary-subtle) !important; }
.border-custom { border-color: var(--border) !important; }
.gap-section { margin-bottom: 1.5rem; }
i.fas.fa-eye {
    left: 0px;
}