/**
 * responsive.css — Correctifs responsives globaux
 * Pro-Artisan · 2026
 * Chargé EN DERNIER dans main.php pour surcharger les conflits
 *
 * Breakpoints unifiés :
 *   ≤ 1200px  xl-down
 *   ≤  992px  lg-down  (tablette)
 *   ≤  768px  md-down  (mobile landscape)
 *   ≤  576px  sm-down  (mobile portrait)
 *   ≤  480px  xs-down  (petits téléphones)
 */

/* ══════════════════════════════════════════════
   0 · VARIABLES BREAKPOINTS (tokens seulement —
       les couleurs sont dans variables-global.css)
   ══════════════════════════════════════════════ */
:root {
  --bp-xl:   1200px;
  --bp-lg:    992px;
  --bp-md:    768px;
  --bp-sm:    576px;
  --bp-xs:    480px;
}

/* ══════════════════════════════════════════════
   1 · CORRECTIFS GLOBAUX — FORMULAIRES
   Corrige le width:35% de style.css ligne ~142
   ══════════════════════════════════════════════ */
form input,
form select,
form textarea {
  max-width: 100%;
}

/* Formulaires Bootstrap : toujours pleine largeur */
.form-control,
.form-select {
  width: 100%;
}

/* Formulaires hero search : pleine largeur sur petits écrans */
.hero__search__form form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero__search__form form input,
.hero__search__form form .select__option,
.hero__search__form form button {
  box-sizing: border-box;
}

/* ══════════════════════════════════════════════
   2 · HEADER — CORRECTIFS GÉNÉRAUX
   ══════════════════════════════════════════════ */

/* Évite que le contenu passe sous le header sticky */
main {
  scroll-padding-top: 80px;
}

/* Empêche l'overflow horizontal global */
body {
  overflow-x: hidden;
}

.container,
.container-fluid {
  padding-left: 16px;
  padding-right: 16px;
}

/* ══════════════════════════════════════════════
   3 · SECTION PADDING — RÉDUIT SUR MOBILE
   ══════════════════════════════════════════════ */
.spad {
  padding-top: 80px;
  padding-bottom: 80px;
}

/* ══════════════════════════════════════════════
   4 · TABLEAUX — SCROLL HORIZONTAL + CARTES MOBILE
   ══════════════════════════════════════════════ */

/* Wrapper scroll pour toutes les tables du projet */
.devis-table-container,
.table-responsive-pa {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
}

/* Assure que le tableau ne compresse pas ses colonnes */
.devis-table {
  min-width: 560px;
}

/* ══════════════════════════════════════════════
   5 · STAT CARDS — LAYOUT FLEXIBLE
   ══════════════════════════════════════════════ */
.devis-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

/* ══════════════════════════════════════════════
   6 · IMAGES RESPONSIVES
   ══════════════════════════════════════════════ */
img {
  max-width: 100%;
  height: auto;
}

.artisan-image-default {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ══════════════════════════════════════════════
   ≤ 1200px  —  LARGE TABLETTE / PETIT DESKTOP
   ══════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .container {
    max-width: 100%;
  }

  .spad {
    padding-top: 70px;
    padding-bottom: 70px;
  }
}

/* ══════════════════════════════════════════════
   ≤ 992px  —  TABLETTE
   ══════════════════════════════════════════════ */
@media (max-width: 992px) {
  .spad {
    padding-top: 60px;
    padding-bottom: 60px;
  }

  /* Hero : empile les éléments */
  .hero__text {
    text-align: center;
  }

  /* Profil header : colonne */
  .profil-header__main {
    flex-direction: column;
    gap: 16px;
  }

  .profil-header__actions {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Dashboard sidebar : pleine largeur */
  .dashboard-sidebar {
    width: 100%;
    margin-bottom: 20px;
  }

  /* Profile card */
  .profile-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .profile-card__actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    margin-left: 0;
  }

  /* Listing deux colonnes */
  .listing__item {
    max-width: 100%;
  }
}

