/* ============================================================
   FreelanceManager — CSS Principal
   Mobile-first, responsive desktop + iPhone
   ============================================================ */

/* ─── Reset et variables ─────────────────────────────────────── */
:root {
  --blue-dark:    #1E3A5F;
  --blue-mid:     #2E6DA4;
  --blue-light:   #D6E4F0;
  --blue-pale:    #F0F7FF;
  --green:        #1A7A42;
  --green-light:  #E8F5EE;
  --orange:       #C06A00;
  --orange-light: #FFF3E0;
  --red:          #C0392B;
  --red-light:    #FDECEA;
  --grey-dark:    #333333;
  --grey-mid:     #666666;
  --grey-light:   #F5F5F5;
  --grey-border:  #DDDDDD;
  --white:        #FFFFFF;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.12);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.10);
  --radius:       8px;
  --radius-sm:    4px;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --nav-width:    240px;
  --nav-height:   60px; /* mobile bottom bar */
  --header-h:     56px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--grey-dark);
  background: var(--grey-light);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ─── Layout principal ──────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Navigation latérale (desktop) ────────────────────────── */
.sidebar {
  width: var(--nav-width);
  background: var(--blue-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo h1 {
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.sidebar-logo span {
  color: var(--blue-light);
  font-size: 12px;
  display: block;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); text-decoration: none; }
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  border-left-color: var(--blue-light);
}
.nav-item .icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer .user-name { color: rgba(255,255,255,0.8); font-weight: 500; display: block; margin-bottom: 4px; }

/* ─── Contenu principal ─────────────────────────────────────── */
.main-content {
  margin-left: var(--nav-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.page-header h2 { font-size: 18px; font-weight: 600; color: var(--blue-dark); }

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

/* ─── Cartes (cards) ────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-border);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--blue-dark); }
.card-body { padding: 20px; }

/* ─── Grilles dashboard ─────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── Jauges (barres de progression) ───────────────────────── */
.gauge-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid var(--grey-border);
  box-shadow: var(--shadow-sm);
}
.gauge-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-mid);
}
.gauge-label strong { color: var(--grey-dark); }
.gauge-bar {
  height: 10px;
  background: var(--grey-border);
  border-radius: 5px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
  background: var(--green);
}
.gauge-fill.warn  { background: var(--orange); }
.gauge-fill.alert { background: var(--red); }
.gauge-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--grey-mid);
}

/* ─── Stat cards (dashboard) ────────────────────────────────── */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--grey-border);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 12px; font-weight: 500; color: var(--grey-mid); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--blue-dark); margin: 4px 0; }
.stat-card .stat-sub   { font-size: 12px; color: var(--grey-mid); }
.stat-card .stat-value.green  { color: var(--green); }
.stat-card .stat-value.orange { color: var(--orange); }

/* ─── Formulaires ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--grey-dark);
  margin-bottom: 5px;
}
.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--grey-dark);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(46,109,164,0.15);
}
.form-control.error { border-color: var(--red); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.form-hint  { font-size: 12px; color: var(--grey-mid); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ─── Boutons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--blue-mid); color: var(--white); }
.btn-secondary { background: var(--grey-border); color: var(--grey-dark); }
.btn-success   { background: var(--green); color: var(--white); }
.btn-danger    { background: var(--red); color: var(--white); }
.btn-outline   { background: transparent; border: 1px solid var(--blue-mid); color: var(--blue-mid); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Tableaux ──────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead tr {
  background: var(--blue-pale);
  border-bottom: 2px solid var(--blue-light);
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-dark);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--grey-border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--grey-light); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── Badges de statut ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-grey   { background: var(--grey-border); color: var(--grey-mid); }

/* ─── Alertes ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-info    { background: var(--blue-pale); border: 1px solid var(--blue-light); color: var(--blue-dark); }
.alert-success { background: var(--green-light); border: 1px solid #A8D5BB; color: var(--green); }
.alert-warning { background: var(--orange-light); border: 1px solid #FFD0A0; color: var(--orange); }
.alert-error   { background: var(--red-light); border: 1px solid #F5BCBC; color: var(--red); }

/* ─── Modales ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--blue-dark); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--grey-mid); padding: 4px 8px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--grey-border); display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Couleur client (point dans les listes) ────────────────── */
.client-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ─── Indicateur remote / onsite ────────────────────────────── */
.work-badge {
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 10px;
}
.work-badge.remote  { background: #E8F0FE; color: #1565C0; }
.work-badge.onsite  { background: #FFF3E0; color: #E65100; }

/* ─── Loading ───────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--grey-border);
  border-top-color: var(--blue-mid);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Filtres barre ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
}
.filter-bar .form-control { width: auto; }

/* ─── Pagination ────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 16px 0; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--grey-border);
}
.pagination a { color: var(--blue-mid); background: var(--white); }
.pagination a:hover { background: var(--blue-pale); text-decoration: none; }
.pagination .current { background: var(--blue-mid); color: var(--white); border-color: var(--blue-mid); }

/* ─── Toast notifications ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 14px;
  animation: slideIn 0.25s ease;
  max-width: 320px;
}
.toast.success { background: var(--green); color: var(--white); }
.toast.error   { background: var(--red); color: var(--white); }
.toast.info    { background: var(--blue-mid); color: var(--white); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Séparateur section ────────────────────────────────────── */
.section-sep { margin: 24px 0; border: none; border-top: 1px solid var(--grey-border); }

/* ─── Textes utilitaires ─────────────────────────────────────── */
.text-muted    { color: var(--grey-mid); font-size: 13px; }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.fw-bold       { font-weight: 600; }
.amount-eur    { color: var(--green); font-weight: 600; }
.amount-chf    { color: var(--blue-mid); font-weight: 600; }
.amount-danger { color: var(--red); font-weight: 600; }

/* ─── Calendrier overrides ──────────────────────────────────── */
.fc .fc-toolbar-title { font-size: 16px !important; }
.fc .fc-event { border-radius: 4px !important; font-size: 12px !important; padding: 1px 4px !important; }
.fc .fc-daygrid-day-number { font-size: 13px; }
.fc .fc-col-header-cell { background: var(--blue-pale); }

pre {
    unicode-bidi: isolate;
    white-space: pre;
    margin-block: 1em 1em;
    margin-inline: 0px;
}

/* ============================================================
   RESPONSIVE — Mobile / iPhone
   ============================================================ */
@media (max-width: 768px) {
  /* Masquer la sidebar, afficher la barre bottom */
  .sidebar { display: none; }
  .main-content { margin-left: 0; margin-bottom: var(--nav-height); }

  /* Navigation bottom bar */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--blue-dark);
    z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.1);
    /* Safe area iPhone */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.6);
    font-size: 10px;
    gap: 3px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav a .icon { font-size: 20px; }
  .mobile-nav a.active, .mobile-nav a:hover { color: var(--white); }

  /* Ajustements layout */
  .page-body { padding: 12px; }
  .page-header { padding: 0 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }

  /* Modale plein écran sur mobile */
  .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* Tableau : certaines colonnes masquées */
  .hide-mobile { display: none !important; }

  /* Stat cards plus compactes */
  .stat-card .stat-value { font-size: 20px; }
}

/* Desktop : masquer la barre mobile */
@media (min-width: 769px) {
  .mobile-nav { display: none; }
}

/* iPhone SE et petits écrans */
@media (max-width: 375px) {
  .page-body { padding: 8px; }
  .card-body { padding: 12px; }
  .btn { padding: 8px 14px; font-size: 13px; }
}
