/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.9;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

/* Input section */
.input-section {
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 1rem;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 20px;
    z-index: 1;
}

/* Barcode input container with prefix */
.barcode-input-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.barcode-input-container:focus-within {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.barcode-prefix {
    padding: 16px 8px 16px 52px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    letter-spacing: 1px;
    background: transparent;
    border-right: 1px solid #ddd;
    user-select: none;
}

#barcodeInput {
    flex: 1;
    padding: 16px 16px 16px 8px;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    letter-spacing: 1px;
    outline: none;
}


#barcodeInput::placeholder {
    color: #999;
    font-weight: 400;
    letter-spacing: normal;
}

.scan-button {
    min-width: 56px;
    height: 56px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.scan-button:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.scan-button:active {
    transform: translateY(0);
}

.lookup-button {
    width: 100%;
    padding: 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.lookup-button:hover {
    background: #218838;
    transform: translateY(-1px);
}

.lookup-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.button-icon {
    font-size: 20px;
}

/* Loading section */
.loading-section {
    text-align: center;
    padding: 2rem 0;
}

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

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

/* Error section */
.error-section {
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 12px;
    padding: 1rem;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.error-icon {
    color: #dc3545;
    font-size: 24px;
}

.error-content p {
    color: #721c24;
    font-weight: 500;
}

/* Success section */
.success-section {
    background: #f0f9f0;
    border: 1px solid #c3e6c3;
    border-radius: 12px;
    padding: 1.5rem;
}

.balance-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.success-icon {
    color: #28a745;
    font-size: 28px;
}

.balance-header h3 {
    color: #155724;
    font-size: 1.25rem;
    font-weight: 600;
}

.balance-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #d4edda;
}

.balance-item.main-balance {
    background: #28a745;
    color: white;
    border-color: #1e7e34;
}

.balance-item label {
    font-weight: 500;
    font-size: 0.9rem;
}

.balance-amount {
    font-size: 1.75rem;
    font-weight: 700;
}

.budget-amount {
    font-size: 1.25rem;
    font-weight: 600;
    color: #28a745;
}

.balance-item.main-balance .budget-amount {
    color: white;
}

/* Scanner Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: #666;
    transition: all 0.2s ease;
}

.close-button:hover {
    background: #f5f5f5;
    color: #333;
}

.scanner-container {
    position: relative;
    background: #000;
}

.scanner-video {
    width: 100%;
    height: 300px;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.scanner-frame {
    width: 200px;
    height: 120px;
    border: 2px solid #fff;
    border-radius: 8px;
    position: relative;
}

.scanner-frame::before,
.scanner-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #667eea;
}

.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;
}

.scanner-instructions {
    color: white;
    font-size: 0.9rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
}

.scanner-controls {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: center;
}

.control-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-button:hover {
    background: #e9ecef;
}

/* Footer */
.footer {
    margin-top: 2rem;
    text-align: center;
}

.environment-indicator {
    display: inline-block;
}

.env-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.env-badge.production {
    background: rgba(220, 53, 69, 0.8);
}

.env-badge.integration {
    background: rgba(255, 193, 7, 0.8);
    color: #333;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 640px) {
    .container {
        padding: 16px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .card {
        padding: 1.5rem;
    }

    .input-group {
        flex-direction: column;
        gap: 8px;
    }

    .scan-button {
        width: 100%;
        height: 48px;
    }

    .balance-info {
        gap: 0.75rem;
    }

    .balance-item {
        padding: 0.75rem;
    }

    .balance-amount {
        font-size: 1.5rem;
    }

    .budget-amount {
        font-size: 1.1rem;
    }

    .modal {
        padding: 10px;
    }

    .scanner-video {
        height: 250px;
    }

    .scanner-frame {
        width: 160px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    #barcodeInput {
        padding: 14px 14px 14px 48px;
        font-size: 14px;
    }

    .input-icon {
        left: 14px;
        font-size: 18px;
    }

    .lookup-button {
        padding: 14px;
        font-size: 15px;
    }
}