:root {
    --bg-color: #0d0d12;
    --surface-color: #1a1a24;
    --surface-highlight: #2a2a35;
    --text-primary: #ffffff;
    --text-secondary: #a0a0ab;
    --primary-color: #00ff88;
    --primary-hover: #00cc6a;
    --error-color: #ff3366;
    --success-color: #00ff88;
    --border-radius: 16px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden; /* Evita scroll no body do PWA */
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(13, 13, 18, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10;
    position: absolute;
    top: 0;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo .highlight {
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-btn.active {
    background: var(--primary-color);
    color: #000;
}

/* Scanner Container */
.scanner-container {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#reader {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

#reader video {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
}

/* Oculta máscara nativa e botões do html5-qrcode para usarmos nosso design centralizado */
#qr-shaded-region,
#reader__dashboard_section_csr span,
#reader__dashboard_section_swaplink {
    display: none !important;
}



.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
}

/* Fake hole nas bordas para ver a câmera clara no centro - implementado via mask ou rgba no html5-qrcode, 
mas como temos overlay próprio, faremos uma caixa de foco */
.focus-box {
    width: 250px;
    height: 150px;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    overflow: hidden;
    background: transparent;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.5); /* Efeito de máscara escura */
}

.corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary-color);
    border-style: solid;
}

.top-left { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-top-left-radius: 12px; }
.top-right { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-top-right-radius: 12px; }
.bottom-left { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-bottom-left-radius: 12px; }
.bottom-right { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-bottom-right-radius: 12px; }

.laser {
    width: 100%;
    height: 2px;
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
    position: absolute;
    top: 0;
    animation: scan 2s infinite linear;
}

@keyframes scan {
    0% { top: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.scan-hint {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.6);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    z-index: 2;
}

/* Bottom Sheet */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface-color);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.bottom-sheet.show {
    transform: translateY(0);
}

.bottom-sheet.hidden {
    display: none; /* Só usa isso pra instanciar, depois remove a classe e usa o show */
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--surface-highlight);
    border-radius: 2px;
    margin: 0 auto 1.5rem auto;
}

.sheet-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 200px;
}

/* States do Bottom Sheet */
.result-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.result-state.hidden {
    display: none;
}

.status-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.status-icon.success {
    background: rgba(0, 255, 136, 0.1);
    color: var(--success-color);
}

.status-icon.error {
    background: rgba(255, 51, 102, 0.1);
    color: var(--error-color);
}

.product-info {
    margin-bottom: 1.5rem;
    width: 100%;
}

.barcode-display {
    font-family: monospace;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

#product-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#product-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stock-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.error-msg {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--text-primary);
    color: #000;
}

.btn-primary:hover {
    background: #e0e0e0;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin-bottom: 1rem;
}

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

/* Modal Estilizado (Configurações) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface-color);
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input[type="url"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--surface-highlight);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    outline: none;
}

.form-group input[type="url"]:focus {
    border-color: var(--primary-color);
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-highlight);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}
