/* Global Styles & Dark Theme */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212; /* Deep Black */
    color: #e0e0e0; /* Soft White */
    display: flex;
    flex-direction: column; /* Stack containers vertically */
    justify-content: center; /* Center containers horizontally if flex container is tall enough */
    align-items: center; /* Center containers horizontally */
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    background-color: #1e1e1e; /* Dark Gray Container BG */
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 255, 255, 0.1); /* Cyan Glow Effect */
    width: 100%;
    max-width: 600px; /* Max width of the container itself */
    text-align: center;
    border: 1px solid rgba(0, 255, 255, 0.2); /* Faint Cyan Border */
    margin-bottom: 30px; /* Space between containers */
}
/* Ensure the last container doesn't have extra bottom margin if body padding is sufficient */
body > .container:last-child {
    margin-bottom: 0;
}


h1 {
    color: #00e5ff; /* Bright Cyan */
    margin-bottom: 25px;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

textarea#text-input {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #444; /* Dark Gray Border */
    border-radius: 8px;
    background-color: #2b2b2b; /* Slightly Lighter Input BG */
    color: #f0f0f0; /* Light Text */
    font-size: 1rem;
    resize: vertical; /* Allow vertical resize */
    outline: none; /* Remove default outline */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

textarea#text-input:focus {
    border-color: #00e5ff; /* Cyan border on focus */
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3); /* Cyan glow on focus */
}

.button-group {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    flex-wrap: wrap; /* Wrap buttons on small screens */
    gap: 15px; /* Spacing between buttons */
}
/* Remove bottom margin from the last button group in a container if needed */
.container > .button-group:last-child {
    margin-bottom: 0;
}


button {
    padding: 12px 25px;
    border: none;
    border-radius: 25px; /* Rounded buttons */
    background: linear-gradient(45deg, #0077ff, #00e5ff); /* Blue to Cyan Gradient */
    color: #121212; /* Dark Text */
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    outline: none;
    min-width: 150px; /* Ensure minimum button width */
}

button:hover {
    transform: translateY(-2px); /* Slight lift effect */
    box-shadow: 0 6px 15px rgba(0, 229, 255, 0.3); /* Stronger glow on hover */
}

button:active {
    transform: translateY(0px); /* Reset lift on click */
    box-shadow: 0 3px 10px rgba(0, 229, 255, 0.2); /* Reduced glow on click */
}

#qrcode-container {
    margin-top: 20px;
    min-height: 220px; /* Minimum space for QR code + padding */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #2b2b2b; /* Match input background */
    border-radius: 8px;
    padding: 20px; /* Inner padding for the container */
    border: 1px dashed #444; /* Dashed border */
    /* The width of this container is controlled by its parent (.container) */
}

/* Styles for generated QR Code Canvas */
#qrcode-container canvas {
    /* Base Styles - keep display, margin, background etc. */
    display: block;
    background-color: white; /* Standard QR code background */
    margin: auto; /* Center the canvas horizontally if needed */
    /* Styling applied by JS (padding, border-radius, box-shadow) are on the canvas element */
    /* Note: JS sets canvas.style.padding = '10px', this adds visual space INSIDE the canvas element's border */
    /* It doesn't affect the drawing, only how the element itself looks */

    /* --- BEGIN MODIFICATION --- */
    /* Limit the DISPLAY width of the canvas */
    max-width: 100%;  /* Don't exceed the width of #qrcode-container */
    height: auto;     /* Maintain aspect ratio when width is scaled down */
    /* --- END MODIFICATION --- */
}


#qrcode-container .placeholder {
    color: #777; /* Placeholder text color */
    font-style: italic;
}

/* Divider Style */
.section-divider {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(0, 255, 255, 0.5), transparent);
    margin: 40px auto; /* Spacing above/below */
    width: 80%; /* Divider width */
}

/* Scanner Section Specific Styles */
#scanner-section h1 {
     /* Inherits general h1 styles */
     margin-top: 0; /* Reset top margin as container has padding */
}

#video-container {
    position: relative; /* For absolute positioning of the overlay */
    width: 100%;
    max-width: 500px; /* Limit max width */
    margin: 0 auto 20px auto; /* Center horizontally, add bottom margin */
    background-color: #000; /* Black background for video area */
    border: 1px dashed #444;
    border-radius: 8px;
    overflow: hidden; /* Hide parts of video outside the container */
    min-height: 250px; /* Ensure minimum height */
    display: flex; /* Used to center potential placeholder text */
    justify-content: center;
    align-items: center;
}

#video-preview {
    display: none; /* Initially hidden */
    width: 100%;
    height: auto; /* Maintain aspect ratio */
    max-height: 400px; /* Limit height */
}

#scan-region-overlay {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 250px; /* Width of the scanning box */
    height: 250px; /* Height of the scanning box */
    border: 3px solid rgba(0, 229, 255, 0.7); /* Cyan solid border */
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), /* Dim the area outside the box */
                0 0 15px rgba(0, 229, 255, 0.4),
                inset 0 0 15px rgba(0, 229, 255, 0.3);
    pointer-events: none; /* Allow clicks to go through to video/container */
    display: none; /* Initially hidden */
}


/* Scan Status Message */
.status-message {
    color: #aaa;
    font-style: italic;
    margin-top: 10px; /* Spacing from video container */
    margin-bottom: 15px; /* Spacing to result textarea */
    min-height: 1.6em; /* Prevent layout shift */
    display: block; /* Ensure it takes full width */
}

/* Scan Result Textarea */
#scan-result {
    width: 100%;
    min-height: 100px; /* Smaller than generator input */
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #444;
    border-radius: 8px;
    background-color: #2b2b2b;
    color: #f0f0f0;
    font-size: 1rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; /* Monospace for results */
}

#scan-result:focus {
    border-color: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

/* Scanner Button Group */
#scanner-section .button-group {
    margin-top: 10px; /* Adjust spacing */
     margin-bottom: 0; /* No extra margin at the bottom of this container */
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    body {
        padding: 10px; /* Less padding on small screens */
    }
    .container {
        padding: 20px 15px; /* Less padding */
    }
    h1 {
        font-size: 1.8rem;
    }
    .button-group {
        flex-direction: column; /* Stack buttons vertically */
        align-items: center;
        gap: 10px; /* Less gap */
        margin-bottom: 20px; /* Adjust margin */
    }
     .container > .button-group:last-child {
        margin-bottom: 0;
    }

    button {
        width: 90%; /* Make buttons wider */
        min-width: unset; /* Remove min-width */
        padding: 12px 20px; /* Adjust padding */
    }
    #qrcode-container {
        min-height: 180px; /* Reduce height */
         padding: 15px; /* Reduce padding */
    }
    /* Scanner Responsive */
    #video-container {
        max-width: 100%;
        min-height: 200px;
    }
     #scan-region-overlay {
        width: 200px; /* Smaller scan box */
        height: 200px;
    }
     #scan-result {
        min-height: 80px;
    }
     .section-divider {
        margin: 30px auto;
     }
}