/* ============================================================================
   STYLES SPÉCIFIQUES AU CANVAS / PLAN
   ============================================================================ */

/* Layout du plan : 3 colonnes */
.plan-layout {
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* ============================================================================
   PANNEAU OUTILS (gauche)
   ============================================================================ */

.tools-panel {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-light);
    padding: 12px;
    overflow-y: auto;
}

.tools-panel h3 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.tool-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section h4 {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.tool-section select,
.tool-section input[type="number"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

/* Boutons d'outils */
.tool-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
    transition: all 0.15s;
}

.tool-btn:hover {
    background: var(--border-light);
    border-color: var(--primary);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Sélecteur d'étage */
.floor-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.floor-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 50px;
    text-align: center;
}

/* Boussole */
.compass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.compass-slider {
    width: 100%;
}

/* ============================================================================
   CANVAS PRINCIPAL (centre)
   ============================================================================ */

.canvas-wrapper {
    position: relative;
    background: #e8edf2;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
    z-index: 10;
}

.canvas-info {
    display: flex;
    gap: 20px;
    color: var(--text-light);
}

.canvas-actions {
    display: flex;
    gap: 4px;
}

#planCanvas {
    flex: 1;
    cursor: crosshair;
    display: block;
}

/* ============================================================================
   PANNEAU PROPRIÉTÉS (droite)
   ============================================================================ */

.properties-panel {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-light);
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.properties-panel h3 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 12px;
}

/* Résumé de l'étage */
.summary-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-light);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row span:first-child {
    color: var(--text-light);
}

.summary-row span:last-child {
    font-weight: 600;
    color: var(--text);
}

/* Propriétés de l'élément sélectionné */
.props-section {
    margin-bottom: 12px;
}

.props-section h4 {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.props-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 0.82rem;
}

.props-row label {
    color: var(--text-light);
    font-size: 0.78rem;
}

.props-row input,
.props-row select {
    width: 90px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 0.8rem;
    text-align: right;
}

/* ============================================================================
   COULEURS DES ÉLÉMENTS SUR LE CANVAS
   ============================================================================ */

/* Définies en JS mais documentées ici :
   - Mur extérieur : #2c3e50 (gris foncé)
   - Mur mitoyen : #e67e22 (orange)
   - Mur intérieur : #95a5a6 (gris clair)
   - Fenêtre : #3498db (bleu)
   - Porte : #8e44ad (violet)
   - Grille : #dde1e7
   - Sélection : #e74c3c (rouge)
   - Cotations : #c0392b (rouge foncé)
*/

/* ============================================================================
   COMPOSITION DES MURS (panneau propriétés)
   ============================================================================ */

.composition-section {
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
}

.layers-table {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    font-size: 0.75rem;
}

.layer-header {
    display: grid;
    grid-template-columns: 1fr 52px 48px 60px;
    gap: 2px;
    padding: 4px 6px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.layer-row {
    display: grid;
    grid-template-columns: 1fr 52px 48px 60px;
    gap: 2px;
    padding: 3px 4px;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
    background: var(--bg-card);
}

.layer-row:nth-child(even) {
    background: var(--bg-panel);
}

.layer-row:hover {
    background: #e8f4ff;
}

.layer-mat .layer-select {
    width: 100%;
    font-size: 0.7rem;
    padding: 2px 2px;
    border: 1px solid var(--border);
    border-radius: 2px;
}

.layer-ep, .layer-lambda {
    display: flex;
    align-items: center;
    gap: 1px;
}

.layer-ep input, .layer-lambda input {
    width: 100%;
    padding: 2px 3px;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.73rem;
    text-align: right;
}

.layer-ep .unit {
    font-size: 0.65rem;
    color: var(--text-light);
}

.layer-actions {
    display: flex;
    gap: 1px;
    justify-content: center;
}

.btn-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.65rem;
    color: var(--text-light);
    border-radius: 2px;
    padding: 0;
}

.btn-icon:hover {
    background: var(--border-light);
    color: var(--primary);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: default;
}

.btn-icon-danger:hover {
    background: #fce4e4;
    color: #e74c3c;
}

.layers-summary {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--primary);
    background: #eef5fb;
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.no-layers-text {
    padding: 8px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
}

.btn-add-layer {
    width: 100%;
    padding: 4px;
    font-size: 0.75rem;
    margin-top: 6px;
}

/* Copier / Coller composition */
.composition-clipboard {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.btn-clipboard {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text);
    transition: all 0.15s;
}

