/* file: /css/irs_styles.css */

.progress-container {
    margin-bottom: 20px;
}

/* Upload header area */
.irs-upload-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.irs-upload-container *,
.irs-upload-container *::before,
.irs-upload-container *::after {
    box-sizing: border-box;
}

#irs-upload-form {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
}

/* Flex wrapper — admin: stacked; frontend: side-by-side on wide screens */
.irs-upload-flex-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    gap: 16px;
}

.irs-upload-context-frontend .irs-upload-flex-wrapper {
    flex-direction: row;
    max-width: 1200px;
    align-items: stretch;
}

@media (max-width: 768px) {
    .irs-upload-context-frontend .irs-upload-flex-wrapper {
        flex-direction: column;
    }
}

.irs-upload-context-admin.irs-upload-container {
    margin-bottom: 0;
}

.irs-upload-context-admin .irs-upload-flex-wrapper {
    max-width: 100%;
    min-width: 0;
}

.irs-upload-context-admin .irs-drop-area,
.irs-upload-context-admin #irs-drop-area {
    flex: 0 0 auto;
    min-height: 140px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.irs-upload-context-admin .irs-upload-button {
    width: 100%;
    max-width: 320px;
    min-width: 0;
    align-self: center;
}

.irs-upload-context-admin .irs-progress-area {
    max-width: 100%;
    margin: 16px 0 0;
}

/* Primary upload button */
.irs-upload-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ff7f00;
    color: #fff;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    flex-shrink: 0;
    min-width: 220px;
    text-align: center;
    align-self: center; /* Center vertically but don't stretch */
    height: fit-content; /* Don't stretch to match dropzone height */
}

.irs-upload-button:hover {
    background-color: #e66a00;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.irs-upload-button i {
    margin-right: 8px;
}

/* Hide the file input */
#irs-receipt-input { display: none; }

/* Progress area - hidden chrome when empty */
.irs-progress-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 12px;
    padding: 0; /* no padding when empty */
    background: transparent;
    border: 0;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.irs-progress-area:empty {
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: 0;
}

/* JSON result styling */
pre.json-result {
    background: #f8fafc;
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: auto;
    white-space: pre-wrap;
    max-height: 400px;
}

/* Container for the receipt data and image */
.receipt-container {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Upload result wrapper */
.irs-upload-result {
    margin-top: 12px;
    width: 100%;
    max-width: 100%;
}

.irs-upload-notice {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.irs-upload-notice-warning {
    background: #fff8e5;
    border: 1px solid #f0c33c;
    color: #6a5500;
}

.irs-file-item.partial {
    border-color: #f0c33c;
    background: #fffdf5;
}

.irs-file-item.partial .irs-file-status {
    color: #9a6700;
    font-weight: 600;
}

/* Receipt data card */
.receipt-data {
    flex: 2;
    min-width: min(100%, 320px);
    padding: 16px 18px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.irs-receipt-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px 20px;
}

.irs-data-group h4 {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7280;
}

.irs-data-group dl {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(72px, auto) 1fr;
    gap: 6px 12px;
    align-items: baseline;
}

.irs-data-group dt {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
}

.irs-data-group dd {
    margin: 0;
    font-size: 14px;
    color: #111827;
    word-break: break-word;
}

.irs-data-amount {
    font-size: 1.25rem !important;
    font-weight: 700;
    color: #111827;
}

.irs-field-empty {
    color: #d63638;
    font-style: italic;
}

.irs-data-line-items {
    margin-top: 16px;
    grid-column: 1 / -1;
}

.irs-line-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.irs-line-items-table th,
.irs-line-items-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef0f2;
    text-align: left;
}

.irs-line-items-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    background: #f9fafb;
}

.irs-line-items-table td:last-child,
.irs-line-items-table th:last-child {
    text-align: right;
    white-space: nowrap;
}

.irs-upload-result-actions {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eef0f2;
}

.irs-api-response-details {
    margin-top: 12px;
    width: 100%;
}

.irs-api-response-details summary {
    cursor: pointer;
    font-weight: 600;
    color: #374151;
    padding: 8px 0;
}

.irs-upload-fallback-msg {
    margin: 0;
    color: #374151;
}

/* Receipt image panel */
.receipt-image {
    flex: 1;
    min-width: min(100%, 240px);
    max-width: 360px;
}

.receipt-image img {
    max-width: 100%;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Generic progress bar */
.progress-bar {
    width: 100%;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

/* Dropzone */
#irs-drop-area,
.irs-drop-area {
    border: 2px dashed #ffad66;
    background: #fff7f0;
    color: #374151;
    padding: 24px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 180px;
    box-sizing: border-box;
}

.irs-upload-context-frontend #irs-drop-area,
.irs-upload-context-frontend .irs-drop-area {
    flex: 1;
}

#irs-drop-area.highlight {
    border-color: #ff7f00;
    background: #fff1e6;
    box-shadow: 0 0 0 3px rgba(255, 127, 0, 0.15) inset;
}

.irs-drop-icon {
    font-size: 36px;
    color: #ff7f00;
    margin-bottom: 12px;
}

.irs-drop-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.irs-drop-title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
}

.irs-drop-subtitle {
    font-size: 14px;
    color: #6b7280;
}

/* Per-file progress items */
.irs-file-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0; /* spacing handled by container gap */
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.irs-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.irs-file-name { font-weight: 600; color: #111827; }
.irs-file-status { color: #6b7280; }

/* State styles */
.irs-file-item.uploading .progress-bar-fill { background-color: #3b82f6; }
.irs-file-item.completed { border-color: #10b981; }
.irs-file-item.completed .irs-file-status { color: #065f46; }
.irs-file-item.completed .progress-bar-fill { background-color: #10b981; }
.irs-file-item.error { border-color: #ef4444; }
.irs-file-item.error .irs-file-status { color: #991b1b; }
.irs-file-item.error .progress-bar-fill { background-color: #ef4444; }

.irs-file-progress .progress-bar { height: 16px; }

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background-color: #10b981;
    transition: width 0.2s ease;
}

.progress-bar-text {
    position: relative;
    display: block;
    padding: 2px 6px;
    font-size: 12px;
    color: #111827;
}

/* Inline error for file item */
.irs-file-error {
    background: #fff8f8;
    border: 1px solid #fca5a5;
    color: #7f1d1d;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 6px 0 0 0;
}
