/* ===== Page Layout (with sidebar) ===== */
.page-layout {
    min-height: 100vh;
    background: var(--bg-secondary);
}

.page-main {
    margin-left: 260px;
}

.page-topbar {
    background: white;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-primary);
}

.back-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.page-title h2 {
    font-size: 1.2rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-title p {
    font-size: var(--ui-subtext-size);
    font-weight: var(--ui-subtext-weight);
    color: var(--text-muted);
}

.page-content {
    padding: 28px 32px;
    max-width: 900px;
}

.page-content-wide {
    max-width: 1100px;
}

/* ===== Entry Form Card ===== */
.entry-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    overflow: hidden;
    margin-bottom: 24px;
}

.entry-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
}

.entry-card-header h3 {
    font-size: var(--ui-title-size);
    font-weight: var(--ui-title-weight);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05em;
    height: 1.05em;
    line-height: 1;
    flex-shrink: 0;
}

.entry-card-body {
    padding: 24px;
}

.field-uppercase {
    text-transform: uppercase;
}

.form-input-readonly {
    background: #f8fafc;
    cursor: not-allowed;
}

.form-input-highlight {
    background: #f0f9ff;
    color: #1e40af;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: default;
}

.form-group-end {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.checkbox-inline-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding-bottom: 10px;
    font-weight: 500;
}

.checkbox-inline-label > input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ===== Entry Method Tabs ===== */
.entry-methods {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.entry-method-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text-secondary);
    min-height: 120px;
    justify-content: center;
}

.entry-method-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.entry-method-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.entry-method-btn .method-icon {
    font-size: 2rem;
    line-height: 1;
}

.entry-method-btn .method-label {
    font-size: 0.88rem;
    font-weight: 600;
}

.entry-method-btn .method-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.35;
    min-height: 2.1em;
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Items Table ===== */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.items-table th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.items-table td:last-child {
    text-align: center;
}

.items-table .form-input {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.items-table .item-total {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.items-table .item-qty {
    width: 70px;
}

.items-table .item-rate,
.items-table .item-gst-amount-field {
    width: 100px;
}

.items-table .item-gst {
    width: 90px;
}

.items-table .item-cess {
    width: 70px;
}

.items-table .item-gst-amount-field {
    text-align: right;
}

.add-item-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: none;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.add-item-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.remove-item-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--danger-light);
    color: var(--danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-item-btn:hover {
    background: var(--danger);
    color: white;
}

/* ===== Totals Summary ===== */
.totals-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.totals-box {
    width: 300px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    border: 1px solid var(--border-light);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.totals-row.total-final {
    border-top: 2px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* ===== Scan Area ===== */
.scan-area {
    border: 3px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    background: var(--bg-secondary);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.scan-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.scan-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.01);
}

.scan-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.scan-area h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.scan-area p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.scan-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.scan-area input[type="file"] {
    display: none;
}

/* Scan preview */
.scan-preview {
    display: none;
    margin-top: 24px;
}

.scan-preview.active {
    display: block;
}

.scan-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.preview-image-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border);
}

.preview-image-box img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.extracted-data {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.extracted-data-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.extracted-data-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-badge-ai {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
}

.extracted-data-body {
    padding: 16px 20px;
}

.extracted-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.extracted-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.extracted-value {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.scanning-animation {
    display: none;
    padding: 40px;
    text-align: center;
}

.scanning-animation.active {
    display: block;
}

.scan-status-title {
    font-weight: 600;
}

.scan-status-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.scan-note {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.header-link-compact {
    font-size: 12px;
    color: #6c3ce1;
    font-weight: 600;
    text-decoration: none;
}

.scanning-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* ===== Camera View ===== */
.camera-container {
    position: relative;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.camera-container video {
    width: 100%;
    display: block;
    border-radius: var(--radius-lg);
}

.camera-container canvas {
    display: none;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.camera-frame {
    width: 80%;
    height: 60%;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-md);
    position: relative;
}

.camera-frame::before {
    content: 'Position the bill in the frame';
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.85rem;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
/* Pseudo-element strings aren't covered by the JS setLanguage() pass
   (which only swaps text on [data-hi][data-en] nodes). Switch via the
   <html lang> attribute that the prepaint script sets. */
html[lang="hi"] .camera-frame::before { content: 'बिल को फ्रेम में रखें'; }

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.is-hidden {
    display: none !important;
}

.mt-16 {
    margin-top: 16px;
}

.mt-12 {
    margin-top: 12px;
}

.capture-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.capture-btn:hover {
    background: var(--primary);
    color: white;
}

/* ===== GST Filing Steps ===== */
.gst-steps {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.gst-step-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    background: white;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.gst-step-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.gst-step-btn.completed {
    border-color: var(--success);
    color: var(--success);
}

/* ===== Summary Table ===== */
.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.summary-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.summary-table tr:hover {
    background: var(--bg-secondary);
}

/* ===== Action Bar ===== */
.action-bar {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.action-bar .btn {
    min-width: 180px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== Mobile Responsive Utilities ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .page-main {
        margin-left: 0;
    }

    .page-topbar {
        padding: 12px 16px;
    }

    .page-main > .page-topbar {
        position: fixed !important;
        top: 0 !important;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 80 !important;
    }

    .page-main > .page-topbar + * {
        margin-top: 72px;
    }

    .page-content {
        padding: 20px 16px;
    }

    .entry-methods {
        flex-direction: column;
    }

    .entry-method-btn {
        min-height: auto;
        padding: 16px 14px;
    }

    .scan-preview-grid {
        grid-template-columns: 1fr;
    }

    .items-table {
        font-size: 0.85rem;
    }

    .totals-summary {
        justify-content: stretch;
    }

    .totals-box {
        width: 100%;
    }

    .action-bar {
        flex-wrap: wrap;
    }

    .action-bar .btn {
        flex: 1 1 180px;
        justify-content: center;
    }

}
