/* ====== PLAN DE TABLE ====== */

/* Settings card */
.pdt-settings-card {
    background: var(--color-card, #fff);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    position: sticky;
    top: 16px;
    z-index: 10;
}

.pdt-settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-end;
}

.pdt-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}

.pdt-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
}

.pdt-input {
    width: 100px;
}

.pdt-dropdown {
    min-width: 160px;
}

.pdt-mariage-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fdf6e3;
    border: 1px solid #d4a843;
    border-radius: 8px;
    padding: 6px 12px;
    color: #b8860b;
    font-weight: 500;
    width: fit-content;
}

.pdt-mariage-icon {
    font-size: 16px;
    color: #d4a843;
}

/* Wrapper scrollable autour de la salle */
.pdt-salle-wrapper {
    overflow: auto;
    width: 100%;
    border: 2px dashed #e0d5c5;
    border-radius: 12px;
    background: #fafaf8;
}

/* Salle en état drop-target (shape survolée) */
.pdt-salle-wrapper.pdt-salle-drop-target {
    border-color: #d4a843;
    background: #fdf9f0;
}

/* Salle virtuelle */
.pdt-salle {
    position: relative;
    width: 100%;
    min-width: 1250px;
    height: 1200px;
    overflow: hidden;
}

/* Boutons de redimensionnement de la salle */
.pdt-salle-resize-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.pdt-salle-resize-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    background: #f5f5f5;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    color: #666;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pdt-salle-resize-btn:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #c0392b;
}

.pdt-salle-resize-btn--grow:hover {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.pdt-salle-resize-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f5f5f5;
    border-color: #ddd;
    color: #aaa;
}

/* Palette de formes */
.pdt-settings-divider {
    width: 1px;
    background: #e8e0d5;
    align-self: stretch;
    margin: 0 4px;
}

.pdt-field-palette {
    flex: 1;
}

.pdt-shapes-palette {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.pdt-shape-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: grab;
    user-select: none;
    opacity: 0.85;
    transition: opacity 0.15s, transform 0.1s;
}

.pdt-shape-item:hover {
    opacity: 1;
    transform: translateY(-2px);
}

.pdt-shape-item:active {
    cursor: grabbing;
}

.pdt-shape-preview {
    background: #fff;
    border: 2px solid #d4a843;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.pdt-shape-preview-ronde {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.pdt-shape-preview-carre {
    width: 38px;
    height: 38px;
    border-radius: 4px;
}

.pdt-shape-preview-rectangle {
    width: 54px;
    height: 34px;
    border-radius: 4px;
}

.pdt-shape-label {
    font-size: 0.7rem;
    color: #888;
    font-weight: 500;
}

/* ── Table cards (conteneur transparent, chaises + forme en absolu) ── */
.pdt-table-card {
    position: absolute;
    cursor: move;
    user-select: none;
    z-index: 5;
}

.pdt-table-card.pdt-table-moving {
    z-index: 20;
}

/* Tailles du wrapper (espace total incluant les chaises) */
.pdt-table-ronde,
.pdt-table-carre {
    width: 290px;
    height: 290px;
}

.pdt-table-rectangle {
    width: 300px;
    height: 290px;
}

/* ── Forme centrale de la table ── */
.pdt-table-shape {
    position: absolute;
    background: #fff;
    border: 2.5px solid #d4a843;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 2;
    transition: box-shadow 0.15s;
}

.pdt-table-card:hover .pdt-table-shape {
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.18);
}

.pdt-table-card.pdt-table-moving .pdt-table-shape {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* Position et taille de la forme selon le type */
.pdt-table-ronde .pdt-table-shape {
    width: 135px;
    height: 135px;
    border-radius: 50%;
    left: 78px;
    top: 78px;
}

.pdt-table-carre .pdt-table-shape {
    width: 135px;
    height: 135px;
    border-radius: 6px;
    left: 78px;
    top: 78px;
}

.pdt-table-rectangle .pdt-table-shape {
    width: 210px;
    height: 112px;
    border-radius: 6px;
    left: 45px;
    top: 89px;
}

/* Table des mariés */
.pdt-table-mariage .pdt-table-shape {
    border-color: #c0392b;
    border-width: 3px;
}

/* Nom de la table centré dans la forme */
.pdt-table-numero {
    font-size: 1.3rem;
    font-weight: 700;
    color: #b8860b;
    text-align: center;
    line-height: 1.2;
    padding: 4px;
    word-break: break-word;
    max-width: 90%;
    pointer-events: none;
    user-select: none;
}

.pdt-table-shape {
    cursor: move;
}

.pdt-table-mariage .pdt-table-numero {
    color: #c0392b;
}

/* Zone poubelle (apparaît pendant le déplacement d'une table) */
#pdt-trash-zone {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    height: 60px;
    background: #fee2e2;
    border: 2px dashed #f87171;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.88rem;
    transition: bottom 0.22s ease, background 0.15s, border-color 0.15s, color 0.15s;
    z-index: 1000;
    pointer-events: none;
    user-select: none;
}

#pdt-trash-zone.pdt-trash-visible {
    bottom: 24px;
}

