/* Component Styles - Forms, Buttons, Camera, Status */

.file-input-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    border: 2px dashed #007AFF;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s;
}

.file-input-wrapper:hover {
    background: #e9ecef;
    border-color: #0051D5;
}

.file-input-wrapper.has-image {
    border-color: #34C759;
    background: #f0fff4;
}

#cameraInput {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.camera-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.camera-text {
    color: #666;
    font-size: 14px;
}

.preview-image {
    display: none;
    max-width: 100%;
    max-height: 180px;
    border-radius: 8px;
    margin-top: 8px;
}

.status {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none;
}

.status.info { background: #E3F2FD; color: #1976D2; }
.status.success { background: #E8F5E9; color: #388E3C; }
.status.error { background: #FFEBEE; color: #C62828; }
.status.show { display: block; }

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
    font-size: 14px;
}

input, textarea, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #007AFF;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.button-group {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 16px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    display: flex;
    gap: 12px;
}

button {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #007AFF;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0051D5;
}

.btn-secondary {
    background: #5856D6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4845B4;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007AFF;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Logo ─────────────────────────────────────────────────────────── */

.logo-section {
    text-align: center;
    margin-bottom: 16px;
}

.logo-img {
    max-width: 200px;
    height: auto;
}

/* ── User Bar ─────────────────────────────────────────────────────── */

.user-bar {
    text-align: right;
    font-size: 12px;
    color: #8E8E93;
    padding: 0 4px 8px;
}

.user-bar a {
    color: #007AFF;
}

/* ── Edit Mode Banner ─────────────────────────────────────────────── */

#editModeIndicator {
    display: none;
    background: #FF9500;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
}

.edit-cancel-btn {
    background: none;
    border: none;
    color: white;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    font-size: 14px;
    padding: 0;
}

/* ── Action Button Row (Camera / Gallery / Scan) ──────────────────── */

.action-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-action {
    flex: 1;
    padding: 12px;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.btn-camera { background: #007AFF; }
.btn-gallery { background: #5856D6; }
.btn-scan { background: #FF9500; font-weight: 600; }

/* ── Barcode Scanner ──────────────────────────────────────────────── */

#barcodeScannerContainer {
    display: none;
    margin-bottom: 12px;
}

.scanner-viewport {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    border: 2px solid #FF9500;
    border-radius: 12px;
    background: #000;
}

.scanner-controls {
    text-align: center;
    margin-top: 8px;
}

#scanResult {
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.scanner-btn-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-capture {
    padding: 12px 24px;
    background: #34C759;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel-scan {
    padding: 12px 24px;
    background: #FF3B30;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* ── Hidden File Inputs ───────────────────────────────────────────── */

.file-input-hidden {
    display: none;
}

/* ── Image Preview ────────────────────────────────────────────────── */

#imagePreviewContainer {
    display: none;
    background: #f8f9fa;
    border: 2px solid #007AFF;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.preview-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

#imagePreviewList {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-process {
    width: 100%;
    padding: 12px;
    background: #34C759;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-clear {
    width: 100%;
    padding: 8px;
    background: #FF3B30;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 8px;
    cursor: pointer;
}

/* ── Loading Text ─────────────────────────────────────────────────── */

.loading-text {
    margin-top: 12px;
}

/* ── Form Helpers ─────────────────────────────────────────────────── */

.field-hint {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

#barcodeDupWarning {
    display: none;
    font-size: 12px;
    color: #FF9500;
    margin-top: 4px;
    font-weight: 600;
}

.qty-narrow {
    width: 100px;
}

/* ── Product Count ────────────────────────────────────────────────── */

#productCount {
    text-align: center;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

/* ── Bottom Bar Overrides ─────────────────────────────────────────── */

.btn-rescan {
    flex: 0.5;
}

/* ── User Login Overlay ───────────────────────────────────────────── */

#userLoginOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: #fff;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.overlay-header {
    text-align: center;
    margin-bottom: 24px;
}

.overlay-logo {
    max-width: 160px;
    height: auto;
    margin-bottom: 16px;
}

.overlay-title {
    margin: 0;
    font-size: 22px;
    color: #1c1c1e;
}

.overlay-subtitle {
    color: #8E8E93;
    margin: 0 0 20px;
    font-size: 15px;
}

.overlay-section {
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.overlay-add-wrapper {
    text-align: center;
    margin-top: 20px;
}

.overlay-back {
    color: #007AFF;
    font-size: 14px;
}

.overlay-back-wrapper {
    margin-top: 16px;
}

/* ── Modal Button Variants ────────────────────────────────────────── */

.modal-button--block {
    display: block;
    width: 100%;
}

.modal-button--gray {
    background: #8E8E93;
}

.modal-button--green {
    background: #34C759;
    margin-top: 8px;
}

.modal-button--orange {
    background: #FF9500;
}

.modal-button--blue {
    background: #007AFF;
    margin-top: 8px;
}

.modal-content--warning {
    border-color: #FF9500;
}

.modal-icon--warning {
    color: #FF9500;
}

/* ── View Navigation ─────────────────────────────────────────────── */

.view-nav {
    padding: 8px 0 4px;
}

.back-to-menu {
    color: #007AFF;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
}

.back-to-menu:hover {
    text-decoration: underline;
}

.no-bottom-bar {
    padding-bottom: 0 !important;
}

/* ── Menu Grid ───────────────────────────────────────────────────── */

.menu-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.menu-card:hover {
    border-color: #007AFF;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.15);
    transform: translateY(-2px);
}

.menu-card-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.menu-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #1c1c1e;
    margin-bottom: 6px;
}

.menu-card-desc {
    font-size: 13px;
    color: #8E8E93;
    line-height: 1.4;
}

.menu-card-badge {
    display: none;
    margin-top: 8px;
    background: #FF3B30;
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
}

.menu-card-badge.has-items {
    display: inline-block;
}

.btn-menu-export {
    display: block;
    width: 100%;
    max-width: 360px;
    margin: 24px auto 0;
    padding: 14px 20px;
    background: none;
    color: #007AFF;
    border: 2px solid #007AFF;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-menu-export:hover {
    background: #007AFF;
    color: #fff;
}

/* ── Quick Capture Styles ────────────────────────────────────────── */

.capture-counter {
    background: #E3F2FD;
    color: #1976D2;
    text-align: center;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 16px;
}

.btn-capture-next {
    display: block;
    width: 100%;
    padding: 16px;
    margin: 16px 0;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-capture-next:hover {
    background: #388E3C;
}

.btn-capture-save {
    display: block;
    width: 100%;
    padding: 16px;
    margin: 12px 0;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-capture-save:hover {
    background: #0051D5;
}
.btn-capture-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Staged Photo Previews ───────────────────────────────────────── */

.staged-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border: 2px solid #007AFF;
    border-radius: 12px;
    margin: 12px 0;
}

.staged-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.staged-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.staged-thumb-num {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
}

.capture-drop-zone {
    display: none;
    border: 2px dashed #007AFF;
    border-radius: 12px;
    padding: 32px 16px;
    text-align: center;
    margin-bottom: 16px;
    transition: all 0.2s;
    cursor: pointer;
}

@media (min-width: 768px) {
    .capture-drop-zone {
        display: block;
    }
}

.capture-drop-zone.drag-over {
    background: #E3F2FD;
    border-color: #0051D5;
}

.drop-zone-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.drop-zone-text {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.drop-zone-hint {
    font-size: 13px;
    color: #8E8E93;
    margin-top: 4px;
}

.recent-captures-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.recent-captures-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-capture-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.recent-capture-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.recent-capture-info {
    flex: 1;
    min-width: 0;
}

.recent-capture-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-capture-time {
    font-size: 12px;
    color: #8E8E93;
}
