/* =======================================
   DevisWindow Pro - Styles principaux
   ======================================= */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a2035;
  --sidebar-hover: #2a3150;
  --sidebar-active: #4361ee;
  --topbar-height: 60px;
  --primary: #4361ee;
  --primary-dark: #3451d1;
  --success: #2ec4b6;
  --warning: #f7b731;
  --danger: #e55353;
  --info: #48cae4;
  --light-bg: #f0f2f5;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --border-radius: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--light-bg);
  color: #2d3748;
  margin: 0;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
  overflow-y: auto;
}

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

#sidebar .sidebar-brand .brand-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white;
}

#sidebar .sidebar-brand .brand-text {
  color: white;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

#sidebar .sidebar-brand .brand-text small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

#sidebar .sidebar-user {
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

#sidebar .sidebar-user .user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: white;
}

#sidebar .sidebar-user .user-info {
  flex: 1;
}

#sidebar .sidebar-user .user-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
}

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

#sidebar .sidebar-section-title {
  padding: 16px 24px 6px;
  color: rgba(255,255,255,0.3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: background .2s, color .2s;
  border-left: 3px solid transparent;
}

#sidebar nav a:hover {
  background: var(--sidebar-hover);
  color: white;
}

#sidebar nav a.active {
  background: rgba(67,97,238,0.2);
  color: white;
  border-left-color: var(--primary);
}

#sidebar nav a i {
  font-size: 17px;
  width: 20px;
  text-align: center;
}

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

/* ===== TOPBAR ===== */
#topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid #e8ecf0;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

#topbar .page-title {
  font-size: 17px;
  font-weight: 700;
  color: #1a2035;
  flex: 1;
}

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

.lang-switcher a {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 20px;
  text-decoration: none;
  color: #666;
  border: 1px solid #ddd;
  transition: all .2s;
}

.lang-switcher a.active,
.lang-switcher a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== CONTENT ===== */
#content {
  flex: 1;
  padding: 24px 28px;
}

/* ===== CARDS ===== */
.card {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  background: white;
}

.card-header {
  background: white;
  border-bottom: 1px solid #f0f2f5;
  border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
}

