/* Import Carnas font */
@import url('https://fonts.googleapis.com/css2?family=Carnas:wght@400;700&display=swap');

/* Grundlegendes Container-Styling */
.barcode-lookup-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 25px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    font-family: 'Carnas', sans-serif;
}

/* Formular-Styling */
.barcode-lookup-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-family: 'Carnas', sans-serif;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: 'Carnas', sans-serif;
}

.form-group label {
    font-weight: 600;
    color: #303030;
    font-size: 15px;
    font-family: 'Carnas', sans-serif;
}

.form-hint {
    color: #303030;
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
    font-family: 'Carnas', sans-serif;
}

.input-group {
    display: flex;
    align-items: stretch;
    position: relative;
    font-family: 'Carnas', sans-serif;
}

/* Input Styling */
input[type="text"] {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Carnas', sans-serif;
    transition: all 0.3s ease;
    background: #fff;
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-color: #ddd;
    color: #303030;
}

input[type="text"]:focus {
    outline: none;
    border-color: #27365E;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Validierungsstyling */
.validation-message {
    display: none;
    margin-top: 8px;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    animation: slideIn 0.3s ease-out;
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    color: #991b1b;
    font-family: 'Carnas', sans-serif;
}

.validation-message.show {
    display: flex;
    align-items: center;
    gap: 8px;
}

.validation-message::before {
    content: "";
}

.validation-message i {
    width: 20px;
    height: 20px;
    color: #dc2626;
    flex-shrink: 0;
}

.barcode-lookup-form input:not(:placeholder-shown):invalid {
    border-color: #27365E;
    background-color: #fff;
}

.barcode-lookup-form input:not(:placeholder-shown)[value=""],
.barcode-lookup-form input:not(:placeholder-shown)[value^="0"] {
    border-color: #27365E;
    background-color: #fff;
}

/* Nur wenn genau 8 Ziffern eingegeben wurden und mit 1-9 beginnt */
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="1"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="2"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="3"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="4"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="5"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="6"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="7"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="8"],
.barcode-lookup-form input:not(:placeholder-shown):valid[value^="9"] {
    border-color: #059669;
    background-color: #f0fdf4;
}

/* Submit Button */
.submit-button {
    background: #AECC52;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875em; /* Smaller font size */
    font-weight: 700;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
    font-family: 'Carnas', sans-serif;
    text-transform: uppercase;
    fill: #FFFFFF;
}

.submit-button:hover {
    background: #8FB03E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

.submit-button:active {
    transform: translateY(0);
    box-shadow: none;
}

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

/* Scanner Button */
.scanner-button {
    background: #AECC52;
    color: white;
    border: none;
    padding: 0 16px;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: 'Carnas', sans-serif;
    font-size: 0.875em; /* Smaller font size */
    font-weight: 700;
    text-transform: uppercase;
    fill: #FFFFFF;
}

.scanner-button:hover {
    background: #8FB03E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
}

.scanner-button:active {
    transform: translateY(0);
    box-shadow: none;
}

.scanner-button i {
    width: 20px;
    height: 20px;
}

/* Scanner Modal */
.scanner-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
}