/* ══════════════════════════════════════════════
   ≤ 768px  —  MOBILE LANDSCAPE
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Espacement global ── */
  .spad {
    padding-top: 50px;
    padding-bottom: 50px;
  }

  .container,
  .container-fluid {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* ── Titres de section ── */
  .section-title h2 {
    font-size: 1.6rem;
    line-height: 1.25;
  }

  .section-title p {
    font-size: 0.95rem;
  }

  /* ── Hero section ── */
  .hero__search__form form {
    flex-direction: column;
    gap: 8px;
  }

  .hero__search__form form input,
  .hero__search__form form .select__option,
  .hero__search__form form button {
    width: 100%;
    margin-right: 0;
  }

  .hero__text {
    padding: 50px 0 30px;
  }

  .hero__text h2 {
    font-size: 1.8rem;
    line-height: 1.2;
  }

  /* ── Espace artisan : conteneurs ── */
  .devis-container {
    padding: 24px 12px 40px;
  }

  .devis-header h1 {
    font-size: 1.5rem;
    gap: 10px;
  }

  /* ── Stat cards : 2 colonnes ── */
  .devis-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 20px 12px;
  }

  .stat-value {
    font-size: 2rem;
  }

  /* ── Tableau → transformation en cartes mobiles ── */
  .devis-table-container {
    border-radius: 12px;
    overflow: visible;
  }

  .devis-table,
  .devis-table thead,
  .devis-table tbody,
  .devis-table th,
  .devis-table td,
  .devis-table tr {
    display: block;
  }

  /* Masque l'entête du tableau */
  .devis-table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
    visibility: hidden;
  }

  /* Chaque ligne devient une carte */
  .devis-table .devis-row,
  .devis-table tbody tr {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    margin-bottom: 12px;
    padding: 16px;
    border: 1px solid var(--color-border);
    position: relative;
  }

  .devis-table .devis-row:hover,
  .devis-table tbody tr:hover {
    background: #f8f9ff;
    transform: none;
  }

  /* Chaque cellule affiche son label via data-label */
  .devis-table td {
    padding: 6px 0;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
  }

  .devis-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--color-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 80px;
    flex-shrink: 0;
  }

  /* Actions : en ligne, alignées à droite */
  .devis-table td.devis-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
    margin-top: 8px;
  }

  .devis-table td.devis-actions::before {
    display: none;
  }

  /* Description : texte normal, pas tronqué */
  .devis-description {
    max-width: 100%;
    white-space: normal;
  }

  /* ── Footer newsletter ── */
  .newslatter__form {
    flex-direction: column;
    gap: 10px;
  }

  .newslatter__form input,
  .newslatter__form button {
    width: 100%;
    border-radius: 8px;
  }

  .newslatter__text {
    margin-bottom: 20px;
  }

  /* ── Footer liens ── */
  .footer__copyright {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }

  .footer__copyright__text,
  .footer__copyright__links {
    float: none;
    text-align: center;
  }

  .footer__copyright__links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
  }

  /* ── Plans page ── */
  .plan-card {
    margin-bottom: 20px;
  }

  /* ── Artisan profile ── */
  .profil-avatar {
    width: 80px;
    height: 80px;
  }

  .profil-header__content h1 {
    font-size: 1.5rem;
  }

  /* ── Tabs nav ── */
  .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding-bottom: 2px;
  }

  .nav-tabs .nav-item {
    flex-shrink: 0;
  }

  .nav-tabs .nav-link {
    padding: 8px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  /* ── Formulaire devis ── */
  .devis-form-card {
    padding: 20px 16px;
  }

  /* ── Stripe / payment ── */
  .payment-history-container {
    padding: 24px 12px 40px;
  }

  /* ── Dashboard général ── */
  .dashboard-container {
    padding: 24px 12px 40px;
  }

  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .dashboard-actions-grid {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════
   ≤ 576px  —  MOBILE PORTRAIT
   ══════════════════════════════════════════════ */
@media (max-width: 576px) {
  /* ── Espacement ── */
  .spad {
    padding-top: 40px;
    padding-bottom: 40px;
  }

  .container,
  .container-fluid {
    padding-left: 10px;
    padding-right: 10px;
  }

  /* ── Titres ── */
  .section-title h2 {
    font-size: 1.4rem;
  }

  /* ── Stat cards : 1 colonne ── */
  .devis-stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
  }

  .stat-card .stat-value {
    font-size: 2.2rem;
    margin-bottom: 0;
    min-width: 60px;
  }

  .stat-card .stat-label {
    font-size: 0.9rem;
    color: var(--color-muted);
  }

  /* ── Hero ── */
  .hero__text h2 {
    font-size: 1.5rem;
  }

  /* ── Boutons : pleine largeur ── */
  .hero__search__form form button,
  .btn-submit-full {
    width: 100%;
    justify-content: center;
  }

  /* ── Dashboard stats : 1 colonne ── */
  .dashboard-stats-grid {
    grid-template-columns: 1fr;
  }

  /* ── Entête sections artisan ── */
  .devis-header h1 {
    font-size: 1.25rem;
    flex-wrap: wrap;
  }

  /* ── Stripe billing ── */
  .billing-info-grid {
    grid-template-columns: 1fr;
  }

  /* ── Artisan matching cards ── */
  .matching-card-meta {
    flex-direction: column;
    gap: 6px;
  }

  /* ── Pagination ── */
  .devis-pagination {
    gap: 4px;
    flex-wrap: wrap;
  }

  .pagination-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  /* ── Footer ── */
  .footer .col-lg-3 {
    margin-bottom: 24px;
  }

  .footer__about__logo img {
    max-height: 40px;
  }
}

/* ══════════════════════════════════════════════
   ≤ 480px  —  PETITS TÉLÉPHONES
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* ── Titres ── */
  .section-title h2 {
    font-size: 1.25rem;
  }

  /* ── Cartes artisan ── */
  .artisan-card {
    border-radius: 12px;
  }

  .artisan-card > img {
    height: 180px;
    object-fit: cover;
  }

  /* ── Boutons icon ── */
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  /* ── Header ── */
  .header-client__logo img,
  .header-artisan__logo img {
    height: 34px;
  }

  /* ── Status badges ── */
  .status-badge {
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  /* ── Popup modale ── */
  .modal-content {
    margin: 10px;
    border-radius: 12px;
  }

  /* ── Formulaires petits écrans ── */
  .form-group label,
  .form-label {
    font-size: 0.85rem;
  }

  .form-control,
  .form-select {
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  /* ── Plans cards ── */
  .plan-price {
    font-size: 2rem;
  }

  .plan-features li {
    font-size: 0.85rem;
  }

  /* ── Newsletter ── */
  .newslatter {
    padding: 30px 0;
  }

  .newslatter__text h3 {
    font-size: 1.2rem;
  }
}

/* ══════════════════════════════════════════════
   7 · IMPRESSION
   ══════════════════════════════════════════════ */
@media print {
  .header-client,
  .header-artisan,
  .newslatter,
  footer.footer,
  .devis-actions,
  .btn-icon,
  nav {
    display: none !important;
  }

  .devis-container,
  .devis-table-container {
    padding: 0;
    box-shadow: none;
    background: white;
  }

  .devis-table td,
  .devis-table th {
    border: 1px solid #ccc;
    padding: 8px;
    font-size: 11pt;
  }

  /* Rétablit l'affichage tableau pour l'impression */
  .devis-table,
  .devis-table thead,
  .devis-table tbody,
  .devis-table th,
  .devis-table td,
  .devis-table tr {
    display: revert;
  }

  .devis-table thead {
    position: static;
    visibility: visible;
  }
}

/* ══════════════════════════════════════════════
   8 · ACCESSIBILITÉ
   ══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus visible cohérent */
:focus-visible {
  outline: 3px solid var(--g-primary);
  outline-offset: 2px;
  border-radius: var(--g-radius-xs);
}

/* ══════════════════════════════════════════════
   9 · UTILITAIRES RESPONSIFS SUPPLÉMENTAIRES
   ══════════════════════════════════════════════ */

/* Images artisans */
.artisan-image-default {
  background: var(--g-gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
}

/* Correction overflow cartes dans grille */
.row {
  --bs-gutter-x: 1.5rem;
}

/* Boutons actions : ne se chevauchent pas sur mobile */
.action-buttons-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Assure que les cards ne débordent pas */
.card,
.stat-card,
.plan-card,
.artisan-card {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ══════════════════════════════════════════════
   10 · NOUVELLES PAGES — CALENDRIER, ANALYTICS, PORTFOLIO
   ══════════════════════════════════════════════ */

/* ── Calendrier ── */
@media (max-width: 992px) {
  .calendar-layout {
    flex-direction: column !important;
  }

  .calendar-sidebar {
    width: 100% !important;
    order: -1; /* Sidebar en haut sur tablette */
    margin-bottom: 20px;
  }
}

@media (max-width: 768px) {
  .calendar-grid .day-cell {
    min-height: 40px !important;
    font-size: 0.8rem;
  }

  .calendar-legend {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .calendar-nav {
    gap: 8px;
  }

  .calendar-nav button {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}

/* ── Analytics ── */
@media (max-width: 768px) {
  .analytics-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  .analytics-chart-container {
    height: 220px !important;
  }

  .analytics-chart-card {
    margin-bottom: 16px;
  }
}

@media (max-width: 480px) {
  .analytics-kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Portfolio ── */
@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  .portfolio-upload-zone {
    padding: 24px 12px !important;
  }

  .portfolio-upload-zone h5 {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .portfolio-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Scroll fluide global ── */
html {
  scroll-behavior: smooth;
}

/* ── Smooth transitions sur toutes les cartes ── */
.card,
.artisan-card,
.stat-card,
.plan-card,
.dashboard-stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* ── Meilleur contraste texte sur mobile ── */
@media (max-width: 576px) {
  body {
    font-size: 15px;
  }

  h1 { font-size: clamp(1.4rem, 6vw, 2rem); }
  h2 { font-size: clamp(1.2rem, 5vw, 1.6rem); }
  h3 { font-size: clamp(1rem, 4vw, 1.3rem); }
}

/* ── Loader skeleton animation ── */
@keyframes pa-skeleton-pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

.skeleton {
  background: var(--g-bg-muted);
  border-radius: var(--g-radius-sm);
  animation: pa-skeleton-pulse 1.5s ease infinite;
}

/* ── Fade-in entrance ── */
@keyframes pa-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: pa-fade-in-up 0.4s ease both;
}

.animate-in:nth-child(2) { animation-delay: 0.06s; }
.animate-in:nth-child(3) { animation-delay: 0.12s; }
.animate-in:nth-child(4) { animation-delay: 0.18s; }

/* ── Respect prefers-reduced-motion déjà déclaré ci-dessus ── */
