* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', 'Source Han Sans TC', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #4a5568;
}

header p {
    font-size: 1.1rem;
    color: #718096;
}

section {
    background: rgba(255, 255, 255, 0.95);
    margin-bottom: 25px;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #2d3748;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

/* Category Selection */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.category-btn {
    padding: 20px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

.category-btn:hover {
    border-color: #667eea;
    background: #f7fafc;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.category-btn.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.selected-category {
    text-align: center;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
    font-weight: 600;
    color: #4a5568;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.reset-btn {
    padding: 8px 16px;
    border: 2px solid #e53e3e;
    background: white;
    color: #e53e3e;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: #e53e3e;
    color: white;
    transform: translateY(-1px);
}

.reload-btn {
    padding: 10px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.reload-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.reload-btn:disabled {
    background: #a0aec0;
    border-color: #a0aec0;
    color: #718096;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.category-controls {
    text-align: center;
    margin-bottom: 20px;
}

/* Scanner Controls */
.scanner-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.scan-btn, .submit-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.scan-btn {
    background: #48bb78;
    color: white;
}

.scan-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

.scan-btn.secondary {
    background: #e53e3e;
}

.scan-btn.secondary:hover {
    background: #c53030;
}

.scan-btn:disabled, .submit-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.submit-btn {
    background: #667eea;
    color: white;
}

.submit-btn:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* QR Reader */
.qr-reader {
    max-width: 100%;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

#qr-reader {
    background: #f7fafc;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #cbd5e0;
}

#qr-reader video {
    width: 100% !important;
    height: auto !important;
    border-radius: 8px;
}

.scan-results {
    margin-top: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
    min-height: 50px;
    text-align: center;
    color: #718096;
}

.scan-results.success {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

/* Manual Entry */
.input-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

#manual-qr-input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 200px;
}

#manual-qr-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Results */
.results-list {
    max-height: 300px;
    overflow-y: auto;
}

.result-item {
    padding: 15px;
    margin-bottom: 10px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #48bb78;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-time {
    font-size: 0.875rem;
    color: #718096;
    font-weight: 600;
}

.result-category {
    font-weight: 600;
    color: #667eea;
    margin: 5px 0;
}

.result-data {
    font-family: monospace;
    background: white;
    padding: 8px;
    border-radius: 4px;
    word-break: break-all;
    border: 1px solid #e2e8f0;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loader {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Messages */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    max-width: 400px;
}

.message {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    font-weight: 600;
    animation: slideIn 0.3s ease-out;
}

.message.success {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.message.info {
    background: #e6f3ff;
    color: #1a365d;
    border: 1px solid #63b3ed;
}

.message.error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes alertSlideIn {
    from {
        transform: scale(0.8) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes alertSlideOut {
    from {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    to {
        transform: scale(0.8) translateY(-20px);
        opacity: 0;
    }
}

.qr-alert-overlay {
    animation: alertSlideIn 0.3s ease-out;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    section {
        padding: 20px;
    }
    
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .category-btn {
        padding: 15px 10px;
        font-size: 0.9rem;
    }
    
    .scanner-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .scan-btn, .submit-btn {
        min-width: 100%;
    }
    
    .message-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
} 