/* ==========================================================================
   CSS DÉDIÉ : TABLES.PHP - Tables de Multiplication (Pixel Art)
   Fichier : css/tables.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, #8b5cf6 0%, #6d28d9 100%);
    border-radius: 14px;
    padding: 10px 15px;
    color: white;
    text-align: center;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
  }

  .tables-header h2 {
    color: white !important;
    font-family: 'Fredoka', sans-serif;
    font-size: 22px;
    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.tables-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;
  }

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

  .side-config-subtitle {
    font-size: 11px;
    font-weight: 800;
    text-align: center;
    color: #2563eb;
    margin-bottom: 6px;
    font-family: 'Fredoka', sans-serif;
    line-height: 1.2;
  }

  /* Boutons de difficulté dans la colonne gauche */
  .side-diff-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .diff-btn {
    width: 100%;
    background: white;
    border: 2px solid #e9d5ff;
    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:hover {
    border-color: #a855f7;
    background: #faf5ff;
    transform: translateY(-1px);
  }

  .diff-btn .diff-title {
    font-size: 12px;
    font-weight: 800;
    color: #4c1d95;
    line-height: 1.2;
  }

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

  /* Couleurs actives par niveau */
  .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 {
    color: #ffffff;
  }
  .diff-btn.active .diff-desc {
    color: rgba(255, 255, 255, 0.95);
  }

  /* Grille des 9 tables dans la colonne gauche */
  .side-tables-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .tbl-btn {
    background: white;
    border: 2px solid #bfdbfe;
    color: #1e3a8a;
    padding: 6px 2px;
    border-radius: 9px;
    font-weight: 800;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fredoka', sans-serif;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
  }

  .tbl-btn:hover {
    background: #dbeafe;
    border-color: #2563eb;
  }

  .tbl-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-color: #1e40af;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35);
  }

  /* Barre de sélection des 12 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;
  }

  .drw-btn {
    background: white;
    border: 2px solid #cbd5e1;
    color: #334155;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 13px;
    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: #8b5cf6;
    color: #6d28d9;
    background: #f5f3ff;
  }

  .drw-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
    border-color: #5b21b6;
    box-shadow: 0 3px 8px rgba(139, 92, 246, 0.35);
  }

  /* Zone Palette de Couleurs */
  /* 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: 490px;
    width: 100%;
  }

  .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: background-color 0.25s ease, transform 0.1s ease;
    border-radius: 4px;
    position: relative;
    box-sizing: border-box;
    padding: 1px;
    overflow: hidden;
  }

  .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;
  }

  .pixel-cell:hover:not(.colored) {
    background: #f1f5f9;
    transform: scale(1.04);
    z-index: 2;
  }

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

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

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

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

  /* Palette sur le côté */
  .palette-side {
    flex: 0 1 210px;
    min-width: 150px;
    max-width: 230px;
    background: #fffbeb;
    border: 3px solid #fde047;
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.15);
    box-sizing: border-box;
  }

  .palette-title {
    font-weight: 800;
    color: #b45309;
    font-size: 13px;
    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: 8px;
    padding: 8px 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;
  }

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

  .color-btn.active {
    border-color: #1e293b !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4) !important;
    transform: scale(1.03);
  }

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

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

  .btn-action {
    padding: 9px 20px;
    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, #8b5cf6 0%, #6d28d9 100%);
    color: white;
  }

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

  .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 #ffde59;
    box-sizing: border-box;
  }

  .modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    color: #16a34a;
    margin: 0 0 6px 0;
  }

  .stars-row {
    font-size: 30px;
    margin: 6px 0;
    color: #fbbf24;
  }

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

  /* Formulaire prénom et Top 10 */
  .player-input {
    padding: 8px 12px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Fredoka', sans-serif;
    outline: none;
    width: 60%;
  }

  .player-input:focus {
    border-color: #3b82f6;
  }

  .top10-container {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px;
    margin-top: 12px;
  }

  .top10-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 15px;
    color: #b45309;
    margin: 0 0 8px 0;
    text-align: center;
  }

  .top10-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .top10-table th {
    background: #e2e8f0;
    color: #475569;
    padding: 5px 6px;
    font-weight: 800;
    text-align: left;
  }

  .top10-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
  }

  .top10-table tr.highlight-row {
    background: #fef08a;
  }

  @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: 6px;
      gap: 4px;
      font-size: 11px;
    }
    .color-swatch {
      width: 14px;
      height: 14px;
    }
  }
