/* styles.css – responsywny wygląd audytu (Bootstrap 5) */

:root {
    --audit-bg: #f4f6fa;
    --audit-border: #dee2e6;
    --audit-primary: #0d6efd;
    --action-bar-h: 90px;
}

html, body {
    background-color: var(--audit-bg);
    color: #212529;
    font-size: 15px;
}

body {
    padding-bottom: calc(var(--action-bar-h) + 20px);
}

/* ----------------------------------------------------------------
 * Nagłówek
 * -------------------------------------------------------------- */
.audit-header {
    background: #ffffff;
    border-bottom: 1px solid var(--audit-border);
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.audit-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    color: #1a1a1a;
}

.audit-header #legal-basis {
    font-size: 0.78rem;
    line-height: 1.2;
    max-width: 800px;
}

.user-info {
    font-size: 0.9rem;
    color: #495057;
    background: #eef4ff;
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    border: 1px solid #cfe2ff;
    white-space: nowrap;
}

/* ----------------------------------------------------------------
 * Karty / sekcje
 * -------------------------------------------------------------- */
.card {
    border: 1px solid var(--audit-border);
    border-radius: 0.6rem;
}

.section-title {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    margin-bottom: 0.35rem;
}

.criterion-text {
    font-weight: 500;
    background: #f8f9fa;
    border-left: 4px solid var(--audit-primary);
    border-radius: 0.25rem;
    padding: 0.75rem 1rem;
    line-height: 1.5;
}

.item-header .badge { font-weight: 600; }

.question-section {
    border-left: 4px solid #0dcaf0;
    border-radius: 0.25rem;
    line-height: 1.5;
}

/* ----------------------------------------------------------------
 * Wizard (AI) – przycisk w nagłówku "Ustalenia audytowe"
 * -------------------------------------------------------------- */
.btn-wizard {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border-radius: 2rem;
    border: 1px solid #cfe2ff;
    background: linear-gradient(135deg, #e7f1ff 0%, #f5f9ff 100%);
    color: #0d6efd;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.05s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-wizard svg {
    flex-shrink: 0;
    display: block;
    transition: transform 0.3s ease;
}

.btn-wizard:hover:not(:disabled) {
    background: linear-gradient(135deg, #cfe2ff 0%, #e7f1ff 100%);
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.btn-wizard:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-wizard:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.35);
}

.btn-wizard:disabled {
    opacity: 0.65;
    cursor: progress;
}

/* Animacja ikony gdy wizard pracuje */
.btn-wizard.is-loading svg {
    animation: wizard-spin 1.1s linear infinite;
    transform-origin: 50% 50%;
}
@keyframes wizard-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Modal Wizard – drobne akcenty */
.wizard-modal-icon { color: #0d6efd; }
.wizard-modal-fields {
    margin: 0;
    padding-left: 1.2rem;
    columns: 2;
    column-gap: 1rem;
    font-size: 0.92rem;
}
.wizard-modal-fields li { margin-bottom: 0.15rem; }
@media (max-width: 576px) {
    .wizard-modal-fields { columns: 1; }
}

/* ----------------------------------------------------------------
 * Sloty dowodów (4 × 16:9)
 * -------------------------------------------------------------- */
.evidence-slots {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.evidence-slot {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #f8f9fa;
    border: 2px dashed #adb5bd;
    border-radius: 0.5rem;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s ease, background 0.15s ease;
    outline: none;
}

.evidence-slot:hover,
.evidence-slot:focus-visible {
    border-color: var(--audit-primary);
    background: #e7f1ff;
}

.evidence-slot.has-image {
    border: 1px solid var(--audit-border);
    border-style: solid;
    background: #000;
    cursor: zoom-in;
}

.slot-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: #6c757d;
    text-align: center;
    padding: 0.4rem;
}

.slot-empty span {
    font-size: 0.78rem;
    line-height: 1.1;
    font-weight: 600;
    color: #495057;
}

.slot-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.slot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.62);
    color: #ffffff;
    border: none;
    font-size: 1.05rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    padding: 0;
    transition: background 0.15s ease;
}

.slot-remove:hover {
    background: rgba(220, 53, 69, 0.92);
}

/* ----------------------------------------------------------------
 * Pasek akcji – CSS GRID, wymusza jeden wiersz i 3 kolumny:
 *   [ wstecz ]   [ Zapisz ]   [ dalej ]
 * -------------------------------------------------------------- */
.action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid var(--audit-border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1030;
    padding: 0.5rem 0.75rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0));
}

.action-bar-inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-group.prev-group {
    grid-column: 1;
    justify-self: start;
    display: flex;
    gap: 0.4rem;
    min-width: 0;
}

.save-group {
    grid-column: 2;
    justify-self: center;
    display: flex;
    align-items: center;
    position: relative;
}

.nav-group.next-group {
    grid-column: 3;
    justify-self: end;
    display: flex;
    gap: 0.4rem;
    min-width: 0;
}

.nav-group .btn-nav {
    min-height: 44px;
    white-space: nowrap;
    font-size: 0.92rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-save {
    min-height: 48px;
    min-width: 150px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 0.5rem;
}

.save-feedback {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 6px;
    padding: 0.3rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 1031;
}
.save-feedback.is-success { color: #198754; border: 1px solid #badbcc; }
.save-feedback.is-danger  { color: #dc3545; border: 1px solid #f5c2c7; }

/* ----------------------------------------------------------------
 * Responsywność
 * -------------------------------------------------------------- */
@media (max-width: 992px) {
    :root { --action-bar-h: 85px; }
}

@media (max-width: 768px) {
    .action-bar-inner { gap: 0.4rem; }
    .nav-group.prev-group,
    .nav-group.next-group { gap: 0.3rem; }
    .nav-group .btn-nav { font-size: 0.82rem; padding: 0.4rem 0.55rem; }
    .btn-save { min-width: 110px; font-size: 0.98rem; }

    .evidence-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 576px) {
    :root { --action-bar-h: 76px; }

    body { font-size: 14px; }

    .audit-header h1 { font-size: 1rem; }
    .audit-header #legal-basis { font-size: 0.72rem; }

    .card-body { padding: 0.9rem; }
    .criterion-text { padding: 0.6rem 0.75rem; }

    .action-bar { padding: 0.35rem 0.4rem; }
    .action-bar-inner { gap: 0.25rem; }

    .nav-group.prev-group,
    .nav-group.next-group { gap: 0.2rem; }

    .nav-group .btn-nav {
        font-size: 0.72rem;
        padding: 0.35rem 0.3rem;
        min-height: 40px;
    }

    .btn-save {
        min-height: 42px;
        min-width: 82px;
        font-size: 0.9rem;
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    #area-progress, #item-progress { font-size: 0.72rem; }

    .save-feedback { font-size: 0.78rem; padding: 0.25rem 0.5rem; }

    .slot-empty span { font-size: 0.7rem; }
    .slot-empty svg  { width: 22px; height: 22px; }

    /* Wizard: na bardzo małych ekranach tylko ikona */
    .btn-wizard { padding: 0.35rem 0.55rem; }
    .btn-wizard .wizard-label { display: none; }
}

#audit-board { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }