/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Background global */
body {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #f1f5f9;
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
}

/* Titre */
h1 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Container principal */
.container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* Cartes (colonnes) */
.column {
    flex: 1 1 calc(33.333% - 20px); /* 3 par ligne */
    max-width: calc(33.333% - 20px);

    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 25px;

    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;

    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Hover effet */
.column:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

/* Titres des blocs */
.column h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #e2e8f0;
}

/* Bouton */
.column a {
    text-decoration: none;
    text-align: center;
    padding: 10px 15px;
    border-radius: 10px;

    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
    font-weight: 600;

    transition: 0.3s;
}

/* Hover bouton */
.column a:hover {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    transform: scale(1.05);
}

/* Responsive tablette */
@media (max-width: 900px) {
    .column {
        flex: 1 1 calc(50% - 20px);
        max-width: calc(50% - 20px);
    }
}

/* Responsive mobile */
@media (max-width: 600px) {
    .column {
        flex: 1 1 100%;
        max-width: 100%;
    }

    h1 {
        font-size: 2rem;
    }
}

.page {
    max-width: 1400px;
    margin: 0 auto;
}

.subtitle {
    text-align: center;
    color: #94a3b8;
    margin-bottom: 30px;
}

.panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    margin-bottom: 24px;
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: end;
}

.field {
    flex: 1 1 280px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    color: #cbd5e1;
}

input, select, button {
    border: none;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 1rem;
}

input, select {
    background: rgba(255,255,255,0.08);
    color: #fff;
    outline: none;
    border: 1px solid rgba(255,255,255,0.08);
}

/* Corrige le texte du dropdown */
select {
    color: #ffffff;
    background-color: rgba(255,255,255,0.08);
}

/* IMPORTANT : style des options */
select option {
    color: #000000;
    background-color: #ffffff;
}

input::placeholder {
    color: #94a3b8;
}

button {
    cursor: pointer;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
    font-weight: 700;
    transition: transform .2s ease, opacity .2s ease;
}

button:hover {
    transform: translateY(-2px);
    opacity: 0.95;
}

.result-box {
    margin-top: 20px;
    padding: 18px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255,255,255,0.08);
}

.result-box strong {
    color: #fff;
}

.table-wrap {
    margin-top: 22px;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    table-layout: fixed;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 16px;
    overflow: hidden;
}

th, td {
    border: 2px solid #475569;
    text-align: center;
    vertical-align: top;
    padding: 12px 8px;
}

thead th {
    background: #c4b5fd;
    font-size: 1.2rem;
    font-weight: 700;
}

.values-row td {
    background: #e2e8f0;
    font-size: 1.9rem;
    font-weight: 700;
}

.steps-row td {
    background: #f8fafc;
    min-height: 110px;
    height: 110px;
    font-size: 1.1rem;
    font-weight: 600;
}

.bits-row td {
    background: #ddd6fe;
    font-size: 2rem;
    font-weight: 800;
}

.step-line {
    display: block;
    line-height: 1.35;
}

.num-blue {
    color: #38bdf8;
    font-weight: 800;
}

.num-red {
    color: #ef4444;
    font-weight: 800;
}

.num-green {
    color: #22c55e;
    font-weight: 800;
}

.num-purple {
    color: #8b5cf6;
    font-weight: 800;
}

.num-orange {
    color: #f97316;
    font-weight: 800;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.legend span {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 0.95rem;
}

.error {
    margin-top: 18px;
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fecaca;
    padding: 14px 16px;
    border-radius: 12px;
    display: none;
}

.hint {
    color: #94a3b8;
    margin-top: 8px;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .values-row td,
    .bits-row td {
        font-size: 1.4rem;
    }

    .steps-row td {
        font-size: 0.95rem;
        height: 120px;
    }
}

.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.tab-btn {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.08);
}

.tab-btn.active {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.action-field {
    flex: 0 0 220px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.result-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-card-accent {
    background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(99,102,241,0.2));
}

.result-label {
    color: #94a3b8;
    font-size: 0.95rem;
}

.result-card strong {
    color: #fff;
    font-size: 1.1rem;
    word-break: break-word;
}

#truthTable th,
#stepsTable th {
    background: #c4b5fd;
}

#truthTable td,
#stepsTable td {
    background: #f8fafc;
}

@media (max-width: 900px) {
    .result-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 600px) {
    .tool-tabs {
        flex-direction: column;
    }

    .action-field {
        flex: 1 1 100%;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }
}

/* Bouton retour */
.back-button {
    position: absolute;
    top: 20px;
    left: 20px;

    padding: 10px 16px;
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);

    color: #fff;
    text-decoration: none;
    font-weight: 600;

    border: 1px solid rgba(255,255,255,0.1);

    transition: all 0.25s ease;
    z-index: 1000;
}

/* Hover */
.back-button:hover {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

/* ===== LOGIC BUILDER FIX ===== */
#builderSection {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
}

/* Textes */
#builderSection,
#builderSection label,
#builderSection span,
#builderSection td,
#builderSection th {
    color: #e2e8f0;
}

/* Inputs / selects / boutons */
#builderSection input,
#builderSection select,
#builderSection button {
    border-radius: 10px;
    font-size: 1rem;
}

/* Champs visibles */
#builderSection input,
#builderSection select {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    outline: none;
}

/* Placeholder */
#builderSection input::placeholder {
    color: #94a3b8;
}

/* Options du dropdown */
#builderSection select option {
    background: #0f172a;
    color: #e2e8f0;
}

/* Boutons */
#builderSection button {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: transform .2s ease, opacity .2s ease;
}

#builderSection button:hover {
    transform: translateY(-2px);
    opacity: 0.95;
}

/* Table builder uniquement */
#builderSection table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    table-layout: fixed;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
}

/* Cellules */
#builderSection th,
#builderSection td {
    border: 1px solid #334155;
    text-align: center;
    vertical-align: middle;
    padding: 10px 8px;
}

/* En-tête */
#builderSection thead th {
    background: #1e293b;
    color: #38bdf8;
    font-weight: 700;
}

/* Corps du tableau */
#builderSection tbody td {
    background: #0f172a;
    color: #e2e8f0;
}

/* Result box dans le builder */
#builderSection .result-box {
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.08);
}

/* Table wrapper */
#builderSection .table-wrap {
    overflow-x: auto;
}

/* Erreur */
#builderSection .error {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fecaca;
}

/* Selects dans le tableau du builder */
#builderSection td select {
    width: 100%;
    min-width: 90px;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    padding: 8px 10px;
}

/* Petit ajustement mobile */
@media (max-width: 768px) {
    #builderSection {
        padding: 14px;
    }

    #builderSection th,
    #builderSection td {
        padding: 8px 6px;
    }
}

.hero {
    width: 50%;
    max-height: 20vh;

    margin: 5vh auto; /* centre horizontal */
    padding: 20px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;

    /* === DESIGN TYPE CARD === */
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);

    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;

    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);

    text-align: center;
}

/* Titre */
.hero h3 {
    margin: 0;
    font-size: 1.5rem;
}

/* Bouton */
.hero a {
    padding: 8px 16px;

    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;

    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;

    transition: 0.2s ease;
}

/* Hover */
.hero a:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 242, 254, 0.4);
}