/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ── Design tokens ───────────────────────────────────── */
:root {
  --navy:       #0f1f4b;
  --navy-deep:  #0a1838;
  --navy-hover: #162954;
  --red:        #e63329;
  --red-hover:  #cc2e25;
  --bg:         #f4f6fb;
  --border:     #e2e6ef;
  --text:       #1a2a4a;
  --muted:      #8492a6;
  --light-blue: #DCE6F1;
  --redv:       #C0504D;
  --light-red:  #F2DCDB;
}

.redv {
  background-color: var(--redv);
  color: white;
}
.light-red {
  background-color: var(--light-red);
}
.light-blue {
  background-color: var(--light-blue);
}

* { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); margin: 0; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--navy-deep);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-logo {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
}

.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-name {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  transition: background 0.2s;
}

.sidebar-nav:hover::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.22);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--red);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 16px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 450;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}

.nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 500;
  border-left: 2px solid var(--red);
  padding-left: 8px;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Sidebar footer ──────────────────────────────────── */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
}

.user-avatar {
  width: 30px; height: 30px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-email {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--navy);
  letter-spacing: -0.2px;
}

.topbar-date {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(230, 51, 41, 0.08);
  color: var(--red);
}

.badge-live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Main content ────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ── Flash messages ──────────────────────────────────── */
.flash-notice {
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
}

.flash-alert {
  padding: 12px 16px;
  background: #fff1f0;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
}

/* ── Login page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--navy-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-logo-mark {
  width: 40px; height: 40px;
  background: var(--red);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo-name {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.3px;
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.25);
}

/* ── Kaminari pagination ─────────────────────────────── */
nav.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

nav.pagination a,
nav.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 450;
  transition: background 0.1s, border-color 0.1s;
}

nav.pagination a:hover {
  background: var(--bg);
  border-color: #c5cdd8;
  color: var(--navy);
}

nav.pagination .current {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
  pointer-events: none;
}

nav.pagination .disabled,
nav.pagination span.first,
nav.pagination span.last,
nav.pagination span.prev,
nav.pagination span.next {
  color: var(--muted);
  pointer-events: none;
  border-color: var(--border);
}

nav.pagination .gap {
  border: none;
  background: transparent;
  color: var(--muted);
  pointer-events: none;
}

.data-table { width:100%; border-collapse:collapse; }
.data-table th {
  padding:10px 16px; text-align:left; font-size:11px; font-weight:600;
  text-transform:uppercase; letter-spacing:0.06em; color:#fff;
  border-bottom:1px solid var(--border); background:#0f1f4b; white-space:nowrap;
}
.data-table th[data-cumul-cell], .data-table th[data-cumul-cell-company] {
  color:var(--navy);
  background-color: var(--light-blue);
}
.data-table th[data-mensuel-cell] .data-table th[data-mensuel-cell-company]  {
  color:var(--navy);
  background-color: var(--light-red);
}

.data-table td { padding:11px 16px; font-size:13.5px; border-bottom:1px solid var(--border); white-space:nowrap; }
.data-table tbody tr:last-child td { border-bottom:none; }
.data-table tbody tr:hover td { background:#f9fafb; }
.record-link { 
  color:rgb(59 113 202); 
  font-weight:500; 
  text-decoration:underline; 
}
.record-link:hover { text-decoration:underline; }
.filter-bar { padding:14px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.filter-bar > div:last-child {
  margin-left: auto;
}
.filter-input { padding:7px 12px; border:1px solid var(--border); border-radius:6px; font-size:13px; font-family:inherit; color:var(--text); outline:none; min-width:220px; }
.filter-input:focus { border-color:var(--navy); }
.btn-primary { padding:7px 14px; background:var(--navy); color:#fff; border:none; border-radius:6px; font-size:13px; cursor:pointer; font-family:inherit; }
.btn-primary:hover { opacity:0.9; }
.btn-clear { padding:7px 14px; background:#f4f6fb; color:var(--muted); border:1px solid var(--border); border-radius:6px; font-size:13px; text-decoration:none; }
.count-badge { font-size:12px; color:var(--muted); white-space:nowrap; margin-left:auto; }

.table-panel {
  background:#fff; border:1px solid var(--border); border-radius:12px; overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,0.06);
}

/* ── Collapsible nav groups ──────────────────────────── */
.nav-group-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px 10px 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.25);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  border-radius: 4px;
  transition: background 0.15s;
}

.nav-group-toggle:hover {
  background: rgba(255,255,255,0.05);
}

.nav-group-chevron {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.5;
}

.nav-group.open .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-group-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.nav-group.open .nav-group-children {
  max-height: 500px;
}

.nav-item.nav-sub {
  padding-left: 22px;
}

/* Collapsed sidebar: hide nav group toggles and children */
#sidebar.collapsed .nav-group-toggle,
#sidebar.collapsed .nav-group-children {
  display: none;
}

/* ── Collapsible sidebar ─────────────────────────────── */
#sidebar {
  --sidebar-expanded-width: 232px;
  position: relative;
  transition: width 0.25s ease, min-width 0.25s ease;
}

#sidebar .nav-label {
  transition: max-width 0.25s ease, opacity 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  max-width: 200px;
  display: block;
}

#sidebar.collapsed {
  width: 56px !important;
  min-width: 56px !important;
}

#sidebar.collapsed .nav-label {
  opacity: 0;
  max-width: 0;
}

#sidebar.collapsed .nav-section-label {
  height: 0;
  padding: 0;
  overflow: hidden;
}

#sidebar.collapsed .sidebar-logo {
  padding: 16px 12px;
}

#sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
  border-left: none;
}

#sidebar.collapsed .nav-item.active {
  border-left: none;
  padding: 10px;
}

#sidebar.collapsed .user-row {
  justify-content: center;
}

/* ── Sidebar toggle button ───────────────────────────── */
#sidebar-toggle {
  position: fixed;
  top: 50vh;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: white;
  border: 1px solid #0f1f4b;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: left 0.25s ease, box-shadow 0.2s ease;
  padding: 0;
}

#sidebar-toggle:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  background: #f8faff;
  transform: translateY(-50%) scale(1.1);
}

#sidebar-toggle svg {
  transition: transform 0.25s ease;
  color: #0f1f4b;
  flex-shrink: 0;
}

#sidebar.collapsed #sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ── Collapsed state tooltips ────────────────────────── */
#sidebar.collapsed a[data-tooltip] {
  position: relative;
}

#sidebar.collapsed a[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f1f4b;
  color: white;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 200;
}

#sidebar.collapsed a[data-tooltip]:hover::after {
  opacity: 1;
}

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

.spinning {
  animation: spin 1s linear infinite;
}

/* ── Toast notifications ─────────────────────────────── */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  min-width: 260px;
  max-width: 400px;
  pointer-events: all;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toast-in 0.3s ease forwards;
  cursor: pointer;
}

.toast-success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.toast-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.toast-info {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

.toast-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}