#pdt-trash-zone.pdt-trash-hot {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.pdt-trash-icon {
    font-size: 22px;
}

/* Input inline pour renommer la table */
.pdt-table-name-input {
    font-size: 1.3rem;
    font-weight: 700;
    color: #b8860b;
    border: none;
    border-bottom: 2px solid #d4a843;
    background: transparent;
    outline: none;
    width: 80%;
    text-align: center;
    padding: 0;
    font-family: inherit;
    cursor: text;
}

.pdt-table-mariage .pdt-table-name-input {
    color: #c0392b;
    border-bottom-color: #c0392b;
}

/* ── Chaises ── */
.pdt-chair-slot {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    z-index: 3;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    overflow: hidden;
}

.pdt-chair-empty {
    border: 2px dashed #ccc;
    background: #f5f5f5;
    cursor: pointer;
}

.pdt-chair-empty:hover {
    border-color: #b8a070;
    background: #faf0d8;
}

.pdt-chair-occupied {
    border: 2px solid #d4a843;
    background: #fdf6e3;
    cursor: grab;
}

.pdt-chair-occupied:active {
    cursor: grabbing;
}

.pdt-dragging-chair {
    opacity: 0.35 !important;
}

/* Chaise cible d'un échange (style distinct du drop vide) */
.pdt-chair-slot.pdt-chair-swap-target {
    border-color: #a855f7 !important;
    border-style: solid !important;
    background: #f3e8ff !important;
    transform: scale(1.12);
}

/* Nom de l'invité dans la chaise */
.pdt-chair-name {
    font-size: 0.62rem;
    font-weight: 600;
    color: #5a4a2a;
    text-align: center;
    line-height: 1.2;
    max-width: 56px;
    overflow: hidden;
    word-break: break-word;
    display: block;
    padding: 2px;
    pointer-events: none;
}

/* Overlay × au hover sur chaise occupée */
.pdt-chair-unassign {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(192, 57, 43, 0.82);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
    line-height: 1;
}

.pdt-chair-occupied:hover .pdt-chair-unassign {
    opacity: 1;
}

/* Chaise en état drop-target */
.pdt-chair-slot.pdt-chair-drop-target {
    border-color: #22c55e !important;
    border-style: solid !important;
    background: #dcfce7 !important;
    transform: scale(1.12);
}

/* Body layout */
.pdt-body {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.pdt-left-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.pdt-main-area {
    min-height: 400px;
}

/* Guest panel */
.pdt-guest-panel {
    width: 20%;
    min-width: 200px;
    background: var(--color-card, #fff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    overflow: hidden;
    flex-shrink: 0;
    position: sticky;
    top: calc(50vh - 200px);
}

.pdt-guest-list-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: #d4a843;
    color: #fff;
}

.pdt-guest-list-icon {
    font-size: 18px;
}

.pdt-guest-list-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.pdt-guest-list-body {
    max-height: 65vh;
    overflow-y: auto;
    padding: 8px 0;
}

.pdt-guest-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: grab;
    transition: background 0.15s, opacity 0.15s;
    user-select: none;
}

.pdt-guest-item:active {
    cursor: grabbing;
}

.pdt-guest-item.pdt-dragging {
    opacity: 0.35;
    background: #fdf6e3;
}

.pdt-guest-item:hover {
    background: #fdf6e3;
}

.pdt-guest-icon {
    font-size: 16px;
    color: #d4a843;
    flex-shrink: 0;
}

.pdt-guest-name {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Bouton "Affinités" dans la settings card ── */
.pdt-rel-open-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: #fdf6e3;
    border: 1.5px solid #d4a843;
    border-radius: 8px;
    color: #b8860b;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.pdt-rel-open-btn:hover {
    background: #f5e8c0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ── Panel latéral Relations ── */
.pdt-rel-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.14);
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdt-rel-panel.pdt-rel-panel-open {
    transform: translateX(0);
}

.pdt-rel-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #d4a843;
    color: #fff;
    flex-shrink: 0;
}

.pdt-rel-panel-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdt-rel-panel-title {
    font-weight: 700;
    font-size: 0.92rem;
}

.pdt-rel-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    font-family: inherit;
}

.pdt-rel-close-btn:hover {
    opacity: 1;
}

.pdt-rel-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Formulaire d'ajout */
.pdt-rel-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-bottom: 1px solid #eee;
}

/* Tag picker */
.pdt-rel-tag-picker {
    position: relative;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    background: #fafaf8;
    min-height: 40px;
    padding: 6px 8px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    transition: border-color 0.15s;
    cursor: text;
}

.pdt-rel-tag-picker:focus-within {
    border-color: #d4a843;
}

.pdt-rel-tags {
    display: contents;
}

.pdt-rel-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fdf6e3;
    border: 1px solid #d4a843;
    border-radius: 20px;
    padding: 2px 8px 2px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #7a5c00;
    white-space: nowrap;
}

.pdt-rel-tag-remove {
    background: none;
    border: none;
    color: #b8860b;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-family: inherit;
    opacity: 0.7;
}

.pdt-rel-tag-remove:hover {
    opacity: 1;
    color: #dc2626;
}

