/* ================================
   SERENE HRM - Custom Styles v3.0
   ================================ */

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #99f6e4;
  --accent: #f59e0b;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #3b82f6;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Navbar */
.navbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: .5px;
}

/* Selectors that live inside the dark navbar (company/language pickers).
   Use a subtle translucent background so they read well over the dark gradient
   in both light and dark themes. */
.navbar-select {
  background: rgba(255, 255, 255, 0.12);
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.25);
}

.navbar-select:focus {
  background: rgba(255, 255, 255, 0.18);
  color: #fff !important;
  border-color: #fff;
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.15);
}

/* The dropdown list that opens from the select uses light theme defaults,
   so option text needs to read as dark. */
.navbar-select option {
  background: #fff;
  color: #212529;
}

[data-theme="dark"] .navbar-select option {
  background: #1e293b;
  color: var(--text);
}

.nav-link {
  font-weight: 500;
  transition: color .2s;
}

/* Right-side navbar controls (search, company, language, theme, user).
   flex-shrink: 0 keeps the dark-mode button from being squeezed off-screen
   when the main nav has many items. */
.navbar-utilities {
  flex-shrink: 0;
  row-gap: 0.5rem;
}

.navbar-search {
  min-width: 180px;
  max-width: 220px;
  flex: 1 1 180px;
}

.navbar-utilities .navbar-select {
  min-width: 120px;
  max-width: 200px;
}

.navbar-utilities form:has(select[name="factory_id"]) .navbar-select {
  min-width: 160px;
  max-width: 220px;
}

.navbar-theme-btn {
  flex-shrink: 0;
  width: 2.25rem;
  padding-left: 0;
  padding-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 991.98px) {
  .navbar-utilities {
    width: 100%;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 0.5rem;
  }

  .navbar-search {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
  }

  .navbar-utilities .navbar-select,
  .navbar-utilities form:has(select[name="factory_id"]) .navbar-select {
    max-width: none;
    flex: 1 1 auto;
  }
}

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: box-shadow .2s, transform .15s;
}

.card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, .08);
}

.card-stat {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.card-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(13, 148, 136, .15);
}

.card-stat .display-6 {
  font-weight: 700;
  color: var(--primary);
}

