/* MNpro App — Styles */
/* Palette: noir/blanc + orange MNpro */

:root {
  --primary:   #e85d04;   /* orange MNpro */
  --primary-d: #c44d00;
  --dark:      #1a1a1a;
  --gray-1:    #2d2d2d;
  --gray-2:    #444;
  --gray-3:    #888;
  --gray-4:    #ccc;
  --gray-5:    #f4f4f4;
  --white:     #fff;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --blue:      #3b82f6;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --sidebar-w: 220px;
  --header-h:  56px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--dark);
  background: var(--gray-5);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
}
.login-container {
  background: var(--white);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo img { height: 48px; margin-bottom: 8px; }
.login-logo h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.login-logo p { color: var(--gray-3); font-size: 13px; margin-top: 4px; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  color: var(--white);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo img { height: 32px; }
.sidebar-logo .app-name { font-size: 18px; font-weight: 700; color: var(--white); }
.sidebar-logo .app-sub { font-size: 11px; color: var(--gray-3); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 8px 20px 4px; font-size: 11px; text-transform: uppercase;
               letter-spacing: .8px; color: var(--gray-3); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.75);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: var(--white); text-decoration: none; }
.nav-item.active { background: rgba(232,93,4,.15); color: var(--primary); border-left-color: var(--primary); }
.nav-item .icon { font-size: 18px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer a { color: rgba(255,255,255,.6); font-size: 13px; }
.sidebar-footer a:hover { color: var(--white); }

/* Main */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* Stats dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-left: 4px solid var(--primary);
}
.stat-card.green  { border-left-color: var(--green); }
.stat-card.red    { border-left-color: var(--red); }
.stat-card.yellow { border-left-color: var(--yellow); }
.stat-card.blue   { border-left-color: var(--blue); }
.stat-label { font-size: 12px; color: var(--gray-3); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat-sub   { font-size: 12px; color: var(--gray-3); margin-top: 2px; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-5);
  border-bottom: 2px solid var(--gray-4);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-2);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Badges statut */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-draft    { background: #f1f5f9; color: var(--gray-2); }
.badge-sent     { background: #dbeafe; color: #1d4ed8; }
.badge-accepted { background: #dcfce7; color: #15803d; }
.badge-paid     { background: #dcfce7; color: #15803d; }
.badge-refused  { background: #fee2e2; color: #b91c1c; }
.badge-late     { background: #fef9c3; color: #92400e; }
.badge-invoiced { background: #f3e8ff; color: #7e22ce; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--gray-2);
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-4);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--dark);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,93,4,.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

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

/* Lignes devis/facture */
.lignes-table { width: 100%; }
.lignes-table th, .lignes-table td { padding: 6px 8px; }
.lignes-table input, .lignes-table select {
  padding: 6px 8px; border: 1px solid var(--gray-4);
  border-radius: 4px; font-size: 13px; width: 100%;
}
.lignes-table input:focus, .lignes-table select:focus { outline: none; border-color: var(--primary); }
.ligne-section input { font-weight: 700; background: var(--gray-5); }
.col-desc { width: 35%; }
.col-unite { width: 8%; }
.col-num   { width: 9%; }
.col-prix  { width: 11%; }
.col-total { width: 11%; text-align: right; }
.col-act   { width: 5%; text-align: center; }

/* Totaux */
.totaux-block { max-width: 320px; margin-left: auto; margin-top: 20px; }
.totaux-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--gray-5); }
.totaux-row.total-final { font-size: 18px; font-weight: 800; border-bottom: none; padding-top: 10px; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-d); color: var(--white); text-decoration: none; }
.btn-secondary { background: var(--gray-5); color: var(--dark); border: 1px solid var(--gray-4); }
.btn-secondary:hover { background: var(--gray-4); }
.btn-success { background: var(--green); color: var(--white); }
.btn-danger  { background: var(--red);   color: var(--white); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }

/* ---- ALERTS ---- */
.alert { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-error   { background: #fee2e2; color: #b91c1c; border-left: 4px solid var(--red); }
.alert-success { background: #dcfce7; color: #15803d; border-left: 4px solid var(--green); }
.alert-info    { background: #dbeafe; color: #1d4ed8; border-left: 4px solid var(--blue); }

/* ---- MOBILE ---- */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-220px);
    width: 220px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; flex-direction: column; gap: 4px; }
  .menu-toggle span { display: block; width: 22px; height: 2px; background: var(--dark); border-radius: 2px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  /* Sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
}
