/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff;
    color: #222;
    min-height: 100vh;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal-box h2 {
    font-size: 20px;
    margin-bottom: 16px;
    color: #222;
}

.modal-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-box input:focus {
    border-color: #333;
}

.modal-box button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #222;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-box button:hover {
    background: #444;
}

.error-text {
    color: #c00;
    font-size: 13px;
    margin-top: 8px;
    min-height: 18px;
}

/* ===== Trial Banner ===== */
.trial-banner {
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
    padding: 8px 24px;
    font-size: 13px;
    color: #666;
    text-align: center;
    position: relative;
    transition: all 0.4s ease;
}

.trial-banner.hidden {
    display: none;
}

.trial-banner.warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}

.trial-banner.urgent {
    background: linear-gradient(90deg, #fff3cd 0%, #ffe0b2 50%, #fff3cd 100%);
    background-size: 200% 100%;
    animation: urgentShimmer 2s ease-in-out infinite;
    color: #e65100;
    border-color: #ffcc80;
    font-weight: 600;
}

@keyframes urgentShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.trial-banner.expired {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.trial-dismiss-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s;
}

.trial-dismiss-btn:hover {
    background: rgba(0,0,0,0.08);
    color: #555;
}

/* ===== Drop Zone ===== */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin: 24px;
    position: relative;
}

.drop-zone.drag-over {
    border-color: #333;
    background: #f5f5f5;
}

.drop-zone.has-results {
    padding: 20px 24px;
    margin-bottom: 0;
}

.drop-zone.has-results .drop-zone-content svg {
    display: none;
}

.drop-zone.has-results .sub-text {
    display: none;
}

.drop-zone-content svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.drop-zone-content p {
    font-size: 16px;
    color: #666;
    margin-top: 4px;
}

.drop-zone-content .click-text {
    color: #333;
    text-decoration: underline;
    font-weight: 500;
}

.drop-zone-content .sub-text {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

/* ===== Camera Button ===== */
.camera-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: #222;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 5;
}

.camera-btn:hover {
    background: #444;
}

@media (min-width: 769px) {
    .camera-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    margin: 0 24px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 14px;
    color: #555;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
    margin: 0 24px;
}

.toolbar-btn {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.15s;
}

.toolbar-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

/* ===== Results Container ===== */
.results-container {
    padding: 16px 24px;
}

/* ===== Receipt Card ===== */
.receipt-card {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    background: #fff;
    animation: fadeIn 0.3s ease;
    position: relative;
}

/* ===== Delete Card Button ===== */
.delete-card-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(200, 0, 0, 0.75);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    opacity: 0;
    pointer-events: none;
}

.receipt-card:hover .delete-card-btn {
    opacity: 1;
    pointer-events: auto;
}

.delete-card-btn:hover {
    background: rgba(180, 0, 0, 1);
    transform: scale(1.15);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.receipt-card-image {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    border-right: 1px solid #eee;
}

.receipt-card-image img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.receipt-card-image img:hover {
    opacity: 0.85;
}

.receipt-card-data {
    flex: 1;
    padding: 16px 20px;
    min-width: 0;
}

.receipt-card-data h3 {
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* ===== Data Row ===== */
.data-row {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
    gap: 8px;
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 0 0 120px;
    white-space: nowrap;
}

.data-value {
    flex: 1;
    font-size: 14px;
    color: #222;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    transition: background 0.15s;
    min-width: 0;
    word-break: break-word;
    user-select: all;
}

.data-value:hover {
    background: #f0f0f0;
}

.copy-btn {
    flex: 0 0 auto;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
    color: #333;
}

.copy-btn.copied {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* ===== Copy All Button ===== */
.copy-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    margin-left: auto;
    transition: all 0.15s;
}

.copy-all-btn:hover {
    background: #f0f0f0;
    border-color: #bbb;
    color: #333;
}

/* ===== Re-extract Button ===== */
.reextract-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.15s;
}

.reextract-btn:hover {
    background: #e8f4fd;
    border-color: #5ba3d9;
    color: #2980b9;
}

/* ===== Duplicate Toast ===== */
.duplicate-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 5000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transition: opacity 0.3s;
    pointer-events: none;
    animation: fadeIn 0.3s ease;
}

/* ===== Error Card ===== */
.error-card {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
    background: #fafafa;
    color: #c00;
    font-size: 14px;
}

/* ===== Streaming indicator ===== */
.streaming-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #333;
    border-radius: 50%;
    margin-left: 6px;
    animation: pulse 1s ease infinite;
    vertical-align: middle;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1000;
}

.lightbox-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-content {
    position: relative;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.lightbox-controls button {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.lightbox-controls button:hover {
    background: rgba(0,0,0,0.8);
}

.lightbox-img-wrapper {
    overflow: auto;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img-wrapper img {
    object-fit: contain;
    transition: width 0.2s ease, height 0.2s ease;
    -webkit-user-drag: none;
    user-select: none;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .receipt-card {
        flex-direction: column;
    }
    .receipt-card-image {
        flex: none;
        max-width: 100%;
    }
    .receipt-card-data {
        padding: 12px 16px;
    }
    .data-label {
        flex: 0 0 100px;
    }
    .toolbar {
        padding: 8px 16px;
    }
    .delete-card-btn {
        opacity: 1;
        pointer-events: auto;
    }
}
/* ===== Small Copy Buttons (for table headers) ===== */
.copy-btn-small {
    flex: 0 0 auto;
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 10px;
    color: #666;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.copy-btn-small:hover {
    background: #f0f0f0;
    border-color: #bbb;
    color: #333;
}

/* ===== Mini Copy Buttons (for table rows) ===== */
.copy-btn-mini {
    flex: 0 0 auto;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 11px;
    color: #999;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.5;
}

.copy-btn-mini:hover {
    opacity: 1;
    background: #f0f0f0;
    border-color: #ddd;
    color: #333;
}

.copy-btn-mini.copied {
    color: #27ae60;
    opacity: 1;
}

/* ===== Table Row Selection ===== */
.table-row-selectable {
    cursor: pointer;
    transition: background 0.15s;
}

.table-row-selectable:hover {
    background: #f8f9fa;
}

.table-row-selectable:hover .copy-btn-mini {
    opacity: 1;
}

.row-copied {
    background: #d4edda !important;
}

/* ===== Data Value - Click to Select ===== */
.data-value {
    cursor: pointer;
    transition: all 0.15s;
}

.data-value::selection {
    background: #b3d7ff;
}

/* ===== Items Table ===== */
.items-table {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.items-table thead {
    background: #f8f9fa;
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Data Value JSON (for object display) ===== */
.data-value-json {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 6px 10px;
}

.data-value-json:hover {
    background: #f0f0f0;
}