/* ===== BATIGEST PRO – STYLES GLOBAUX ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #7c3aed;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #1e293b;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* ===== LAYOUT ===== */
#app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar .logo-area {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

#sidebar .logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

#sidebar .logo-text { 
  color: #fff; 
  font-weight: 700; 
  font-size: 16px;
  line-height: 1.2;
}

#sidebar .logo-sub {
  color: #94a3b8;
  font-size: 11px;
}

#sidebar .company-info {
  padding: 12px 16px;
  background: rgba(255,255,255,0.05);
  margin: 12px;
  border-radius: 10px;
  cursor: pointer;
}

#sidebar .company-name {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar .company-plan {
  font-size: 10px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

#sidebar .plan-badge {
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

#sidebar nav {
  padding: 8px 0;
  flex: 1;
}

#sidebar .nav-section-title {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 20px 4px;
}

#sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 0;
  transition: var(--transition);
  position: relative;
  text-decoration: none;
  font-size: 14px;
}

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

#sidebar .nav-item.active {
  background: rgba(37,99,235,0.2);
  color: #60a5fa;
  border-right: 3px solid var(--primary);
}

#sidebar .nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

#sidebar .nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

#sidebar .sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

#sidebar .user-avatar-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

#sidebar .user-avatar-area:hover {
  background: rgba(255,255,255,0.07);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* ===== TOPBAR ===== */
#topbar {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

#topbar .page-title {
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  flex: 1;
}

#topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== PAGE CONTENT ===== */
#page-content {
  padding: 24px;
  flex: 1;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: var(--transition);
}

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

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover { background: #b45309; }

.btn-secondary {
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg-main); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
}

thead th {
  background: var(--bg-main);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(37,99,235,0.03); }

tbody td {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text-primary);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info { background: #dbeafe; color: #2563eb; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #7c3aed; }

[data-theme="dark"] .badge-success { background: rgba(22,163,74,0.2); color: #4ade80; }
[data-theme="dark"] .badge-danger { background: rgba(220,38,38,0.2); color: #f87171; }
[data-theme="dark"] .badge-warning { background: rgba(217,119,6,0.2); color: #fbbf24; }
[data-theme="dark"] .badge-info { background: rgba(37,99,235,0.2); color: #60a5fa; }
[data-theme="dark"] .badge-secondary { background: rgba(71,85,105,0.3); color: #94a3b8; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-label span.req { color: var(--danger); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

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

.form-textarea { resize: vertical; min-height: 80px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  animation: slideUp 0.25s ease;
  position: relative;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--bg-main);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger); color: #fff; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== PROGRESS BAR ===== */
.progress-bar-container {
  background: var(--bg-main);
  border-radius: 10px;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

.progress-green { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-orange { background: linear-gradient(90deg, #f97316, #ea580c); }
.progress-red { background: linear-gradient(90deg, #ef4444, #dc2626); }

/* ===== LOGIN PAGE ===== */
#login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}

.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-right {
  width: 480px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  min-height: 100vh;
}

.login-box { width: 100%; max-width: 380px; }
.login-logo { margin-bottom: 32px; }

.login-hero {
  color: #fff;
  max-width: 480px;
}

.login-hero h1 {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
}

.login-hero p {
  font-size: 16px;
  color: #94a3b8;
  line-height: 1.6;
  margin-bottom: 32px;
}

.feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e2e8f0;
  font-size: 14px;
}

.feature-list li .check {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(37,99,235,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  font-size: 12px;
  flex-shrink: 0;
}

/* ===== FILTERS ===== */
.filters-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 13px;
}

.search-input-wrap input {
  padding-left: 34px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 200%; }
}

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

.loading-spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ===== BUDGET BAR WIDGET ===== */
.budget-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.budget-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.budget-stat {
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-main);
}

.budget-stat .val {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.budget-stat .lbl {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== TABS ===== */
.tabs-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 7px;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  min-width: 300px;
  pointer-events: all;
  animation: slideUp 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-danger { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p { font-size: 14px; }

/* ===== DARK MODE ADJUSTMENTS ===== */
[data-theme="dark"] body { background: var(--bg-main); }
[data-theme="dark"] .card,
[data-theme="dark"] table,
[data-theme="dark"] #topbar,
[data-theme="dark"] .modal,
[data-theme="dark"] .toast,
[data-theme="dark"] .login-right { background: var(--bg-card); }
[data-theme="dark"] thead th { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: var(--bg-main);
  color: var(--text-primary);
  border-color: var(--border);
}
[data-theme="dark"] .btn-secondary { background: var(--bg-main); }

/* ===== RESPONSIVE ===== */
#sidebar-toggle {
  display: none;
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-primary);
}

@media (max-width: 1024px) {
  :root { --sidebar-width: 0px; }
  #sidebar { transform: translateX(-260px); width: 260px; }
  #sidebar.open { transform: translateX(0); --sidebar-width: 260px; }
  #main-content { margin-left: 0; }
  #sidebar-toggle { display: flex; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .budget-stats { grid-template-columns: repeat(2, 1fr); }
  .login-right { width: 100%; }
  .login-left { display: none; }
}

@media (max-width: 640px) {
  #page-content { padding: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
}

/* ===== SUBSCRIPTION PLANS ===== */
.plan-card {
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  transition: var(--transition);
  position: relative;
}

.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.plan-card.featured {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(37,99,235,0.05), rgba(124,58,237,0.05));
}

.plan-badge-top {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 20px;
}

/* ===== CHANTIER SPECIFIC ===== */
.chantier-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: var(--transition);
  cursor: pointer;
}

.chantier-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: var(--primary);
}

.chantier-status-bar {
  height: 6px;
  border-radius: 3px;
  margin-bottom: 16px;
}

/* ===== SIDEBAR OVERLAY MOBILE ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.show { display: block; }