/* ===== STAT CARDS ===== */
.stat-card {
  border-radius: var(--border-radius);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.stat-card .stat-icon {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  opacity: 0.15;
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-card.primary  { background: linear-gradient(135deg, #4361ee, #3a0ca3); }
.stat-card.success  { background: linear-gradient(135deg, #2ec4b6, #0096c7); }
.stat-card.warning  { background: linear-gradient(135deg, #f7b731, #f77f00); }
.stat-card.danger   { background: linear-gradient(135deg, #e55353, #c1121f); }
.stat-card.info     { background: linear-gradient(135deg, #48cae4, #0077b6); }
.stat-card.purple   { background: linear-gradient(135deg, #7b2d8b, #4a0072); }

/* ===== QUICK ACTION BUTTONS ===== */
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
  background: white;
  border: 2px solid #e8ecf0;
  border-radius: var(--border-radius);
  text-decoration: none;
  color: #2d3748;
  transition: all .25s;
  text-align: center;
  gap: 10px;
}

.quick-action-btn i {
  font-size: 28px;
  color: var(--primary);
}

.quick-action-btn span {
  font-size: 13px;
  font-weight: 600;
}

.quick-action-btn:hover {
  border-color: var(--primary);
  background: #f0f4ff;
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(67,97,238,0.15);
}

/* ===== CREATE DEVIS ===== */
.step-wizard {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.step-wizard .step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #aaa;
}

.step-wizard .step.active { color: var(--primary); font-weight: 600; }
.step-wizard .step.done   { color: var(--success); }

.step-wizard .step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: #e8ecf0;
  color: #888;
  flex-shrink: 0;
}

.step-wizard .step.active .step-num { background: var(--primary); color: white; }
.step-wizard .step.done .step-num   { background: var(--success); color: white; }

/* Product type selector */
.product-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.product-type-card {
  border: 2px solid #e8ecf0;
  border-radius: 10px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: white;
}

.product-type-card:hover {
  border-color: var(--primary);
  background: #f0f4ff;
}

.product-type-card.selected {
  border-color: var(--primary);
  background: #eef2ff;
}

.product-type-card svg, .product-type-card i {
  font-size: 28px;
  color: var(--primary);
  display: block;
  margin: 0 auto 8px;
}

.product-type-card .pt-name {
  font-size: 12px;
  font-weight: 600;
  color: #2d3748;
  line-height: 1.2;
}

/* Gamme selector */
.gamme-list .gamme-item {
  border: 2px solid #e8ecf0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all .2s;
  font-size: 13px;
  font-weight: 500;
}

.gamme-list .gamme-item:hover  { border-color: var(--primary); background: #f0f4ff; }
.gamme-list .gamme-item.selected { border-color: var(--primary); background: #eef2ff; color: var(--primary); }

/* Opening type tabs */
.opening-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.opening-tab-btn {
  padding: 5px 14px;
  border: 2px solid #e8ecf0;
  border-radius: 20px;
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  color: #555;
}

.opening-tab-btn:hover,
.opening-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Opening type images grid */
.opening-images-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.opening-img-item {
  border: 2px solid #e8ecf0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all .2s;
  background: white;
  position: relative;
}

.opening-img-item:hover  { border-color: var(--primary); }
.opening-img-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(67,97,238,0.3); }

.opening-img-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: 4px;
  background: white;
}

.opening-img-item .img-label {
  font-size: 9px;
  text-align: center;
  padding: 2px 4px;
  background: #f8f9fa;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opening-img-item.selected::after {
  content: '✓';
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}

/* Dimensions form */
.dimensions-form {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 14px;
}

.dimensions-form .form-label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

/* ===== PRODUCT LIST (right column) ===== */
.product-list-panel {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.product-list-panel .panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f2f5;
  font-weight: 600;
  font-size: 15px;
}

.product-list-panel .panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.product-item-row {
  border: 1px solid #e8ecf0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: white;
  position: relative;
  transition: box-shadow .2s;
}

.product-item-row:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }

.product-item-row .item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.product-item-row .item-thumb {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid #eee;
  padding: 2px;
  background: white;
}

.product-item-row .item-info {
  flex: 1;
}

.product-item-row .item-name {
  font-size: 13px;
  font-weight: 600;
  color: #2d3748;
}

.product-item-row .item-sub {
  font-size: 11px;
  color: #888;
}

.product-item-row .btn-remove-item {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  transition: color .2s;
}

.product-item-row .btn-remove-item:hover { color: var(--danger); }

.product-item-row .item-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.product-item-row .item-fields label {
  font-size: 10px;
  font-weight: 600;
  color: #999;
  display: block;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.product-item-row .item-fields .form-control,
.product-item-row .item-fields .form-select {
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 6px;
  height: 34px;
}

.margin-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.margin-badge.positive { background: #e6f9f0; color: #198754; }
.margin-badge.negative { background: #fde8e8; color: var(--danger); }
.margin-badge.neutral  { background: #f0f2f5; color: #666; }

/* Totals panel */
.totals-panel {
  border-top: 2px solid #f0f2f5;
  padding: 16px 20px;
  background: #f8f9fa;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.totals-panel .total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}

.totals-panel .total-row.grand-total {
  border-top: 2px solid #dee2e6;
  margin-top: 8px;
  padding-top: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.totals-panel .total-label { color: #666; }
.totals-panel .total-value { font-weight: 600; }

/* ===== TABLES ===== */
.table-container {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  background: #f8f9fa;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #888;
  border-bottom: 2px solid #e8ecf0;
  padding: 12px 16px;
}

.table tbody td {
  padding: 12px 16px;
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 1px solid #f5f5f5;
}

.badge-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-status.draft    { background: #f0f2f5; color: #666; }
.badge-status.sent     { background: #fff3cd; color: #b45309; }
.badge-status.signed   { background: #d1fae5; color: #065f46; }
.badge-status.cancelled { background: #fee2e2; color: #991b1b; }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed #c8d0e7;
  border-radius: var(--border-radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .25s;
  background: white;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: #f0f4ff;
}

.upload-zone i {
  font-size: 48px;
  color: #c8d0e7;
  display: block;
  margin-bottom: 12px;
}

.upload-zone.drag-over i { color: var(--primary); }

.upload-zone .upload-text {
  font-size: 15px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}

.upload-zone .upload-hint {
  font-size: 12px;
  color: #999;
}

/* ===== CONFIGURATION ===== */
.config-section {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
  overflow: hidden;
}

.config-section-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
}

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

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

.btn-sm { font-size: 12px; }

/* ===== ALERTS ===== */
.alert {
  border-radius: 10px;
  font-size: 14px;
  border: none;
}

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideIn .3s ease;
  max-width: 360px;
  color: white;
}

.app-toast.success { background: #2ec4b6; }
.app-toast.error   { background: var(--danger); }
.app-toast.info    { background: var(--primary); }
.app-toast.warning { background: var(--warning); color: #333; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: #aaa;
}

.empty-state i {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
  opacity: .35;
}

.empty-state p {
  font-size: 15px;
  margin: 0;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8d0e7; border-radius: 10px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.show { transform: translateX(0); }
  #main-wrapper { margin-left: 0; }
  .product-type-grid { grid-template-columns: repeat(2, 1fr); }
  .opening-images-grid { grid-template-columns: repeat(3, 1fr); }
  .product-item-row .item-fields { grid-template-columns: 1fr 1fr; }
}
