/* ============================================================
   BUDGETCLAIR
   RESPONSIVE GLOBAL
   Cible : desktop, tablette, iPhone / Android, iPhone SE 320+
   Aucun texte fonctionnel sous 14 px.
   ============================================================ */


/* ============================================================
   GARDE-FOUS GLOBAUX
   ============================================================ */

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

img,
svg,
canvas {
  max-width: 100%;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

input,
select,
textarea {
  max-width: 100%;
}


/* ============================================================
   TABLETTE / PETIT DESKTOP
   ============================================================ */

@media (max-width: 1320px) {
  .app-content-scroll {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-header-inner {
    width: calc(100% - 28px);
    column-gap: 18px;
  }

  .budgetclair-logo {
    width: 210px;
  }

  .budgetclair-tagline {
    gap: 7px;
    font-size: 16px;
    letter-spacing: 0.18em;
  }

  .header-navigation {
    gap: 1px;
  }

  .header-nav-link {
    padding-left: 9px;
    padding-right: 9px;
    font-size: 16px;
  }

  .header-nav-link .material-symbols-outlined {
    font-size: 20px;
  }

  .header-login-button,
  .header-register-button {
    padding-left: 12px;
    padding-right: 12px;
    font-size: 16px;
  }

  .page {
    width: calc(100% - 30px);
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* Accueil public */
  .welcome-page {
    width: min(1180px, calc(100% - 36px));
    height: auto;
    min-height: 100%;
    grid-template-rows: auto auto;
  }

  .welcome-intro {
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    gap: 42px;
  }

  .module-card {
    flex-basis: min(560px, calc(100vw - 90px));
    width: min(560px, calc(100vw - 90px));
  }
}


/* ============================================================
   PETITE TABLETTE
   ============================================================ */

@media (max-width: 1040px) {
  .app-shell {
    grid-template-rows:
      78px
      minmax(0, 1fr)
      54px;
  }

  .budgetclair-logo {
    width: 194px;
  }

  .budgetclair-tagline {
    gap: 6px;
    font-size: 16px;
    letter-spacing: 0.14em;
  }

  .app-header-inner {
    column-gap: 14px;
  }

  .header-nav-link {
    width: 48px;
    padding: 0;
    font-size: 0;
  }

  .header-nav-link::after {
    left: 8px;
    right: 8px;
  }

  .header-nav-link .material-symbols-outlined {
    font-size: 23px;
  }

  .header-register-button span:last-child {
    display: none;
  }

  .header-register-button {
    width: 46px;
    padding: 0;
  }

  .footer-copyright,
  .footer-copyright .footer-dot,
  .footer-links {
    font-size: 16px;
  }

  /* Accueil */
  .welcome-page {
    width: min(860px, calc(100% - 30px));
    padding-top: 24px;
  }

  .welcome-intro {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .welcome-intro-copy {
    max-width: none;
  }

  .welcome-intro h1 {
    font-size: clamp(44px, 7vw, 58px);
  }

  .welcome-promises {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .welcome-promises > div {
    grid-template-columns: 40px 1fr;
    padding: 14px;
    border: 1px solid rgba(133, 203, 228, 0.11);
    border-radius: 12px;
  }

  .welcome-promises .material-symbols-outlined {
    width: 38px;
    height: 38px;
  }

  .module-showcase-header {
    align-items: center;
  }
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-rows:
      64px
      minmax(0, 1fr);
  }

  .app-header {
    grid-row: 1;
  }

  .app-header-inner {
    width: calc(100% - 18px);
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
  }

  .budgetclair-brand {
    justify-items: start;
  }

  .budgetclair-logo {
    width: 165px;
  }

  .budgetclair-tagline,
  .header-separator,
  .header-navigation {
    display: none;
  }

  .app-header-actions {
    margin-left: auto;
    gap: 6px;
  }

  .header-login-button,
  .header-register-button {
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 9px;
  }

  .header-login-button span:last-child,
  .header-register-button span:last-child {
    display: none;
  }

  .header-login-button .material-symbols-outlined,
  .header-register-button .material-symbols-outlined {
    font-size: 20px;
  }

  .app-content-scroll {
    grid-row: 2;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
    scrollbar-gutter: auto;
  }

  .page {
    width: calc(100% - 22px);
    height: auto;
    min-height: 100%;
    padding: 16px 0 24px;
  }

  .hero {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .hero h1 {
    font-size: 25px;
  }

  .hero-copy,
  .eyebrow {
    font-size: 16px;
  }

  .desktop-add-button {
    display: none;
  }

  /* KPI génériques */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi-card {
    min-height: 90px;
    padding: 13px;
  }

  .kpi-card:nth-child(5) {
    grid-column: 1 / -1;
  }

  .kpi-label {
    font-size: 14px;
  }

  .kpi-value {
    font-size: 17px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .panel {
    padding: 15px;
  }

  .balance-grid {
    grid-template-columns: 1fr;
  }

  /* Footer desktop masqué sur téléphone */
  .app-footer {
    display: none;
  }

  /* ==========================================================
     ACCUEIL PUBLIC
     ========================================================== */

  .welcome-scroll {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .welcome-page {
    width: calc(100% - 22px);
    height: auto;
    min-height: 100%;
    margin: 0 auto;
    padding: 20px 0 30px;
    display: block;
  }

  .welcome-intro {
    display: block;
  }

  .welcome-eyebrow {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.35;
  }

  .welcome-eyebrow .material-symbols-outlined {
    font-size: 20px;
  }

  .welcome-intro h1 {
    font-size: clamp(34px, 10vw, 44px);
    line-height: 1.02;
    letter-spacing: -0.025em;
  }

  .welcome-lead {
    margin-top: 18px;
    font-size: 16px;
    line-height: 1.55;
  }

  .welcome-actions {
    margin-top: 20px;
  }

  .welcome-signup-reminder {
    font-size: 15px;
    line-height: 1.45;
  }

  .welcome-promises {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .welcome-promises > div {
    grid-template-columns: 42px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    padding: 13px 0;
    border: 0;
    border-bottom: 1px solid rgba(133, 203, 228, 0.11);
    border-radius: 0;
  }

  .welcome-promises .material-symbols-outlined {
    width: 40px;
    height: 40px;
  }

  .welcome-promises strong {
    font-size: 16px;
  }

  .welcome-promises small {
    font-size: 14px;
    line-height: 1.4;
  }

  .module-showcase {
    margin-top: 26px;
    padding-top: 20px;
    gap: 14px;
  }

  .module-showcase-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 10px;
  }

  .module-showcase-kicker {
    font-size: 14px;
  }

  .module-showcase h2 {
    font-size: 23px;
    line-height: 1.2;
  }

  .module-showcase-header p {
    grid-column: 1 / -1;
    font-size: 14px;
    line-height: 1.45;
  }

  .module-carousel-controls {
    gap: 7px;
  }

  .module-arrow {
    width: 42px;
    height: 42px;
  }

  .module-carousel {
    width: 100%;
    overflow: hidden;
    border-radius: 14px;
    mask-image: none;
  }

  .module-track {
    gap: 12px;
    padding: 2px 0 8px;
  }

  .module-card {
    flex: 0 0 calc(100vw - 34px);
    width: calc(100vw - 34px);
    min-height: 0;
    padding: 17px;
    gap: 12px;
    border-radius: 15px;
  }

  .module-card-head {
    gap: 11px;
  }

  .module-icon {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .module-card h3 {
    font-size: 21px;
  }

  .module-number,
  .module-purpose,
  .module-preview span,
  .module-preview small,
  .module-preview p,
  .module-preview em,
  .module-preview b {
    font-size: 14px;
  }

  .module-preview {
    padding: 13px;
    overflow: visible;
  }

  .preview-kpis,
  .overview-kpis {
    grid-template-columns: 1fr;
  }

  .preview-bars > div {
    grid-template-columns: minmax(78px, 0.8fr) minmax(80px, 1fr) auto;
    gap: 7px;
  }

  .preview-saving,
  .preview-assets,
  .preview-advice,
  .overview-bottom {
    grid-template-columns: 1fr;
  }

  .saving-ring {
    width: 112px;
    height: 112px;
  }

  .asset-ledger > div,
  .goal-row {
    gap: 12px;
  }

  /* ==========================================================
     PAGE BUDGET
     ========================================================== */

  .budget-page {
    padding-top: 14px;
  }

  .budget-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
  }

  .budget-heading h1 {
    font-size: 25px;
  }

  .budget-heading-text {
    font-size: 15px;
    line-height: 1.45;
  }

  .budget-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .budget-actions > * {
    width: 100%;
    min-width: 0;
  }

  .budget-secondary-action,
  .primary-action {
    min-height: 44px;
    height: auto;
    padding: 8px 10px;
    font-size: 14px;
  }

  .budget-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .budget-kpi {
    min-height: 86px;
    padding: 11px;
    gap: 9px;
  }

  .budget-kpi-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .budget-kpi-label,
  .budget-kpi-value {
    font-size: 14px;
  }

  .budget-global-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .budget-categories-panel,
  .table-wrapper,
  .data-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    max-width: none;
  }

  /* ==========================================================
     AUTHENTIFICATION
     ========================================================== */

  .auth-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 20px;
  }

  .auth-page,
  .auth-page-login {
    width: calc(100% - 20px);
    min-height: 100%;
    padding: 18px 0 24px;
    place-items: start stretch;
  }

  .auth-card {
    grid-template-columns: 1fr;
    border-radius: 14px;
  }

  .auth-form-panel,
  .auth-card-login .auth-form-panel {
    padding: 24px 18px 26px;
  }

  .auth-form-panel h1,
  .auth-card-login .auth-form-panel h1 {
    font-size: 30px;
    line-height: 1.08;
  }

  .auth-card-login .auth-form-panel h1 {
    margin-bottom: 22px;
  }

  .auth-intro {
    font-size: 15px;
  }

  .auth-name-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .auth-field,
  .auth-field input,
  .auth-consent,
  .auth-submit,
  .auth-secondary-button,
  .auth-login-note {
    font-size: 15px;
  }

  .auth-field input {
    min-height: 48px;
  }

  .auth-benefits {
    padding: 24px 18px;
    border-left: 0;
    border-top: 1px solid rgba(111, 203, 244, 0.22);
  }

  .auth-benefits h2 {
    font-size: 21px;
  }

  /* ==========================================================
     PLACEHOLDERS / SECTIONS
     ========================================================== */

  .section-page {
    height: auto;
    min-height: 100%;
    align-items: flex-start;
    padding-top: 18px;
  }

  .section-placeholder {
    width: 100%;
    min-height: 0;
    flex-direction: column;
    gap: 18px;
    padding: 26px 18px;
    text-align: center;
  }

  .section-placeholder-icon {
    width: 68px;
    height: 68px;
    flex-basis: 68px;
  }

  .section-placeholder h1 {
    font-size: 27px;
  }

  .section-placeholder p,
  .section-placeholder-kicker,
  .section-coming-soon {
    font-size: 15px;
  }

  /* ==========================================================
     NAVIGATION MOBILE
     ========================================================== */

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;

    height: calc(68px + env(safe-area-inset-bottom));
    padding:
      0 4px
      env(safe-area-inset-bottom);

    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;

    border-top: 1px solid rgba(111, 203, 244, 0.34);
    background:
      linear-gradient(180deg, rgba(0, 43, 65, 0.98), rgba(0, 27, 42, 0.995));

    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.48);
  }

  .mobile-nav-item {
    position: relative;
    min-width: 0;
    height: 68px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;

    padding: 5px 2px;
    border: 0;
    background: transparent;

    color: #91aab5;
    text-decoration: none;

    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;

    cursor: pointer;
  }

  .mobile-nav-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 2px;
    background: transparent;
  }

  .mobile-nav-item .material-symbols-outlined {
    font-size: 22px;
  }

  .mobile-nav-item.active {
    color: #a8e84f;
  }

  .mobile-nav-item.active::before {
    background: #a8e84f;
    box-shadow: 0 0 8px rgba(168, 232, 79, 0.45);
  }

  .mobile-nav-more {
    position: relative;
    min-width: 0;
  }

  .mobile-nav-more > summary {
    list-style: none;
  }

  .mobile-nav-more > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-nav-more-menu {
    position: absolute;
    right: 4px;
    bottom: calc(100% + 10px);
    width: min(210px, calc(100vw - 18px));
    overflow: hidden;

    border: 1px solid rgba(111, 203, 244, 0.28);
    border-radius: 12px;

    background: rgba(0, 35, 53, 0.99);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
  }

  .mobile-nav-more-menu a {
    min-height: 50px;
    padding: 0 15px;

    display: flex;
    align-items: center;
    gap: 10px;

    color: #c7dae2;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
  }

  .mobile-nav-more-menu a + a {
    border-top: 1px solid rgba(111, 203, 244, 0.12);
  }

  .mobile-nav-more-menu a.active {
    color: #a8e84f;
    background: rgba(168, 232, 79, 0.06);
  }
}


/* ============================================================
   TÉLÉPHONES 430 PX ET MOINS
   iPhone 14/15/16 standard et similaires
   ============================================================ */

@media (max-width: 430px) {
  .app-header-inner {
    width: calc(100% - 14px);
  }

  .budgetclair-logo {
    width: 154px;
  }

  .page,
  .welcome-page {
    width: calc(100% - 16px);
  }

  .hero h1 {
    font-size: 23px;
  }

  .module-card {
    flex-basis: calc(100vw - 24px);
    width: calc(100vw - 24px);
    padding: 15px;
  }

  .module-showcase-header {
    grid-template-columns: 1fr;
  }

  .module-carousel-controls {
    justify-self: start;
  }

  .preview-bars > div {
    grid-template-columns: 1fr auto;
  }

  .preview-bars i {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .preview-bars em {
    grid-column: 2;
    grid-row: 1;
  }

  .budget-actions {
    grid-template-columns: 1fr;
  }

  .auth-page,
  .auth-page-login {
    width: calc(100% - 14px);
  }

  .auth-form-panel,
  .auth-card-login .auth-form-panel {
    padding-left: 15px;
    padding-right: 15px;
  }
}


/* ============================================================
   iPHONE SE / PETITS MOBILES
   375 PX ET MOINS
   ============================================================ */

@media (max-width: 375px) {
  .budgetclair-logo {
    width: 142px;
  }

  .header-login-button,
  .header-register-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .welcome-page {
    padding-top: 16px;
  }

  .welcome-intro h1 {
    font-size: 32px;
  }

  .welcome-lead {
    font-size: 15px;
  }

  .module-showcase h2 {
    font-size: 21px;
  }

  .module-card {
    flex-basis: calc(100vw - 20px);
    width: calc(100vw - 20px);
    padding: 14px;
  }

  .module-preview {
    padding: 11px;
  }

  .budget-kpi-grid {
    grid-template-columns: 1fr;
  }

  .budget-kpi {
    min-height: 74px;
  }

  .auth-form-panel h1,
  .auth-card-login .auth-form-panel h1 {
    font-size: 27px;
  }

  .auth-submit {
    min-height: 48px;
  }

  .mobile-nav {
    padding-left: 1px;
    padding-right: 1px;
  }

  .mobile-nav-item {
    font-size: 11px;
  }

  .mobile-nav-item .material-symbols-outlined {
    font-size: 21px;
  }
}


/* ============================================================
   TRÈS PETIT MOBILE
   Jusqu'à 320 PX pour couvrir ancien iPhone SE
   ============================================================ */

@media (max-width: 340px) {
  .app-header-inner {
    width: calc(100% - 10px);
  }

  .budgetclair-logo {
    width: 128px;
  }

  .app-header-actions {
    gap: 4px;
  }

  .header-login-button,
  .header-register-button {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .welcome-intro h1 {
    font-size: 29px;
  }

  .welcome-eyebrow {
    font-size: 14px;
  }

  .module-card h3 {
    font-size: 19px;
  }

  .auth-form-panel,
  .auth-card-login .auth-form-panel {
    padding: 20px 12px 24px;
  }

  .auth-form-panel h1,
  .auth-card-login .auth-form-panel h1 {
    font-size: 25px;
  }

  .mobile-nav-item {
    font-size: 10px;
  }

  .mobile-nav-item .material-symbols-outlined {
    font-size: 20px;
  }
}


/* ============================================================
   MODE PAYSAGE BAS
   ============================================================ */

@media (max-height: 520px) and (max-width: 900px) {
  .app-shell {
    grid-template-rows:
      56px
      minmax(0, 1fr);
  }

  .budgetclair-logo {
    width: 145px;
  }

  .app-content-scroll {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .mobile-nav {
    height: calc(58px + env(safe-area-inset-bottom));
  }

  .mobile-nav-item {
    height: 58px;
  }
}


/* ============================================================
   PRÉFÉRENCE ACCESSIBILITÉ : MOUVEMENTS RÉDUITS
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