.btn-clipboard:hover {
    border-color: var(--primary);
    background: #eef5fb;
}

.btn-clipboard.btn-paste {
    background: #eaf7ee;
    border-color: #4caf50;
    color: #2e7d32;
}

.btn-clipboard.btn-paste:hover {
    background: #c8e6c9;
}

/* ============================================================================
   PROPRIÉTÉS ENRICHIES
   ============================================================================ */

.props-grid {
    display: flex;
    flex-direction: column;
}

.props-row.highlight {
    background: #eef5fb;
    border-radius: 3px;
    padding: 3px 4px;
    margin: 1px 0;
}

.props-row .val {
    font-weight: 600;
    color: var(--text);
    font-size: 0.8rem;
}

.input-unit {
    display: flex;
    align-items: center;
    gap: 3px;
}

.input-unit input {
    width: 64px;
}

.input-unit span {
    font-size: 0.7rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* ============================================================================
   TOOL BUTTON - TRIM & DIMENSION EXTRA STYLES
   ============================================================================ */

.tool-btn[data-tool="trim"] {
    color: #e74c3c;
}

.tool-btn[data-tool="trim"].active {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
}

.tool-btn[data-tool="dimension"] {
    color: #c0392b;
}

.tool-btn[data-tool="dimension"].active {
    background: #c0392b;
    border-color: #c0392b;
    color: white;
}

/* Checkbox label style */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text);
    cursor: pointer;
    margin-top: 4px;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

/* ============================================================================
   SÉLECTEUR SOUS-TYPE DE COTATION
   ============================================================================ */

.dim-subtool-section {
    background: #fdf6ec;
    border: 1px solid #f0d9a8;
    border-radius: var(--radius-sm);
    padding: 8px !important;
    margin-bottom: 12px;
}

.dim-subtool-btns {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dim-sub-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text);
    transition: all 0.15s;
    text-align: left;
}

.dim-sub-btn:hover {
    background: #fff3e0;
    border-color: #c0392b;
}

.dim-sub-btn.active {
    background: #c0392b;
    color: white;
    border-color: #c0392b;
}

.dim-sub-btn i {
    width: 14px;
    text-align: center;
    font-size: 0.8rem;
}

/* ============================================================================
   LAMBDA LECTURE SEULE (composition mur)
   ============================================================================ */

.lambda-readonly {
    display: inline-block;
    width: 100%;
    padding: 2px 3px;
    font-size: 0.73rem;
    text-align: right;
    color: var(--text-light);
    background: var(--bg-panel);
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: default;
}

/* ============================================================================
   HINT PARAMÉTRIQUE (sous les propriétés de cotation)
   ============================================================================ */

.dim-parametric-hint {
    font-size: 0.72rem;
    color: #c0392b;
    font-style: italic;
    padding: 4px 6px;
    background: #fef5f5;
    border: 1px solid #f5d5d5;
    border-radius: var(--radius-sm);
    margin-top: 6px;
}

.dim-parametric-hint i {
    margin-right: 4px;
}

/* ============================================================================
   MODE SOMBRE — CANVAS
   ============================================================================ */

body.dark-mode .canvas-wrapper {
    background: #151a26;
}

body.dark-mode .canvas-toolbar {
    background: var(--bg-panel);
    border-bottom-color: var(--border);
}

body.dark-mode .tools-panel {
    background: var(--bg-panel);
    border-right-color: var(--border);
}

body.dark-mode .properties-panel {
    background: var(--bg-panel);
    border-left-color: var(--border);
}

body.dark-mode .layer-row {
    background: var(--bg-card);
    border-bottom-color: var(--border);
}

body.dark-mode .layer-row:nth-child(even) {
    background: var(--bg-panel);
}

body.dark-mode .layer-row:hover {
    background: rgba(59,125,221,0.1);
}

body.dark-mode .layers-summary {
    background: rgba(59,125,221,0.1);
    border-top-color: var(--border);
}

body.dark-mode .layer-select,
body.dark-mode .layer-ep input,
body.dark-mode .layer-lambda input {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode .btn-icon:hover {
    background: var(--border);
}

body.dark-mode .btn-icon-danger:hover {
    background: rgba(231,76,60,0.15);
    color: #e74c3c;
}

body.dark-mode .dim-parametric-hint {
    background: rgba(192,57,43,0.1);
    border-color: rgba(192,57,43,0.3);
    color: #e57373;
}