/* Status Badges */
.badge-status {
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.badge-active,
.badge-ACTIVE {
  background: #dcfce7;
  color: #15803d;
}

.badge-inactive,
.badge-INACTIVE {
  background: #fef2f2;
  color: #dc2626;
}

.badge-OPEN {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-FULFILLED {
  background: #dcfce7;
  color: #15803d;
}

.badge-IN_PROGRESS {
  background: #fef3c7;
  color: #92400e;
}

.badge-RESIGNED {
  background: #fef2f2;
  color: #dc2626;
}

.badge-RELIEVED {
  background: #f0fdf4;
  color: #166534;
}

.badge-EXIT_INTERVIEW_DONE {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-CLEARANCE_DONE {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-NEW {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-SCREENED {
  background: #fef3c7;
  color: #92400e;
}

.badge-INTERVIEWED {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-OFFER {
  background: #fce7f3;
  color: #9d174d;
}

.badge-JOINED {
  background: #dcfce7;
  color: #15803d;
}

.badge-SELECTED {
  background: #dcfce7;
  color: #15803d;
}

.badge-REJECTED {
  background: #fef2f2;
  color: #dc2626;
}

.badge-HOLD {
  background: #fef3c7;
  color: #92400e;
}

.badge-PENDING {
  background: #e2e8f0;
  color: #475569;
}

.badge-DONE {
  background: #dcfce7;
  color: #15803d;
}

.badge-APPROVED {
  background: #dcfce7;
  color: #15803d;
}

.badge-CANCELLED {
  background: #e2e8f0;
  color: #475569;
}

/* Tables */
.table {
  border-radius: 8px;
  overflow: hidden;
}

.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  cursor: pointer;
}

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

.table tbody tr {
  transition: background .15s;
}

.table tbody tr:hover {
  background: #f0fdfa;
}

.table-responsive {
  border-radius: 8px;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

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

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

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .4;
}

/* Footer */
footer {
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* Pagination */
.pagination .page-link {
  color: var(--primary);
  border-radius: 8px;
  margin: 0 2px;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* Confirm modal */
.modal-confirm .modal-header {
  border-bottom: 2px solid var(--danger);
}

/* Loading spinner */
.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid #fff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin .6s linear infinite;
}

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

/* Quick links */
.quick-links .btn {
  border-radius: 10px;
  font-weight: 500;
}

/* Action buttons */
.btn-action {
  padding: 2px 8px;
  font-size: .8rem;
  border-radius: 6px;
}

/* Responsive */
@media (max-width: 768px) {
  .table-responsive {
    font-size: .85rem;
  }

  .card .display-6 {
    font-size: 1.5rem;
  }
}

/* ================================
   DARK MODE
   ================================ */
[data-theme="dark"] {
  --primary: #14b8a6;
  --primary-dark: #0d9488;
  --primary-light: #134e4a;
  --accent: #fbbf24;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;
  --info: #60a5fa;

  /* Re-point Bootstrap's own body/heading color variables so utilities like
     .text-body, .text-body-emphasis, and default body text are readable on
     the dark background. Without this, .text-body keeps its light-mode dark
     color and becomes near-invisible (e.g. employee names on the dashboard). */
  --bs-body-color: #e2e8f0;
  --bs-body-color-rgb: 226, 232, 240;
  --bs-emphasis-color: #f1f5f9;
  --bs-emphasis-color-rgb: 241, 245, 249;
  --bs-secondary-color: rgba(226, 232, 240, 0.75);
  --bs-heading-color: #f1f5f9;
}

/* Base text */
[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
  color: var(--text);
}

[data-theme="dark"] p,
[data-theme="dark"] label,
[data-theme="dark"] strong,
[data-theme="dark"] b,
[data-theme="dark"] small,
[data-theme="dark"] .small {
  color: var(--text);
}

[data-theme="dark"] .form-label {
  color: var(--text) !important;
}

[data-theme="dark"] .form-check-label {
  color: var(--text);
}

/* Cards */
[data-theme="dark"] .card {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .card-header {
  background: rgba(255, 255, 255, .04) !important;
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .card-body {
  color: var(--text);
}

[data-theme="dark"] .card-stat .display-6 {
  color: var(--primary);
}

/* Tables — must override Bootstrap 5 CSS variables */
[data-theme="dark"] .table {
  --bs-table-color: #e2e8f0;
  --bs-table-bg: transparent;
  --bs-table-hover-color: #e2e8f0;
  --bs-table-hover-bg: rgba(20, 184, 166, .08);
  --bs-table-striped-color: #e2e8f0;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table thead th {
  background: #1a2332 !important;
  color: #94a3b8 !important;
  border-color: var(--border) !important;
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
  border-color: var(--border) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table td strong {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table td a:not(.btn) {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table td span:not(.badge-status):not([class*="badge-"]) {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table td a.btn {
  color: var(--primary) !important;
}

[data-theme="dark"] .table tbody tr:hover {
  background: rgba(20, 184, 166, .08) !important;
}

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: #1e293b;
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background: #1e293b;
  color: var(--text);
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(20, 184, 166, .25);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted);
  opacity: .7;
}

[data-theme="dark"] input[type="date"] {
  color-scheme: dark;
}

/* Dropdowns */
[data-theme="dark"] .dropdown-menu {
  background: #1e293b;
  border-color: var(--border);
}

[data-theme="dark"] .dropdown-item {
  color: var(--text);
}

[data-theme="dark"] .dropdown-item:hover {
  background: #334155;
}

[data-theme="dark"] .dropdown-item-text {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .dropdown-divider {
  border-color: var(--border);
}

/* Modals */
[data-theme="dark"] .modal-content {
  background: var(--card-bg);
  color: var(--text);
}

[data-theme="dark"] .modal-header {
  border-color: var(--border);
}

[data-theme="dark"] .modal-footer {
  border-color: var(--border);
}

[data-theme="dark"] .btn-close {
  filter: invert(1);
}

/* Alerts */
[data-theme="dark"] .alert {
  border-color: var(--border);
}

[data-theme="dark"] .alert-success {
  background: #064e3b;
  color: #4ade80;
  border-color: #065f46;
}

[data-theme="dark"] .alert-warning {
  background: #451a03;
  color: #fbbf24;
  border-color: #78350f;
}

[data-theme="dark"] .alert-danger {
  background: #450a0a;
  color: #f87171;
  border-color: #7f1d1d;
}

/* Bootstrap utility overrides */
[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .text-dark {
  color: var(--text) !important;
}

[data-theme="dark"] .text-body,
[data-theme="dark"] .text-body-emphasis,
[data-theme="dark"] .text-black {
  color: var(--text) !important;
}

[data-theme="dark"] .text-secondary {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .bg-light {
  background: #1a2332 !important;
}

[data-theme="dark"] .bg-transparent {
  background: transparent !important;
}

[data-theme="dark"] .border {
  border-color: var(--border) !important;
}

/* Buttons */
[data-theme="dark"] .btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border);
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--border);
  color: var(--text);
}

[data-theme="dark"] .btn-outline-success {
  color: #4ade80;
  border-color: #4ade80;
}

[data-theme="dark"] .btn-outline-danger {
  color: #f87171;
  border-color: #f87171;
}

/* Footer & Pagination */
[data-theme="dark"] footer {
  border-color: var(--border);
  color: var(--text-muted);
}

[data-theme="dark"] .pagination .page-link {
  background: var(--card-bg);
  color: var(--primary);
  border-color: var(--border);
}

[data-theme="dark"] .pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

[data-theme="dark"] .empty-state {
  color: var(--text-muted);
}

/* Attendance dots */
[data-theme="dark"] .att-present {
  background: #064e3b;
  color: #4ade80;
}

[data-theme="dark"] .att-absent {
  background: #450a0a;
  color: #f87171;
}

[data-theme="dark"] .att-late {
  background: #451a03;
  color: #fbbf24;
}

[data-theme="dark"] .att-half {
  background: #172554;
  color: #60a5fa;
}

[data-theme="dark"] .att-leave {
  background: #2e1065;
  color: #a78bfa;
}

/* Org chart */
[data-theme="dark"] .org-emp {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .org-emp .emp-name {
  color: var(--text);
}

[data-theme="dark"] .org-emp .emp-meta {
  color: var(--text-muted);
}

[data-theme="dark"] .org-connector {
  background: var(--border);
}

/* List group */
[data-theme="dark"] .list-group-item {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}

/* =====================================================================
   SERENE HRM — UI Polish v3.1
   Additive layer. Pure styling refinements (no layout/HTML dependencies).
   Designed to be safe: no logo sizing, no text-color changes that could
   harm contrast, no structural overrides.
   ===================================================================== */

/* Soft depth on the page background (light theme). Dark theme keeps its
   solid background because [data-theme="dark"] body has higher specificity. */
body {
  background-image:
    radial-gradient(1100px 560px at 100% -8%, rgba(13, 148, 136, 0.06), transparent 60%),
    radial-gradient(820px 460px at -8% 108%, rgba(245, 158, 11, 0.05), transparent 55%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* ---- Navbar refinement (styling only; HTML untouched) ---- */
.navbar {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(94, 234, 212, 0.14);
}

.navbar .nav-link {
  border-radius: 8px;
  padding: 0.4rem 0.55rem !important;
  margin: 0 1px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.82) !important;
}

.navbar .nav-link i {
  margin-right: 0.35rem !important;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff !important;
}

.navbar .nav-link.show,
.navbar .nav-link[aria-expanded="true"] {
  background: rgba(20, 184, 166, 0.18);
  color: #5eead4 !important;
}

/* Keep the right-side controls compact so the lang picker, dark-mode
   toggle and user menu never overflow off-screen at desktop widths. */
.navbar-utilities {
  gap: 0.4rem !important;
}

.navbar-search {
  min-width: 130px;
  max-width: 150px;
}

.navbar-utilities .navbar-select {
  min-width: 96px;
  max-width: 112px;
}

.navbar-utilities form:has(select[name="factory_id"]) .navbar-select {
  min-width: 150px;
  max-width: 182px;
}

/* Graceful overflow handling at >=lg:
   - left nav never wraps internally (so "Reports" never drops a line)
   - the utility cluster drops to its own right-aligned second row only
     when the single row genuinely can't hold everything. */
@media (min-width: 992px) {
  .navbar-collapse {
    flex-wrap: wrap;
  }

  .navbar-nav {
    flex-wrap: nowrap;
  }

  .navbar-utilities {
    padding-top: 0;
  }
}

/* Navbar dropdown menus: softer, modern */
.navbar .dropdown-menu {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.16);
  padding: 0.4rem;
  margin-top: 0.4rem;
}

.navbar .dropdown-item {
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

/* ---- Page headings ---- */
h2,
h3 {
  letter-spacing: -0.01em;
}

/* ---- Cards ---- */
.card {
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
}

.card:hover {
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.09);
}

.card-header {
  font-weight: 600;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

/* Stat cards — subtle gradient accent bar that reveals on hover */
.card-stat {
  position: relative;
  overflow: hidden;
}

.card-stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card-stat:hover::before {
  opacity: 1;
}

.card-stat .display-6 {
  font-weight: 800;
}

/* ---- Buttons ---- */
.btn {
  border-radius: 9px;
  font-weight: 500;
}

.btn-sm {
  border-radius: 7px;
}

.btn-primary {
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.22);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.32);
}

/* ---- Forms ---- */
.form-control,
.form-select {
  border-radius: 9px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(13, 148, 136, 0.15);
}

/* ---- Tables ---- */
.table thead th {
  font-size: 0.72rem;
}

.table tbody td {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  vertical-align: middle;
}

/* ---- Badges ---- */
.badge-status {
  border-radius: 999px;
}

/* ---- Login: branded welcome card ---- */
.serene-login-head {
  text-align: center;
  margin-bottom: 1.25rem;
}

.serene-login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.18);
  margin-bottom: 0.75rem;
}

.serene-login-title {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
  margin-bottom: 0.15rem;
}

.serene-login-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Dark theme: keep cards readable with a touch more depth ---- */
[data-theme="dark"] .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .card:hover {
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}