.scanner-modal-content {
    position: relative;
    margin: 50px auto;
    width: 90%;
    max-width: 640px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.close-scanner {
    position: absolute;
    right: 15px;
    top: 15px;
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1010;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-scanner:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Scanner Viewport */
.viewport {
    width: 100%;
    height: 300px;
    position: relative;
    background: #000;
    overflow: hidden;
}

#interactive.viewport > video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#interactive.viewport > canvas.drawingBuffer {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
}

/* Scanner Feedback */
.scanning-feedback {
    text-align: center;
    color: #fff;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
}

.scanning-status {
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 500;
}

.scanning-hint {
    font-size: 14px;
    opacity: 0.8;
}

/* Ergebnis-Anzeige */
.barcode-result {
    margin-top: 20px;
    padding: 16px;
    border-radius: 8px;
    animation: slideIn 0.3s ease-out;
    font-size: 14px; /* Smaller font size */
    border-left: 4px solid transparent; /* Standardrand */
    background: transparent; /* Standardhintergrund */
    color: inherit; /* Standardtextfarbe */
}

/* Eindeutige Klassennamen für jeden Status */
.barcode-result.success {
    background: #f0fdf4 !important; /* Green background */
    border-left-color: #059669 !important;
    color: #065f46 !important;
}

.barcode-result.error {
    background: #fef2f2 !important;
    border-left-color: #dc2626 !important;
    color: #991b1b !important;
}

.barcode-result.multiple {
    background: #fef2f2 !important;
    border-left-color: #dc2626 !important;
    color: #991b1b !important;
}

.barcode-result.not-found {
    background: #fff7ed !important;
    border-left-color: #ea580c !important;
    color: #9a3412 !important;
}

.barcode-result.invalid_format {
    background: #fef2f2 !important;
    border-left-color: #dc2626 !important;
    color: #991b1b !important;
}

.barcode-result.single {
    background: #f0fdf4 !important;
    border-left-color: #059669 !important;
    color: #065f46 !important;
}

.barcode-result.single.not_found {
    background: #fff7ed; /* Yellow background */
    border-left: 4px solid #ea580c;
    color: #9a3412;
    font-size: 14px; /* Smaller font size */
}

.barcode-result.not_found {
    background: #fff7ed !important;
    border-left-color: #ea580c !important;
    color: #9a3412 !important;
}

/* Ergebnis-Anzeige - Erhöhte Spezifität und strikte Übersteuerung */
.barcode-result[class*="not_found"],
.barcode-result[class*="not-found"] {
    background: #fff7ed !important;
    border-left-color: #ea580c !important;
    color: #9a3412 !important;
}

.barcode-result[class*="single"]:not([class*="not_found"]):not([class*="not-found"]) {
    background: #f0fdf4 !important;
    border-left-color: #059669 !important;
    color: #065f46 !important;
}

/* Reset und strikte Spezifitätsregeln für Ergebnisanzeige */
.barcode-result {
    /* ...existing code... */
}

/* Überschreibe alle vorherigen Stile mit sehr hoher Spezifität */
.barcode-lookup-container .barcode-result.single:not(.not_found):not(.multiple):not(.error) {
    background: #f0fdf4 !important;
    border-left-color: #059669 !important;
    color: #065f46 !important;
}

.barcode-lookup-container .barcode-result.not_found,
.barcode-lookup-container .barcode-result.not-found {
    background: #fff7ed !important;
    border-left-color: #ea580c !important;
    color: #9a3412 !important;
}

.barcode-lookup-container .barcode-result.multiple {
    background: #fef2f2 !important;
    border-left-color: #dc2626 !important;
    color: #991b1b !important;
}

.barcode-lookup-container .barcode-result.error {
    background: #fef2f2 !important;
    border-left-color: #dc2626 !important;
    color: #991b1b !important;
}

/* Dark Mode Varianten mit gleicher hoher Spezifität */
@media (prefers-color-scheme: dark) {
    .barcode-lookup-container .barcode-result.single:not(.not_found):not(.multiple):not(.error) {
        background: #1b2d1b !important;
        border-left-color: #059669 !important;
        color: #6ee7b7 !important;
    }

    .barcode-lookup-container .barcode-result.not_found,
    .barcode-lookup-container .barcode-result.not-found {
        background: #2d1f1b !important;
        border-left-color: #ea580c !important;
        color: #fed7aa !important;
    }

    .barcode-lookup-container .barcode-result.multiple {
        background: #2d1b1b !important;
        border-left-color: #dc2626 !important;
        color: #fecaca !important;
    }

    .barcode-lookup-container .barcode-result.error {
        background: #2d1b1b !important;
        border-left-color: #dc2626 !important;
        color: #fecaca !important;
    }
}

/* Loading-Zustand */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading .submit-button {
    padding-right: 45px;
}

.loading .submit-button::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

/* Animationen */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Responsives Design */
@media screen and (max-width: 480px) {
    .barcode-lookup-container {
        margin: 10px;
        padding: 15px;
    }

    .input-group {
        flex-direction: row;
    }

    input[type="text"] {
        font-size: 14px;
        padding: 10px;
    }

    .scanner-button {
        padding: 10px;
        min-width: 42px;
        height: 42px;
    }

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

    .scanner-modal-content {
        margin: 20px auto;
    }

    .viewport {
        height: 250px;
    }

    .scanning-feedback {
        padding: 15px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .barcode-lookup-container {
        background: #1a1a1a;
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
    }

    .form-group label {
        color: #fff;
    }

    .form-hint {
        color: #aaa;
    }

    input[type="text"] {
        background: #2d2d2d;
        border-color: #404040;
        color: #fff;
    }

    input[type="text"]:focus {
        border-color: #0073aa;
        box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
    }

    .validation-message {
        background: #2d1b1b;
        border-left-color: #dc2626;
        color: #fecaca;
    }

    .barcode-lookup-form input:not(:placeholder-shown):invalid {
        background-color: #2d2d2d;
        border-color: #0073aa;
    }

    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="1"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="2"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="3"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="4"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="5"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="6"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="7"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="8"],
    .barcode-lookup-form input:not(:placeholder-shown):valid[value^="9"] {
        background-color: #1b2d1b;
        border-color: #059669;
    }

    .barcode-result.success {
        background: #1b2d1b;
        border-left-color: #059669;
        color: #6ee7b7;
    }

    .barcode-result.error {
        background: #2d1b1b;
        border-left-color: #dc2626;
        color: #fecaca;
    }

    .barcode-result.not-found {
        background: #2d1f1b;
        border-left-color: #ea580c;
        color: #fed7aa;
    }

    .barcode-result.multiple {
        background: #2d1b1b !important;
        border-left-color: #dc2626 !important;
        color: #fecaca !important;
    }

    .barcode-result.not-found {
        background: #2d1f1b !important;
        border-left-color: #ea580c !important;
        color: #fed7aa !important;
    }

    .barcode-result.invalid_format {
        background: #2d1b1b !important;
        border-left-color: #dc2626 !important;
        color: #fecaca !important;
    }

    .barcode-result.single {
        background: #1b2d1b !important;
        border-left-color: #059669 !important;
        color: #6ee7b7 !important;
    }

    .barcode-result.not_found {
        background: #2d1f1b !important;
        border-left-color: #ea580c !important;
        color: #fed7aa !important;
    }

    .barcode-result[class*="not_found"],
    .barcode-result[class*="not-found"] {
        background: #2d1f1b !important;
        border-left-color: #ea580c !important;
        color: #fed7aa !important;
    }

    .barcode-result[class*="single"]:not([class*="not_found"]):not([class*="not-found"]) {
        background: #1b2d1b !important;
        border-left-color: #059669 !important;
        color: #6ee7b7 !important;
    }
}

/* Device-specific layouts */
.barcode-lookup-container[data-device-type="loading"] .scanner-button {
    display: none;
}

.barcode-lookup-container[data-device-type="desktop"] .scanner-button {
    display: none;
}

.barcode-lookup-container[data-device-type="desktop"] input[type="text"] {
    border-radius: 8px;
    border-right: 2px solid #ddd;
}

.barcode-lookup-container[data-device-type="desktop"] input[type="text"]:focus {
    border-right: 2px solid #27365E;
}

.barcode-lookup-container[data-device-type="native-camera"] .scanner-button {
    display: flex;
}