/* =====================================================================
   BACKOFFICE.CSS - Styles communs pour les modules Back-Office
   ===================================================================== */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #dfe3e8;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --primary: #2c7be5;
    --primary-hover: #1a5dc8;
    --danger: #dc3545;
    --danger-hover: #b02a37;
    --success: #28a745;
    --warning: #f0ad4e;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* =====================================================================
   HEADER
   ===================================================================== */

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}
.header h1 { font-size: 18px; font-weight: 600; }
.header .app-name { color: var(--text-light); font-size: 13px; }

/* =====================================================================
   LAYOUT MAITRE-DETAIL
   ===================================================================== */

.layout {
    display: flex;
    height: calc(100vh - 52px);
}

/* Liste (maitre) */
.master {
    width: 280px;
    min-width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.master-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.master-header span { font-weight: 600; font-size: 13px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }

.panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.panel-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.panel-item:hover { background: #f0f4ff; }
.panel-item.active { background: #e8f0fe; border-color: var(--primary); }
.panel-item .panel-title { font-weight: 600; font-size: 13px; }
.panel-item .panel-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.panel-item .panel-inactive { opacity: 0.5; }
.panel-item .badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: 6px;
}
.badge-filter { background: #e8f5e9; color: #2e7d32; }
.badge-form { background: #fff3e0; color: #e65100; }

/* Detail */
.detail {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-top: 60px;
}
.detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-light);
    font-size: 15px;
}

/* Barre d'actions fixe en haut du detail */
.detail-toolbar {
    position: fixed;
    top: 52px;
    left: 280px;
    right: 0;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow);
}
.detail-toolbar .spacer { flex: 1; }

/* =====================================================================
   FORMULAIRE
   ===================================================================== */

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.form-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    align-items: flex-start;
}
.form-group {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.form-group label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(44, 123, 229, 0.15);
}
.form-group textarea {
    min-height: 95px;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-size: 12px;
    resize: vertical;
}
.form-group input[type="checkbox"] {
    width: 16px; height: 16px; margin-top: 4px;
}
.form-group.narrow { max-width: 100px; flex: 0 0 100px; }
.form-group.medium { max-width: 180px; flex: 0 0 180px; }
.form-group.key { max-width: 130px; flex: 0 0 130px; }
.form-group.check { max-width: 60px; flex: 0 0 60px; align-items: center; }

/* =====================================================================
   TRADUCTIONS INLINE
   ===================================================================== */

.trans-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.trans-row .lang-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    width: 24px;
    text-align: right;
    flex-shrink: 0;
}
.trans-row input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}
.trans-row input:focus {
    outline: none;
    border-color: var(--primary);
}
.trans-block { margin-bottom: 8px; }

/* =====================================================================
   FIELDS (cartes de champs)
   ===================================================================== */

.field-card {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 4px;
}
.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.field-header span { font-weight: 600; font-size: 12px; color: var(--text-light); }

/* =====================================================================
   BOUTONS
   ===================================================================== */

.btn {
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f5f5f5; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 4px 8px; font-size: 16px; line-height: 1; }

.btn-bar {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.btn-bar .spacer { flex: 1; }

/* =====================================================================
   TOAST (notifications)
   ===================================================================== */

.toast {
    position: fixed;
    top: 60px;
    right: 20px;
    padding: 10px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* =====================================================================
   SECTIONS REPLIABLES
   ===================================================================== */

.collapsible {
    cursor: pointer;
    user-select: none;
}
.collapsible:hover { color: var(--primary); }
.collapse-arrow {
    display: inline-block;
    font-size: 10px;
    width: 14px;
    transition: transform 0.15s;
}
.collapsible-content {
    overflow: hidden;
    max-height: 5000px;
    transition: max-height 0.25s ease;
}
.collapsible-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 768px) {
    .layout { flex-direction: column; height: auto; }
    .master { width: 100%; min-width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
    .detail { padding: 12px; padding-top: 60px; }
    .detail-toolbar { left: 0; }
    .form-row { flex-direction: column; gap: 8px; }
    .form-group.narrow, .form-group.check { max-width: none; flex: 1; }
}


/* =====================================================================
   COMPOSANTS COMMUNS (badges, statuts, info-grid)
   ===================================================================== */

.server-type-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
}
.type-esri { background: #f3e5f5; color: #7b1fa2; }
.type-wfs  { background: #fff3e0; color: #e65100; }
.status-yes { color: var(--success); font-weight: 600; }
.status-no  { color: var(--text-light); }
.info-label { font-weight: 600; color: var(--text-light); }
.info-value { color: var(--text); }

/* =====================================================================
   HARMONISATIONS (info-grid, layer-item, modal-overlay, badges)
   ===================================================================== */

.info-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px 12px;
    font-size: 13px;
}
.layer-item .layer-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.layer-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-size: 12px;
}
.layer-item:hover { background: #f0f4ff; }
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active  { display: flex; }
.modal-overlay.visible { display: flex; }
.badge-on  { background: var(--success); color: #fff; }
.badge-off { background: #e0e0e0; color: #888; }