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

:root {
    --primary-color: #4a90e2;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Screen Management */
.screen {
    min-height: 100vh;
    padding: 20px;
}

/* Config Screen */
.config-container {
    max-width: 500px;
    margin: 50px auto;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.config-container h1 {
    margin-bottom: 20px;
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
}

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

.error-message {
    color: var(--danger-color);
    margin-top: 10px;
    padding: 10px;
    background: #fee;
    border-radius: 4px;
}

/* Main Screen */
.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--card-bg);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 24px;
}

/* Scanner Section */
.scanner-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

#video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

#video {
    width: 100%;
    height: auto;
    display: block;
}

#canvas {
    display: none;
}

.status-message {
    text-align: center;
    padding: 10px;
    color: #666;
    font-size: 14px;
}

/* Product Info */
.product-info {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.product-header h2 {
    font-size: 20px;
    word-break: break-all;
}

.product-state {
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 4px;
}

.state-label {
    font-weight: 500;
    margin-right: 10px;
}

.state-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

.state-badge.disponibile {
    background: var(--success-color);
    color: white;
}

.state-badge.venduto {
    background: #6c757d;
    color: white;
}

.state-badge.prenotato {
    background: var(--warning-color);
    color: #333;
}

.actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.message {
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 14px;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #357abd;
}

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

.btn-action:hover {
    background: #357abd;
}

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

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

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    color: var(--text-color);
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

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

.modal-header h2 {
    font-size: 20px;
}

.modal-body {
    padding: 20px;
}

.danger-zone {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--danger-color);
}

.danger-zone label {
    color: var(--danger-color);
    font-weight: 600;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

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

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

.loading-text {
    margin-top: 15px;
    color: var(--text-color);
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 20px;
    }

    .actions {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }
}

