/* ── ISO Audit — App-specific styles ──────────────────────────── */

/* ── Audit control cards ─────────────────────────────────────── */
.ctrl-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; margin-bottom: 12px; transition: border-color 0.15s;
}
.ctrl-card:hover { border-color: var(--light-blue); }
.ctrl-card-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.ctrl-id {
    font-weight: 700; font-size: 0.85em; color: var(--light-blue);
    background: #e8f4fd; padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}
.ctrl-title { font-weight: 600; font-size: 0.9em; color: var(--text); flex: 1; }
.ctrl-hds {
    font-size: 0.7em; font-weight: 700; padding: 2px 8px; border-radius: 10px;
    background: #3a8a6e; color: white; white-space: nowrap;
}
.ctrl-desc { font-size: 0.82em; color: var(--text-muted); line-height: 1.4; margin-bottom: 10px; }

/* ── Status buttons ──────────────────────────────────────────── */
.status-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.status-btn {
    padding: 4px 10px; border: 2px solid var(--border); border-radius: 6px;
    cursor: pointer; font-size: 0.78em; font-weight: 600; background: white;
    color: var(--text-muted); transition: all 0.15s; user-select: none;
}
.status-btn:hover { border-color: var(--light-blue); color: var(--text); }
.status-btn.active { color: white; }
.status-btn[data-status="c"].active { background: var(--green); border-color: var(--green); }
.status-btn[data-status="ncmaj"].active { background: var(--red); border-color: var(--red); }
.status-btn[data-status="ncmin"].active { background: var(--orange); border-color: var(--orange); }
.status-btn[data-status="ps"].active { background: #8e44ad; border-color: #8e44ad; }
.status-btn[data-status="pp"].active { background: var(--light-blue); border-color: var(--light-blue); }
.status-btn[data-status="na"].active { background: #95a5a6; border-color: #95a5a6; }

/* ── Finding fields ──────────────────────────────────────────── */
.ctrl-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ctrl-field { display: flex; flex-direction: column; }
.ctrl-field label { font-size: 0.75em; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 2px; }
.ctrl-field textarea { min-height: 50px; font-size: 0.85em; resize: vertical; }
.ecart-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
    padding-top: 8px; border-top: 1px dashed var(--border);
}
.ecart-fields .ctrl-field label { color: var(--red); }

/* ── Questions panel ─────────────────────────────────────────── */
.questions-panel { display: none; margin-top: 8px; }
.questions-panel.open { display: block; }
.question-item {
    display: flex; align-items: flex-start; gap: 6px; padding: 6px 0;
    border-bottom: 1px solid var(--border); font-size: 0.82em;
}
.question-item:last-child { border-bottom: none; }
.btn-copy-q {
    flex-shrink: 0; padding: 2px 6px; border: 1px solid var(--border);
    border-radius: 4px; cursor: pointer; font-size: 0.8em; background: white;
}
.btn-copy-q:hover { background: #e8f4fd; }

/* ── Card action buttons ─────────────────────────────────────── */
.ctrl-actions { display: flex; gap: 6px; margin-left: auto; }
.btn-questions, .btn-templates {
    padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px;
    cursor: pointer; font-size: 0.75em; background: white; color: var(--text-muted);
}
.btn-questions:hover, .btn-templates:hover { background: #e8f4fd; color: var(--light-blue); }

/* ── Filters bar ─────────────────────────────────────────────── */
.filters-bar {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding: 10px 0; margin-bottom: 8px; border-bottom: 1px solid var(--border);
}
.filter-select {
    padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
    font-size: 0.82em; background: white;
}
.filter-search {
    padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
    font-size: 0.82em; flex: 1; min-width: 150px;
}
.filter-count { font-size: 0.8em; color: var(--text-muted); margin-left: auto; }

/* ── Dashboard ───────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; text-align: center;
}
.dash-card h3 { font-size: 0.9em; color: var(--blue); margin-bottom: 8px; }
/* (.dash-card-full removed — unused) */

/* (gauge-value/grade/label removed — gauge uses inline SVG styles) */

/* ── KPI boxes ───────────────────────────────────────────────── */
.kpi-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.kpi-box {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px;
    padding: 10px 14px; text-align: center; flex: 1; min-width: 100px;
}
.kpi-value { font-size: 1.6em; font-weight: 700; }
.kpi-label { font-size: 0.75em; color: var(--text-muted); margin-top: 2px; }

/* ── NC table ────────────────────────────────────────────────── */
.nc-table { width: 100%; border-collapse: collapse; font-size: 0.82em; }
.nc-table th { background: var(--bg); padding: 6px 10px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--border); }
.nc-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }

/* ── Sidebar domain badges ───────────────────────────────────── */
.sidebar-badge {
    font-size: 0.7em; padding: 1px 6px; border-radius: 8px; margin-left: auto;
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.6);
}
.sidebar-badge.complete { background: rgba(39,174,96,0.3); color: #27ae60; }

/* (timer-bar and ecart-card removed — unused) */

/* ── Document review ─────────────────────────────────────────── */
.doc-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-ref { font-weight: 600; font-size: 0.85em; color: var(--light-blue); white-space: nowrap; min-width: 50px; }
.doc-label { flex: 1; font-size: 0.85em; }
.doc-status-btns { display: flex; gap: 4px; }
.doc-status-btn {
    padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px;
    cursor: pointer; font-size: 0.72em; font-weight: 600; background: white;
}
.doc-status-btn.active { color: white; }
.doc-status-btn[data-ds="recu"].active { background: var(--green); border-color: var(--green); }
.doc-status-btn[data-ds="incomplet"].active { background: var(--orange); border-color: var(--orange); }
.doc-status-btn[data-ds="manquant"].active { background: var(--red); border-color: var(--red); }
.doc-status-btn[data-ds="na"].active { background: #95a5a6; border-color: #95a5a6; }
.doc-obs { width: 100%; margin-top: 4px; font-size: 0.82em; min-height: 30px; }

/* ── Planning ────────────────────────────────────────────────── */
.planning-params { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 20px; padding: 16px; background: var(--bg); border-radius: 8px; border: 1px solid var(--border); }
.planning-param { display: flex; flex-direction: column; gap: 4px; }
.planning-param label { font-size: 0.75em; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.planning-param input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.85em; }
.planning-slot {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    border-radius: 8px; margin-bottom: 6px; font-size: 0.82em;
    transition: box-shadow 0.15s;
}
.planning-slot:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.slot-time { font-weight: 700; font-family: monospace; white-space: nowrap; min-width: 110px; }
.slot-domain { flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.82em; background: white; }
.slot-actions { display: flex; gap: 4px; }

/* ── Journal ─────────────────────────────────────────────────── */
.journal-entry {
    display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border);
    font-size: 0.82em;
}
.journal-time { font-family: monospace; font-size: 0.85em; color: var(--text-muted); white-space: nowrap; }
.journal-type {
    font-size: 0.72em; font-weight: 600; padding: 1px 6px; border-radius: 4px;
    white-space: nowrap;
}
.journal-text { flex: 1; }

/* ── Meta fields (dashboard) ─────────────────────────────────── */
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.meta-field { display: flex; flex-direction: column; }
.meta-field label { font-size: 0.75em; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 2px; }
.meta-field input, .meta-field select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.85em; }

/* ── Search overlay ──────────────────────────────────────────── */
.search-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 500; justify-content: center; align-items: flex-start;
    padding-top: 10vh;
}
.search-overlay.open { display: flex; }
.search-panel {
    background: white; border-radius: 12px; width: 100%; max-width: 600px;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.search-header { display: flex; gap: 8px; padding: 16px 16px 8px; }
.search-input {
    flex: 1; padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px;
    font-size: 1em; outline: none; transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--light-blue); }
