/* PrestigeiaPro — Espace Artisan Frontend v1.0 */

/* ── Reset & base ──────────────────────────────────────────── */
.pea-app *, .pea-modal-overlay * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}
.pea-app {
    display: flex;
    min-height: 85vh;
    background: #f0f2f5;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.10);
    position: relative;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.pea-sidebar {
    width: 240px;
    background: #0A2463;
    color: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform .25s;
    z-index: 100;
}
.pea-sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.pea-logo {
    max-height: 45px;
    max-width: 160px;
    margin-bottom: 12px;
    display: block;
}
.pea-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.pea-avatar {
    width: 38px; height: 38px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800;
    flex-shrink: 0;
}
.pea-user-info strong { display: block; font-size: 13px; font-weight: 700; }
.pea-user-info span   { font-size: 11px; opacity: .65; }

/* ── Nav ───────────────────────────────────────────────────── */
.pea-nav { padding: 10px 0; flex: 1; overflow-y: auto; }
.pea-nav-item {
    display: flex; align-items: center;
    padding: 10px 16px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s;
    gap: 8px;
    position: relative;
}
.pea-nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.pea-nav-item.active {
    background: rgba(255,255,255,.14);
    color: white;
    border-left-color: #4fc3f7;
    font-weight: 700;
}
.pea-icon { font-size: 16px; flex-shrink: 0; }
.pea-nav-separator { height: 1px; background: rgba(255,255,255,.1); margin: 6px 16px; }
.pea-badge {
    margin-left: auto;
    background: #e74c3c;
    color: white;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    display: none;
}
.pea-badge.visible { display: inline-block; }

/* ── Main ──────────────────────────────────────────────────── */
.pea-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.pea-topbar {
    background: white;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #e8e8e8;
    box-shadow: 0 2px 6px rgba(0,0,0,.04);
    position: sticky;
    top: 0;
    z-index: 50;
}
.pea-page-title { margin: 0; font-size: 18px; font-weight: 700; color: #1a1a2e; flex: 1; }
.pea-menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px 8px; }
.pea-topbar-actions { display: flex; gap: 8px; }

.pea-content { padding: 20px; flex: 1; overflow-y: auto; }

/* ── Loading ───────────────────────────────────────────────── */
.pea-loading { text-align: center; padding: 60px 20px; color: #999; }
.pea-spinner {
    width: 40px; height: 40px;
    border: 4px solid #f0f0f0;
    border-top-color: #0A2463;
    border-radius: 50%;
    animation: pea-spin .8s linear infinite;
    margin: 0 auto 15px;
}
@keyframes pea-spin { to { transform: rotate(360deg); } }

/* ── Cards & KPIs ──────────────────────────────────────────── */
.pea-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.pea-kpi {
    background: white;
    border-radius: 10px;
    padding: 16px;
    border-left: 5px solid #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.pea-kpi-val { font-size: 22px; font-weight: 800; line-height: 1.2; }
.pea-kpi-label { font-size: 11px; color: #888; margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }
.pea-kpi.green { border-color: #27ae60; } .pea-kpi.green .pea-kpi-val { color: #27ae60; }
.pea-kpi.blue  { border-color: #3498db; } .pea-kpi.blue .pea-kpi-val  { color: #3498db; }
.pea-kpi.red   { border-color: #e74c3c; } .pea-kpi.red .pea-kpi-val   { color: #e74c3c; }
.pea-kpi.orange{ border-color: #e67e22; } .pea-kpi.orange .pea-kpi-val{ color: #e67e22; }
.pea-kpi.purple{ border-color: #9b59b6; } .pea-kpi.purple .pea-kpi-val{ color: #9b59b6; }
.pea-kpi.teal  { border-color: #1abc9c; } .pea-kpi.teal .pea-kpi-val  { color: #1abc9c; }

.pea-card {
    background: white;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-bottom: 14px;
}
.pea-card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 700; color: #333; padding-bottom: 10px; border-bottom: 2px solid #f0f0f0; }
.pea-row { display: flex; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────── */
.pea-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.pea-btn:hover { border-color: #0A2463; color: #0A2463; }
.pea-btn-primary { background: #0A2463; color: white; border-color: #0A2463; }
.pea-btn-primary:hover { background: #0d2e7a; color: white; }
.pea-btn-green { background: #27ae60; color: white; border-color: #27ae60; }
.pea-btn-red { background: #e74c3c; color: white; border-color: #e74c3c; }
.pea-btn-orange { background: #e67e22; color: white; border-color: #e67e22; }
.pea-btn-blue { background: #3498db; color: white; border-color: #3498db; }
.pea-btn-sm { padding: 5px 10px; font-size: 12px; }

.pea-quick-actions { display: flex; flex-direction: column; gap: 8px; }
.pea-quick-actions .pea-btn { text-align: left; }

/* ── Filters ───────────────────────────────────────────────── */
.pea-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.pea-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.pea-input {
    padding: 7px 12px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 13px; min-width: 200px;
}
.pea-input:focus { outline: none; border-color: #0A2463; box-shadow: 0 0 0 2px rgba(10,36,99,.1); }
.pea-select { padding: 7px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }

/* ── Table ─────────────────────────────────────────────────── */
.pea-table-wrap { overflow-x: auto; background: white; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.pea-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pea-table th { background: #f8f9fa; padding: 11px 12px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #777; font-weight: 700; border-bottom: 2px solid #eee; white-space: nowrap; }
.pea-table td { padding: 11px 12px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.pea-table tr:last-child td { border-bottom: none; }
.pea-table tr:hover td { background: #fafbff; }
.pea-table .retard { background: #fff5f5 !important; }

/* ── Badges ────────────────────────────────────────────────── */
.pea-tag {
    display: inline-block; padding: 3px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
}
.pea-tag-green  { background: #d4edda; color: #155724; }
.pea-tag-blue   { background: #cce5ff; color: #004085; }
.pea-tag-red    { background: #f8d7da; color: #721c24; }
.pea-tag-orange { background: #fff3cd; color: #856404; }
.pea-tag-purple { background: #e2d9f3; color: #432874; }
.pea-tag-gray   { background: #e2e3e5; color: #383d41; }

/* ── Actions ───────────────────────────────────────────────── */
.pea-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────────── */
.pea-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pea-form-grid.full { grid-template-columns: 1fr; }
.pea-form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.pea-field { display: flex; flex-direction: column; gap: 4px; }
.pea-field label { font-size: 11px; font-weight: 700; color: #555; text-transform: uppercase; }
.pea-field input, .pea-field select, .pea-field textarea {
    padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 13px; transition: border-color .15s;
}
.pea-field input:focus, .pea-field select:focus, .pea-field textarea:focus {
    outline: none; border-color: #0A2463; box-shadow: 0 0 0 2px rgba(10,36,99,.1);
}
.pea-section-title { font-size: 13px; font-weight: 700; color: #0A2463; text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 8px; padding-bottom: 6px; border-bottom: 2px solid #e8f0fe; }

/* ── Lignes devis ──────────────────────────────────────────── */
.pea-ligne { background: #fafafa; border: 1px solid #eee; border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.pea-ligne-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.pea-totaux { background: #f0f4ff; border-radius: 8px; padding: 14px 18px; margin-top: 12px; }
.pea-totaux table { width: 100%; max-width: 320px; margin-left: auto; }
.pea-totaux td { padding: 5px 8px; font-size: 13px; }
.pea-totaux td:last-child { text-align: right; font-weight: 600; }
.pea-totaux .ttc-row td { background: #0A2463; color: white; font-size: 16px; font-weight: 800; border-radius: 4px; }

/* ── URSSAF ────────────────────────────────────────────────── */
.pea-urssaf-card { border-left: 5px solid #e67e22; }
.pea-urssaf-badge-a_declarer { background: #fff3cd; color: #856404; }
.pea-urssaf-badge-declaree { background: #cce5ff; color: #004085; }
.pea-urssaf-badge-payee { background: #d4edda; color: #155724; }
.pea-progress-bar { background: #eee; border-radius: 4px; height: 8px; margin-top: 4px; }
.pea-progress-fill { height: 100%; border-radius: 4px; transition: width .4s; }

/* ── Demandes ──────────────────────────────────────────────── */
.pea-demande-card {
    background: white; border-radius: 10px; padding: 16px;
    margin-bottom: 12px; border: 1px solid #eee;
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
    transition: box-shadow .15s;
}
.pea-demande-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.pea-demande-card.nouveau { border-left: 5px solid #e67e22; }
.pea-demande-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pea-urgence-urgent { color: #e74c3c; font-weight: 700; }
.pea-urgence-normal { color: #3498db; }
.pea-urgence-flexible { color: #27ae60; }

/* ── Modal ─────────────────────────────────────────────────── */
.pea-modal-overlay {
    position: fixed; top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,.55);
    z-index: 9999;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.pea-modal-box {
    background: white; border-radius: 12px;
    width: 100%; max-width: 820px;
    margin: auto;
    padding: 24px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,.25);
    max-height: 90vh;
    overflow-y: auto;
}
.pea-modal-close {
    position: absolute; top: 14px; right: 14px;
    background: none; border: none; font-size: 20px;
    cursor: pointer; color: #999; padding: 4px 8px;
    border-radius: 50%;
}
.pea-modal-close:hover { background: #f5f5f5; color: #333; }

/* ── Toast ─────────────────────────────────────────────────── */
#pea-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #1a1a2e; color: white;
    padding: 12px 22px; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    display: none; z-index: 99999;
    box-shadow: 0 4px 18px rgba(0,0,0,.3);
    max-width: 380px;
}
#pea-toast.error { background: #c62828; }
#pea-toast.success { background: #2e7d32; }

/* ── Impayés ───────────────────────────────────────────────── */
.pea-impaye-item { padding: 8px 0; border-bottom: 1px solid #f5f5f5; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.pea-impaye-item:last-child { border-bottom: none; }

/* ── Login required ────────────────────────────────────────── */
.pea-login-required { text-align: center; padding: 40px; background: #fff; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.pea-login-required .pea-btn { margin-top: 14px; display: inline-block; padding: 10px 30px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .pea-app { flex-direction: column; }
    .pea-sidebar {
        width: 100%; position: fixed; top:0; left:0; bottom:0;
        transform: translateX(-100%); z-index: 200;
    }
    .pea-sidebar.open { transform: translateX(0); }
    .pea-menu-toggle { display: block; }
    .pea-main { width: 100%; }
    .pea-form-grid { grid-template-columns: 1fr; }
    .pea-form-grid.three { grid-template-columns: 1fr 1fr; }
    .pea-kpis { grid-template-columns: 1fr 1fr; }
    .pea-row { flex-direction: column; }
    .pea-content { padding: 12px; }
}
@media (max-width: 480px) {
    .pea-kpis { grid-template-columns: 1fr 1fr; }
    .pea-form-grid.three { grid-template-columns: 1fr; }
    .pea-table th, .pea-table td { padding: 8px 6px; font-size: 12px; }
}

/* ══ OVERRIDES pour matcher le design PrestigeiaPro ════════════
 * Basé sur les captures d'écran : bleu marine #0A2463, orange #E85D1A
 * ════════════════════════════════════════════════════════════ */

/* Masquer la sidebar interne — on utilise le menu existant du site */
.pea-sidebar {
    display: none !important; /* Le menu est géré par peia-user-space */
}
.pea-main {
    width: 100%;
    min-height: auto;
}
.pea-app {
    display: block;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    min-height: auto;
}
.pea-topbar {
    background: #0A2463;
    color: white;
    border-radius: 10px 10px 0 0;
    padding: 16px 20px;
    margin-bottom: 0;
}
.pea-page-title {
    color: white;
    font-size: 20px;
}
.pea-menu-toggle {
    color: white;
    display: none; /* géré par le site */
}

/* Navigation interne à onglets (remplace la sidebar) */
.pea-tabs {
    display: flex;
    flex-wrap: wrap;
    background: #0c2d78;
    padding: 0 12px;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pea-tab {
    padding: 10px 14px;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all .15s;
    user-select: none;
}
.pea-tab:hover { color: white; }
.pea-tab.active {
    color: white;
    border-bottom-color: #E85D1A;
}

/* Contenu */
.pea-content {
    background: white;
    border-radius: 0 0 10px 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,.08);
}

/* Bouton principal — orange comme le site */
.pea-btn-primary {
    background: #E85D1A;
    border-color: #E85D1A;
    color: white;
}
.pea-btn-primary:hover {
    background: #d04e10;
    border-color: #d04e10;
    color: white;
}

/* KPIs — style des blocs du site */
.pea-kpi {
    border-radius: 12px;
    border-left: none;
    border: none;
}
.pea-kpi.green  { background: #27ae60; color: white; }
.pea-kpi.green .pea-kpi-val, .pea-kpi.green .pea-kpi-label { color: white; }
.pea-kpi.blue   { background: #0A2463; color: white; }
.pea-kpi.blue .pea-kpi-val, .pea-kpi.blue .pea-kpi-label { color: white; }
.pea-kpi.orange { background: #E85D1A; color: white; }
.pea-kpi.orange .pea-kpi-val, .pea-kpi.orange .pea-kpi-label { color: white; }
.pea-kpi.red    { background: #e74c3c; color: white; }
.pea-kpi.red .pea-kpi-val, .pea-kpi.red .pea-kpi-label { color: white; }
.pea-kpi.purple { background: #9b59b6; color: white; }
.pea-kpi.purple .pea-kpi-val, .pea-kpi.purple .pea-kpi-label { color: white; }
.pea-kpi.teal   { background: #1abc9c; color: white; }
.pea-kpi.teal .pea-kpi-val, .pea-kpi.teal .pea-kpi-label { color: white; }
.pea-kpi-val   { font-size: 28px; font-weight: 900; }
.pea-kpi-label { font-size: 12px; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }

/* Cards */
.pea-card { border-radius: 10px; border: 1px solid #eee; }
.pea-card h3 { color: #0A2463; }

/* Table */
.pea-table th { color: #0A2463; }

/* Toast */
#pea-toast.success { background: #27ae60; }
#pea-toast.error   { background: #e74c3c; }

/* Mobile — plein écran */
@media (max-width: 600px) {
    .pea-content { padding: 12px; }
    .pea-tab { padding: 8px 10px; font-size: 12px; }
    .pea-kpi-val { font-size: 22px; }
}

/* ══ PRIX BÂTIMENT — Espace artisan frontend ════════════════ */
.ppb-fe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.ppb-fe-met {
    background: white;
    border: 2px solid #e8ecf5;
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    transition: all .2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ppb-fe-met:hover, .ppb-fe-met.active { border-color: #E85D1A; background: #fff8f5; }
.ppb-fe-met strong { display: block; font-size: 11px; font-weight: 700; line-height: 1.3; }
.ppb-fe-met small { color: #999; font-size: 10px; }
.ppb-fe-metier-all { background: #0A2463; color: white; border-color: #0A2463; }
.ppb-fe-metier-all strong, .ppb-fe-metier-all small { color: white; }

.ppb-fe-cat-block { margin-bottom: 14px; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.ppb-fe-cat-title {
    background: linear-gradient(135deg,#0A2463,#1a3a8a);
    color: white;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
}
.ppb-fe-count { background: rgba(255,255,255,.2); border-radius: 10px; padding: 1px 8px; font-size: 11px; }

.ppb-fe-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid #f5f5f5;
    background: white;
    flex-wrap: wrap;
    transition: background .1s;
}
.ppb-fe-row:hover { background: #fafbff; }
.ppb-fe-row:last-child { border-bottom: none; }
.ppb-fe-row.ppb-fe-perso { background: #f0fff4; }
.ppb-fe-row.ppb-fe-fav { border-left: 4px solid #f39c12; }

.ppb-fe-info { flex: 1; min-width: 200px; font-size: 13px; }
.ppb-fe-fourchette { font-size: 11px; text-align: right; min-width: 90px; color: #aaa; }
.ppb-fe-prix-wrap { display: flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.ppb-fe-prix-input {
    width: 80px;
    padding: 6px 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    transition: border-color .2s;
}
.ppb-fe-prix-input:focus { outline: none; border-color: #0A2463; }
.ppb-fe-ttc { font-size: 12px; color: #0A2463; min-width: 70px; text-align: right; }
.ppb-fe-ttc strong { font-size: 14px; }
.ppb-fe-actions { display: flex; gap: 4px; }

.ppb-fe-tag { background: #e8ecf5; color: #555; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 700; }
.ppb-fe-cee { background: #d4edda; color: #155724; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 700; }
.ppb-fe-map { background: #cce5ff; color: #004085; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 700; }

@media (max-width:600px) {
    .ppb-fe-grid { grid-template-columns: 1fr 1fr; }
    .ppb-fe-row { padding: 8px 10px; }
    .ppb-fe-fourchette { display: none; }
    .ppb-fe-ttc { display: none; }
}

/* ═══ PRIX BÂTIMENT — Panneau inline dans formulaire devis ═══ */
.ppb-inline-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid #eee;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    transition: background .15s, border-color .15s;
    background: white;
}
.ppb-inline-item:hover {
    background: #f0f4ff;
    border-color: #0A2463;
}
