/* Dedicated receipts screen (index → Reçus), mobile-first. */

.ka-receipts {
    box-sizing: border-box;
    width: 100%;
    padding: 1ex 1ch 2ex;
    font-family: var(--ka-text-default-font, sans-serif);
    color: var(--text-color, #111);
}

.ka-receipts-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1ch;
    margin-bottom: 1.2ex;
}

.ka-receipts-title {
    margin: 0;
    font-size: 14pt;
    color: var(--company-text-color, #fff);
    background-color: var(--title-background-color, var(--company-color-dark, #333));
    padding: 0.6ex 1ch;
    flex: 1 1 auto;
    text-align: center;
}

.ka-receipts-day-label {
    font-weight: bold;
    font-size: 11pt;
    padding: 0 0.5ch;
    white-space: nowrap;
}

.ka-receipts-day-label.ka-receipts-day-missing {
    font-weight: normal;
    font-style: italic;
    opacity: 0.7;
}

.ka-receipts-browse {
    position: relative;
    min-height: 40vh;
}

.ka-receipts-browse[hidden],
.ka-receipts-stage[hidden] {
    display: none !important;
}

.ka-receipts-stage {
    display: flex;
    flex-direction: column;
    gap: 1.2ex;
    padding: 1ex 1ch 1.5ex;
    border: 1px solid color-mix(in srgb, var(--text-color, #000) 18%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--text-color, #000) 4%, var(--background-color, #fff));
}

.ka-receipts-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 1ch;
    justify-content: center;
}

.ka-receipts-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4ex;
    max-width: 100%;
}

.ka-receipts-preview img {
    max-width: min(100%, 320px);
    max-height: 42vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    background: color-mix(in srgb, var(--text-color, #000) 8%, transparent);
}

.ka-receipts-preview-file {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border-radius: 6px;
    font-weight: bold;
    background: color-mix(in srgb, var(--text-color, #000) 8%, transparent);
}

.ka-receipts-preview-name {
    font-size: 0.85em;
    opacity: 0.75;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ka-receipts-flag {
    display: flex;
    align-items: center;
    gap: 0.8ch;
    font-size: 12pt;
    cursor: pointer;
    user-select: none;
    min-height: 44px;
}

.ka-receipts-flag input {
    min-height: auto;
    min-width: auto;
    width: 1.35em;
    height: 1.35em;
    margin: 0;
}

.ka-receipts-stage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8ch;
    margin-top: 0.5ex;
}

.ka-receipts-stage-actions button {
    flex: 1 1 30%;
    min-height: 48px;
    font-weight: bold;
    font-size: 12pt;
    cursor: pointer;
}

button.ka-receipts-save {
    background-color: var(--ka-background-button-color, #0a7);
    color: var(--ka-button-color, #fff);
    border: none;
}

button.ka-receipts-save.ka-receipts-busy,
button.ka-receipts-save:disabled,
button.ka-receipts-cancel:disabled,
button.ka-receipts-retake:disabled {
    opacity: 0.55;
    pointer-events: none;
}

button.ka-receipts-add-btn {
    position: sticky;
    bottom: calc(1ex + env(safe-area-inset-bottom, 0px));
    margin: 2ex auto 0;
    display: flex;
    min-width: 56px;
    max-width: 56px;
    min-height: 56px;
    max-height: 56px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background-color: var(--ka-background-button-color, #0a7);
    color: var(--ka-button-color, #fff);
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

button.ka-receipts-add-btn:active {
    transform: scale(0.96);
}

.ka-receipts-list {
    display: flex;
    flex-direction: column;
}

.ka-receipts-empty {
    margin: 2ex 1ch;
    text-align: center;
    opacity: 0.8;
    line-height: 1.4;
}

.ka-receipts-item {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 1ch;
    align-items: center;
    padding: 0.9ex 0.5ch;
    border-bottom: 1px solid color-mix(in srgb, var(--text-color, #000) 12%, transparent);
    cursor: pointer;
}

.ka-receipts-item:active {
    background: color-mix(in srgb, var(--text-color, #000) 6%, transparent);
}

.ka-receipts-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    background: color-mix(in srgb, var(--text-color, #000) 8%, transparent);
}

.ka-receipts-thumb-file {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9pt;
    font-weight: bold;
}

.ka-receipts-item-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2ex;
}

.ka-receipts-item-name {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ka-receipts-item-sub {
    font-size: 0.85em;
    opacity: 0.7;
}

.ka-receipts-item-tags {
    font-size: 0.8em;
    font-weight: bold;
    opacity: 0.85;
}

button.ka-receipts-item-delete {
    min-height: 44px;
    min-width: 44px;
    max-width: none;
    width: auto;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 14pt;
    cursor: pointer;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Full-screen receipt viewer */
.ka-receipts-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.ka-receipts-lightbox-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1ch;
    padding: 0.8ex 1ch;
    padding-top: calc(0.8ex + env(safe-area-inset-top, 0px));
    background: rgba(0, 0, 0, 0.55);
}

.ka-receipts-lightbox-name {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

button.ka-receipts-lightbox-close {
    min-height: 44px;
    min-width: 44px;
    max-width: none;
    width: auto;
    margin: 0;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 18pt;
    cursor: pointer;
    box-shadow: none;
}

.ka-receipts-lightbox-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 1ch;
    box-sizing: border-box;
}

.ka-receipts-lightbox-media {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border: none;
    border-radius: 4px;
    background: #111;
}

iframe.ka-receipts-lightbox-media {
    width: 100%;
    height: 100%;
}

.ka-receipts-lightbox-loading,
.ka-receipts-lightbox-error {
    opacity: 0.85;
    text-align: center;
    padding: 2ex;
}

.ka-receipts-lightbox-foot {
    display: flex;
    flex-direction: column;
    gap: 0.6ex;
    padding: 1ex 1ch;
    padding-bottom: calc(1ex + env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.55);
}

.ka-receipts-lightbox-flag {
    color: #fff;
}

.ka-receipts-lightbox-ticket {
    font-size: 11pt;
    opacity: 0.85;
    padding-left: calc(1.35em + 0.8ch);
}
