:root {
    --primary-color: #1a73e8;
    --primary-dark: #1557b0;
    --secondary-color: #34a853;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --border-color: #dadce0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header-title .material-icons {
    font-size: 1.8rem;
}

/* Scanner Container */
.scanner-container {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.camera-wrapper {
    position: relative;
    background: #000;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1rem;
}

#video {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
    background: #000;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-frame {
    width: 200px;
    height: 200px;
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius);
    position: relative;
    animation: scanner-pulse 2s infinite;
}

.scanner-frame::before,
.scanner-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--secondary-color);
}

.scanner-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.scanner-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

@keyframes scanner-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Camera Controls */
.camera-controls {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.control-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    touch-action: manipulation;
    user-select: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.control-btn.active {
    background: var(--warning-color);
    color: white;
}

.zoom-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 1rem;
    border-radius: 24px;
    backdrop-filter: blur(10px);
}

.zoom-icon {
    color: white;
    font-size: 1.2rem;
}

.zoom-slider {
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    -webkit-appearance: none;
    touch-action: manipulation;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}

.zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
}

/* Scanner Status */
.scanner-status {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
    font-weight: 500;
    color: var(--text-secondary);
}

.scanner-status.success {
    background: var(--secondary-color);
    color: white;
}

.scanner-status.error {
    background: var(--danger-color);
    color: white;
}

/* Results Container */
.results-container {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.results-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Scanned List */
.scanned-list {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.scanned-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.scanned-item:last-child {
    border-bottom: none;
}

.scanned-item:hover {
    background: var(--bg-secondary);
}

.item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.item-icon {
    color: var(--secondary-color);
    font-size: 1.5rem;
}

.item-details {
    flex: 1;
}

.item-code {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.item-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: rgba(234, 67, 53, 0.1);
    transform: scale(1.1);
}

/* Combined Results */
.combined-results {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
}

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

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.input-group input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--bg-secondary);
    transition: border-color 0.3s ease;
    touch-action: manipulation;
    user-select: all;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

.btn-danger:hover {
    background: #d33b2c;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: toast-in 0.3s ease;
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state .material-icons {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header-title {
        font-size: 1.25rem;
    }
    
    #video {
        height: 250px;
    }
    
    .scanner-frame {
        width: 150px;
        height: 150px;
    }
    
    .camera-controls {
        bottom: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
    }
    
    .zoom-container {
        padding: 0.25rem 0.75rem;
    }
    
    .zoom-slider {
        width: 80px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .toast {
        min-width: auto;
        max-width: calc(100vw - 2rem);
    }
    
    .toast-container {
        right: 1rem;
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .scanner-container,
    .results-container {
        padding: 0.75rem;
    }
    
    .combined-results {
        padding: 1rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .scanned-item {
        padding: 0.75rem;
    }
    
    .item-code {
        font-size: 0.9rem;
    }
}

/* PWA Styles */
@media (display-mode: standalone) {
    .header {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
    
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Loading Animation */
@keyframes loading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading {
    animation: loading 1s linear infinite;
}

/* Focus visible for accessibility */
.btn:focus-visible,
.control-btn:focus-visible,
.delete-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}