/* ==========================================================================
   CSS DÉDIÉ : ADDITIONS.PHP - Pixel Art des Additions
   Fichier : css/additions.css
   École de l'Enfant-Jésus - Morlanwelz
   ========================================================================== */

.tables-container {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 20px 0;
    background: #ffffff;
    border-radius: 20px;
    padding: 15px 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.05);
    border: none;
    font-family: 'Nunito', sans-serif;
  }

  .tables-header {
    background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 50%, #10b981 100%);
    border-radius: 16px;
    padding: 12px 18px;
    color: white;
    text-align: center;
    margin-bottom: 14px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
  }

  .tables-header h2 {
    color: white !important;
    font-family: 'Fredoka', sans-serif;
    font-size: 23px;
    margin: 0 0 4px 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
  }

  .tables-header p {
    font-size: 14px;
    margin: 0;
    opacity: 0.95;
  }

  /* Panneau de configuration sur la gauche de la grille */
  .config-side-left {
    flex: 0 1 205px;
    min-width: 175px;
    max-width: 225px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
  }

  .side-config-box {
    border-radius: 16px;
    padding: 10px 11px;
    box-sizing: border-box;
    box-shadow: 0 3px 8px rgba(0,0,0,0.03);
  }

  .side-config-box.diff-box {
    background: #fdf4ff;
    border: 2px solid #d8b4fe;
  }

  .side-config-box.tranche-box {
    background: #eff6ff;
    border: 2px solid #93c5fd;
  }

  .side-config-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 6px;
    text-align: center;
  }

  .diff-box .side-config-title {
    color: #6b21a8;
  }

  .tranche-box .side-config-title {
    color: #1e40af;
  }

  .side-diff-buttons, .side-tranche-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .diff-btn, .tranche-btn {
    width: 100%;
    background: white;
    border-radius: 12px;
    padding: 7px 9px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fredoka', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
    box-sizing: border-box;
  }

  .diff-btn {
    border: 2px solid #e9d5ff;
  }

  .diff-btn:hover {
    border-color: #a855f7;
    background: #faf5ff;
    transform: translateY(-1px);
  }

  .diff-btn .diff-title, .tranche-btn .tranche-title {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
  }

  .diff-btn .diff-title {
    color: #4c1d95;
  }

  .diff-btn .diff-desc, .tranche-btn .tranche-desc {
    font-size: 9.5px;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    line-height: 1.15;
  }

  .diff-btn .diff-desc {
    color: #6b7280;
  }

  /* Couleurs actives par niveau de difficulté */
  .diff-btn-easy.active {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    border-color: #065f46;
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.35);
  }
  .diff-btn-normal.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-color: #1e40af;
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.35);
  }
  .diff-btn-hard.active {
    background: linear-gradient(135deg, #ea580c 0%, #9a3412 100%);
    border-color: #7c2d12;
    box-shadow: 0 3px 8px rgba(234, 88, 12, 0.35);
  }

  .diff-btn.active .diff-title, .tranche-btn.active .tranche-title {
    color: #ffffff;
  }
  .diff-btn.active .diff-desc, .tranche-btn.active .tranche-desc {
    color: rgba(255, 255, 255, 0.95);
  }

  /* Boutons de tranche d'additions */
  .tranche-btn {
    border: 2px solid #bfdbfe;
  }

  .tranche-btn:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
    transform: translateY(-1px);
  }

  .tranche-btn .tranche-title {
    color: #1e40af;
  }

  .tranche-btn .tranche-desc {
    color: #64748b;
  }

  .tranche-btn-20.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: #047857;
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.35);
  }

  .tranche-btn-50.active {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border-color: #075985;
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.35);
  }

  .tranche-btn-100.active {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    border-color: #5b21b6;
    box-shadow: 0 3px 8px rgba(124, 58, 237, 0.35);
  }

  /* Barre de sélection des dessins */
  .drawing-selector-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 14px;
  }

  .drawing-selector-title {
    width: 100%;
    text-align: center;
    font-weight: 800;
    color: #334155;
    font-size: 14px;
    margin-bottom: 4px;
    font-family: 'Fredoka', sans-serif;
  }

  .drw-btn {
    background: white;
    border: 2px solid #cbd5e1;
    color: #334155;
    padding: 6px 11px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fredoka', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .drw-btn:hover {
    border-color: #0284c7;
    color: #0369a1;
    background: #f0f9ff;
  }

  .drw-btn.active {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: white;
    border-color: #075985;
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.35);
  }

  /* Barre d'informations : Score & Progression */
  .game-info-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 10px 16px;
    margin-bottom: 14px;
  }

  .score-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 15px;
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.3);
    font-family: 'Fredoka', sans-serif;
    transition: transform 0.2s ease, background-color 0.2s ease;
    user-select: none;
  }

  .score-badge.gain {
    animation: scoreGain 0.4s ease;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  }

  .score-badge.loss {
    animation: scoreLoss 0.4s ease;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  }

  @keyframes scoreGain {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
  }

  @keyframes scoreLoss {
    0%, 100% { transform: translateX(0); }
    25%, 75% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
  }

  .progress-info {
    flex: 1 1 240px;
  }

  .progress-container {
    width: 100%;
    background: #e2e8f0;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    position: relative;
  }

  .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    width: 0%;
    transition: width 0.3s ease;
  }

  .progress-text {
    font-size: 13px;
    font-weight: 800;
    color: #475569;
    margin-bottom: 4px;
  }

  /* Zone de jeu principale : Grille & Palette côte à côte */
  .game-play-area {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 14px;
  }

  .grid-wrapper {
    flex: 1 1 320px;
    max-width: 500px;
    width: 100%;
  }

  /* Bandeau Loupe de calcul */
  .calc-preview-bar {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 12px;
    padding: 8px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    border: 2px solid #38bdf8;
    transition: all 0.2s ease;
  }

  .calc-preview-bar.active-highlight {
    border-color: #facc15;
    background: linear-gradient(135deg, #0369a1 0%, #0c4a6e 100%);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  }

  .preview-icon {
    font-size: 18px;
    flex-shrink: 0;
  }

  .preview-text {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 14.5px;
    font-weight: 700;
    text-align: center;
    color: #e2e8f0;
  }

  .preview-text strong.calc-highlight {
    font-size: 19px;
    font-weight: 800;
    color: #fef08a;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  }

  .pixel-grid {
    display: grid;
    gap: 2px;
    background: #cbd5e1;
    padding: 6px;
    border-radius: 16px;
    border: 3px solid #94a3b8;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  }

  .pixel-cell {
    aspect-ratio: 1 / 1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.15s ease;
    border-radius: 5px;
    position: relative;
    box-sizing: border-box;
    padding: 1px;
    overflow: visible;
    z-index: 1;
  }

  /* Structure sur 2 lignes pour lisibilité maximale des calculs */
  .formula-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.05;
    width: 100%;
    pointer-events: none;
    font-family: 'Fredoka', 'Nunito', sans-serif;
  }

  .formula-top {
    font-size: clamp(10.5px, 1.9vw, 13.5px);
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    letter-spacing: -0.2px;
  }

  .formula-bot {
    font-size: clamp(9.5px, 1.7vw, 12px);
    font-weight: 800;
    color: #2563eb;
    white-space: nowrap;
    letter-spacing: -0.2px;
  }

  .formula-box.long-formula .formula-top {
    font-size: clamp(9px, 1.5vw, 11.5px);
  }
  .formula-box.long-formula .formula-bot {
    font-size: clamp(8.5px, 1.4vw, 10.5px);
  }

  /* Ancien style fallback pour 1 ligne si besoin */
  .formula-text {
    font-size: clamp(9.5px, 1.8vw, 13px);
    line-height: 1;
    white-space: nowrap;
    text-align: center;
    letter-spacing: -0.2px;
    display: inline-block;
  }

  .formula-text.long-formula {
    font-size: clamp(8.2px, 1.5vw, 11.5px);
    letter-spacing: -0.35px;
  }

  /* Effet Loupe / Zoom au survol ou focus */
  .pixel-cell:hover:not(.colored),
  .pixel-cell.active-focus:not(.colored) {
    background: #ffffff;
    transform: scale(1.42);
    z-index: 50;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    border: 2px solid #0284c7;
    border-radius: 8px;
  }

  .pixel-cell:hover:not(.colored) .formula-top,
  .pixel-cell.active-focus:not(.colored) .formula-top {
    color: #0369a1;
  }

  .pixel-cell:hover:not(.colored) .formula-bot,
  .pixel-cell.active-focus:not(.colored) .formula-bot {
    color: #d97706;
  }

  .pixel-cell.colored {
    cursor: default;
    border: none;
  }

  .pixel-cell.colored .formula-box,
  .pixel-cell.colored .formula-text {
    display: none;
  }

  .pixel-cell.wrong-paint {
    animation: shakeCell 0.4s ease;
  }

  .pixel-cell.hint-pulse {
    animation: hintGlow 1.2s infinite ease-in-out;
    z-index: 3;
  }

  @keyframes shakeCell {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-3px); }
    40%, 80% { transform: translateX(3px); }
  }

  @keyframes hintGlow {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 12px 3px rgba(16, 185, 129, 0.9); }
  }

  /* Palette sur le côté */
  .palette-side {
    flex: 0 1 230px;
    min-width: 170px;
    max-width: 250px;
    background: #f0fdf4;
    border: 3px solid #86efac;
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.12);
    box-sizing: border-box;
  }

  .palette-title {
    font-weight: 800;
    color: #166534;
    font-size: 13.5px;
    margin-bottom: 10px;
    text-align: center;
    font-family: 'Fredoka', sans-serif;
  }

  .palette-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .color-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 12px;
    border: 3px solid transparent;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    background: white;
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
  }

  .color-btn:hover {
    transform: translateY(-2px);
  }

  .color-btn.active {
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.35) !important;
    transform: scale(1.02);
  }

  .color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
    display: inline-block;
  }

  .color-text-box {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    flex: 1;
  }

  .color-main-val {
    font-size: 15px;
    color: #0f172a;
    font-weight: 900;
  }

  .color-sub-info {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
  }

  .color-completed-badge {
    font-size: 12px;
    color: #16a34a;
    font-weight: 800;
  }

  /* Actions et modales */
  .actions-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
  }

  .btn-action {
    padding: 9px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    border: none;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  }

  .btn-restart {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: white;
  }

  .btn-hint {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
  }

  .btn-leaderboard {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
  }

  .btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
  }

  .modal-close-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    background: #f1f5f9;
    border: 2px solid #cbd5e1;
    color: #475569;
    font-size: 16px;
    font-weight: 900;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    z-index: 10;
  }

  .modal-close-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
    transform: scale(1.1);
  }

  .modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 15px;
    box-sizing: border-box;
  }

  .modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .modal-content {
    background: white;
    border-radius: 24px;
    padding: 22px 18px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    border: 4px solid #38bdf8;
    box-sizing: border-box;
  }

  .modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    color: #0284c7;
    margin: 0 0 8px 0;
  }

  .stars-row {
    font-size: 32px;
    margin-bottom: 8px;
  }

  .modal-message {
    font-size: 15px;
    color: #475569;
    margin-bottom: 15px;
  }

  .player-input {
    padding: 8px 12px;
    border-radius: 12px;
    border: 2px solid #93c5fd;
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    width: 180px;
  }

  .leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13px;
  }

  .leaderboard-table th {
    background: #e0f2fe;
    color: #0369a1;
    padding: 6px;
    border-radius: 6px;
  }

  .leaderboard-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
  }

  @media screen and (max-width: 820px) {
    .config-side-left {
      flex: 1 1 100%;
      max-width: 100%;
      flex-direction: row;
      flex-wrap: wrap;
    }
    .side-config-box {
      flex: 1 1 200px;
    }
  }

  @media screen and (max-width: 600px) {
    .tables-container { padding: 10px; }
    .config-side-left {
      flex: 1 1 100%;
      max-width: 100%;
      flex-direction: column;
    }
    .side-config-box {
      flex: 1 1 auto;
      width: 100%;
    }
    .game-play-area {
      flex-direction: row;
      flex-wrap: wrap;
      gap: 8px;
    }
    .grid-wrapper {
      flex: 1 1 65%;
    }
    .palette-side {
      flex: 0 0 32%;
      min-width: 95px;
      padding: 6px;
    }
    .palette-title {
      font-size: 11px;
      margin-bottom: 6px;
    }
    .color-btn {
      padding: 5px;
      gap: 4px;
      font-size: 11px;
    }
    .color-swatch {
      width: 14px;
      height: 14px;
    }
    .color-main-val {
      font-size: 13px;
    }
    .color-sub-info {
      font-size: 9.5px;
    }
  }