.search-scope {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.82em; background: white; cursor: pointer;
}
.search-count { font-size: 0.78em; color: var(--text-muted); padding: 0 16px 8px; }
.search-results {
    flex: 1; overflow-y: auto; padding: 0 16px; min-height: 60px;
}
.search-result-item {
    display: flex; gap: 10px; padding: 10px 8px; border-bottom: 1px solid var(--border);
    cursor: pointer; border-radius: 6px; transition: background 0.1s;
}
.search-result-item:hover { background: #f0f7ff; }
.search-result-id {
    font-weight: 700; font-size: 0.82em; color: var(--light-blue);
    background: #e8f4fd; padding: 2px 8px; border-radius: 4px; white-space: nowrap;
    align-self: flex-start;
}
.search-result-content { flex: 1; min-width: 0; }
.search-result-title { font-weight: 600; font-size: 0.88em; color: var(--text); }
.search-result-match {
    font-size: 0.8em; color: var(--text-muted); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-match mark { background: #fff3cd; padding: 1px 2px; border-radius: 2px; }
.search-result-status {
    font-size: 0.7em; font-weight: 600; padding: 1px 6px; border-radius: 4px;
    color: white; margin-left: 6px; vertical-align: middle;
}
.search-no-results {
    text-align: center; padding: 30px; color: var(--text-muted); font-size: 0.9em;
}
.search-footer {
    text-align: center; padding: 10px; font-size: 0.75em; color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ── Enhanced dashboard ─────────────────────────────────────── */
.dash-charts-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-card-wide { grid-column: 1 / -1; }
.radar-svg { display: block; margin: 0 auto; }

/* ── Stacked bars ───────────────────────────────────────────── */
.stacked-row { margin-bottom: 6px; }
.stacked-label { font-size: 0.78em; font-weight: 600; margin-bottom: 2px; color: var(--text); }
.stacked-track {
    display: flex; height: 18px; background: #eee; border-radius: 4px; overflow: hidden;
}
.stacked-seg { height: 100%; transition: width 0.3s; }

/* ── HDS focus ──────────────────────────────────────────────── */
.hds-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 0.82em; }
.hds-bar-label { min-width: 100px; font-weight: 600; }
.hds-bar-track { flex: 1; height: 14px; background: #eee; border-radius: 4px; overflow: hidden; }
.hds-bar-fill { height: 100%; border-radius: 4px; }
.hds-bar-count { min-width: 30px; text-align: right; font-weight: 600; font-size: 0.9em; }

/* ── Report button ──────────────────────────────────────────── */
.btn-report {
    padding: 6px 14px; border: 1px solid var(--light-blue); border-radius: 6px;
    background: #e8f4fd; color: var(--light-blue); cursor: pointer; font-size: 0.82em;
    font-weight: 600; transition: all 0.15s;
}
.btn-report:hover { background: var(--light-blue); color: white; }

/* ── Images / preuves ────────────────────────────────────────── */
.img-section { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.img-section-header { font-size: 0.8em; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.img-thumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.img-thumb {
    position: relative; width: 100px; height: 75px; border-radius: 6px; overflow: hidden;
    border: 1px solid var(--border); cursor: pointer; transition: box-shadow 0.15s;
}
.img-thumb:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb-del {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    background: rgba(231,76,60,0.85); color: white; border: none; border-radius: 50%;
    font-size: 0.7em; cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
}
.img-thumb:hover .img-thumb-del { opacity: 1; }
.img-add-btn {
    width: 100px; height: 75px; border: 2px dashed var(--border); border-radius: 6px;
    background: none; cursor: pointer; font-size: 0.75em; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; text-align: center;
    transition: all 0.15s;
}
.img-add-btn:hover { border-color: var(--light-blue); color: var(--light-blue); }

/* Image overlay (fullscreen) */
.img-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 600; justify-content: center; align-items: center;
    cursor: pointer;
}
.img-overlay.open { display: flex; }
.img-overlay-content { text-align: center; max-width: 90vw; max-height: 90vh; }
.img-overlay-content img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 4px; }
.img-overlay-name { color: rgba(255,255,255,0.7); font-size: 0.82em; margin-top: 8px; }

/* ── Sidebar utilities ────────────────────────────────────────── */
.opacity-low { opacity: 0.3; }
.btn-group-sm { display: flex; gap: 6px; padding: 6px 14px 8px; }
.btn-undo, .btn-redo {
    background: none; border: none; color: rgba(255,255,255,0.5); font-size: 1.2em;
    cursor: pointer; padding: 2px 4px; transition: color 0.15s;
}
.btn-undo:hover, .btn-redo:hover { color: white; }
.sidebar-brand {
    display: block; text-align: center; padding: 10px 14px; font-size: 0.75em;
    color: rgba(255,255,255,0.35); text-decoration: none; letter-spacing: 0.5px;
}
.sidebar-brand:hover { color: rgba(255,255,255,0.6); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .toolbar-logo { display: none; }
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%; min-width: 100%; height: auto; max-height: 0; overflow: hidden;
        position: relative; top: 0; transition: max-height 0.3s ease;
        flex-direction: column; display: flex; z-index: 50;
    }
    .sidebar.open { max-height: 80vh; overflow-y: auto; }
    .sidebar-collapse { display: none; }
    .sidebar-item { padding: 12px 16px; font-size: 0.85em; border-left: none; border-bottom: 1px solid rgba(255,255,255,0.1); }
    .sidebar-item.active { background: rgba(255,255,255,0.15); border-left-color: transparent; }
    .sidebar-section { padding: 10px 16px 4px; font-size: 0.7em; }
    .container { padding: 8px; }
    .dash-grid { grid-template-columns: 1fr; }
    .dash-charts-grid { grid-template-columns: 1fr; }
    .ctrl-fields, .ecart-fields { grid-template-columns: 1fr; }
    .meta-grid { grid-template-columns: 1fr; }
    .planning-params { grid-template-columns: 1fr 1fr !important; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .search-panel { max-width: 95%; }
    .search-header { flex-direction: column; }
}