.pdt-rel-search {
    flex: 1;
    min-width: 100px;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.85rem;
    font-family: inherit;
    color: #333;
    padding: 2px 4px;
}

.pdt-rel-search::placeholder {
    color: #bbb;
}

/* Dropdown */
.pdt-rel-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #d4a843;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 400;
    max-height: 200px;
    overflow-y: auto;
}

.pdt-rel-dropdown-item {
    padding: 9px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    color: #333;
    transition: background 0.1s;
}

.pdt-rel-dropdown-item:hover {
    background: #fdf6e3;
    color: #7a5c00;
}

.pdt-rel-dropdown-empty {
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #aaa;
    text-align: center;
}

/* Boutons type lié / incompatible */
.pdt-rel-type-group {
    display: flex;
    gap: 8px;
}

.pdt-rel-type-btn {
    flex: 1;
    padding: 7px 0;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    color: #666;
}

.pdt-rel-type-btn.pdt-rel-type-active[data-type="lié"] {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.pdt-rel-type-btn.pdt-rel-type-active[data-type="incompatible"] {
    background: #fee2e2;
    border-color: #f87171;
    color: #991b1b;
}

/* Conteneur boutons du formulaire (Annuler + Ajouter/Modifier) */
.pdt-rel-actions {
    display: flex;
    gap: 8px;
}

/* Bouton Annuler */
.pdt-rel-cancel-btn {
    flex: 0 0 auto;
    padding: 9px 14px;
    background: #f5f5f5;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    color: #666;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pdt-rel-cancel-btn:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #c0392b;
}

/* Bouton Ajouter */
.pdt-rel-add-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px;
    background: #d4a843;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.pdt-rel-add-btn:hover:not(:disabled) {
    background: #b8930f;
}

.pdt-rel-add-btn:disabled {
    background: #c8bfaa;
    cursor: not-allowed;
    opacity: 0.65;
}

/* Liste des relations */
.pdt-rel-list {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdt-rel-empty {
    color: #999;
    font-size: 0.85rem;
    text-align: center;
    margin: 0;
    padding: 8px 0;
}

.pdt-rel-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 4px 0 0;
    padding: 0;
}

.pdt-rel-nom-input {
    width: 100%;
    border: 1.5px solid #e0d5c0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.88rem;
    background: #fff;
    color: #444;
}

.pdt-rel-nom-input:focus {
    outline: none;
    border-color: #d4a843;
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.15);
}

.pdt-rel-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pdt-rel-members {
    font-size: 0.75rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdt-rel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fafaf8;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.pdt-rel-item:hover {
    background: #fdf6e3;
    border-color: #d4a843;
}

.pdt-rel-badge {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.pdt-rel-names {
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdt-rel-delete-group {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    border-radius: 6px;
    color: #e57373;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pdt-rel-delete-group:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #c0392b;
}

/* ── Bouton rotation (dans la forme de la table) ── */
.pdt-rotate-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid rgba(212, 168, 67, 0.5);
    background: rgba(255, 255, 255, 0.85);
    color: #b8860b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    padding: 0;
    font-family: inherit;
}

.pdt-table-card:hover .pdt-rotate-btn {
    opacity: 1;
}

.pdt-rotate-btn:hover {
    background: #fdf6e3;
    border-color: #d4a843;
}

.pdt-rotate-btn .material-symbols-outlined {
    font-size: 14px;
}

/* ── Bouton impression ── */
#pdt-print-btn {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #d4a843;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(212, 168, 67, 0.35);
    transition: background 0.15s, box-shadow 0.15s;
}

#pdt-print-btn:hover {
    background: #b8930f;
    box-shadow: 0 4px 14px rgba(212, 168, 67, 0.45);
}

/* ── Règles d'impression ── */
@media print {
    @page {
        size: A4 landscape;
        margin: 1cm;
    }

    /* Cacher tout sauf la salle */
    .sidebar,
    .page-title,
    .pdt-settings-card,
    .pdt-guest-panel,
    .pdt-salle-resize-controls,
    #pdt-print-btn,
    #pdt-trash-zone,
    #pdt-toast,
    #pdt-rel-panel {
        display: none !important;
    }

    body {
        background: #fff !important;
    }

    /* Supprimer la marge du sidebar */
    .page-display {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .pdt-body {
        display: block;
        gap: 0;
    }

    .pdt-left-col {
        width: 100%;
        gap: 0;
    }

    /* Révéler tout le contenu de la salle */
    .pdt-salle-wrapper {
        overflow: visible !important;
        border: none !important;
        background: #fff !important;
    }

    .pdt-salle {
        overflow: visible !important;
    }
}

/* ── Toast notifications ── */
#pdt-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    max-width: 420px;
    text-align: center;
    pointer-events: none;
    animation: pdt-toast-in 0.2s ease;
}

@keyframes pdt-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.pdt-toast-error {
    background: #fee2e2;
    border: 1.5px solid #f87171;
    color: #991b1b;
}

.pdt-toast-info {
    background: #fdf6e3;
    border: 1.5px solid #d4a843;
    color: #7a5c00;
}
