/* QR Tool Variables */
:root {
    /* Monokai Theme Colors */
    --monokai-bg: #272822;
    --monokai-fg: #f8f8f2;
    --monokai-comment: #75715e;
    --monokai-yellow: #e6db74;
    --monokai-purple: #ae81ff;
    --monokai-red: #f92672;
    --monokai-blue: #66d9ef;
    --monokai-green: #a6e22e;
    --monokai-orange: #fd971f;

    /* Glass Variables */
    --glass-bg: rgba(30, 30, 30, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    --glass-blur: blur(16px) saturate(180%);
}

/* Hide Global Navigation for this tool */
header.navbar-fixed,
#headNav,
#aplayer,
.aplayer {
    display: none !important;
}

/* Base Layout */
body {
    margin: 0;
    padding: 0;
    background-image: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    color: var(--monokai-fg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow-y: auto; /* Allow global scroll */
    height: auto;
}

.qr-tool-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    background: var(--monokai-bg);
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    color: var(--monokai-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-3px);
}

.qr-workspace {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Left Panel: Preview */
.qr-preview-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #3a3a3a 0%, #272822 100%);
    position: relative;
    overflow: hidden;
}

/* Decorative background elements */
.qr-preview-panel::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: var(--monokai-blue);
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.1;
    top: 10%;
    left: 10%;
}

.qr-preview-panel::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: var(--monokai-purple);
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.08;
    bottom: -10%;
    right: 10%;
}

.qr-card {
    background: rgba(255, 255, 255, 0.05); /* Slightly lighter than bg */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-card:hover {
    transform: translateY(-5px);
}

#qr-canvas {
    border-radius: 12px;
    overflow: hidden;
    /* Remove fixed width/height here, rely on init options, but constrain with max-width */
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qr-canvas svg {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Right Panel: Config */
.qr-config-panel {
    width: 400px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--glass-border);
    padding: 40px 30px;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
    z-index: 10;
}

.config-header h1 {
    font-size: 1.8rem;
    margin: 0 0 5px 0;
    background: linear-gradient(45deg, var(--monokai-blue), var(--monokai-green));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.config-header p {
    margin: 0;
    color: var(--monokai-comment);
    font-size: 0.9rem;
}

.config-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--monokai-comment);
    font-weight: 600;
}

.input-group textarea {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--monokai-fg);
    padding: 12px;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    transition: all 0.2s;
    outline: none;
}

.input-group textarea:focus {
    border-color: var(--monokai-blue);
    background: rgba(0, 0, 0, 0.3);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.option-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-item label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    width: 24px;
    height: 24px;
    cursor: pointer;
    background: none;
    padding: 0;
    border-radius: 4px;
    overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-value {
    font-size: 0.8rem;
    color: var(--monokai-comment);
    font-family: monospace;
}

/* Select */
select {
    display: block !important;
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--monokai-fg);
    padding: 8px 12px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: menulist !important;
    -moz-appearance: menulist !important;
    appearance: menulist !important;
    height: auto !important;
    min-height: 38px;
}

select:focus {
    border-color: var(--monokai-blue);
}

/* Radio Button Group for Error Correction */
/* Radio Button Group (Deprecated, replaced by Select) */
/* CSS Removed */

/* File Input */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

input[type="file"] {
    display: none;
}

.file-label {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    color: var(--monokai-fg);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.file-label:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.1);
}

.icon-btn {
    background: rgba(249, 38, 114, 0.2);
    color: var(--monokai-red);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(249, 38, 114, 0.3);
}

/* Buttons */
.action-footer {
    margin-top: auto;
    display: flex;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    border: none;
    font-size: 0.95rem;
}

.primary-btn {
    background: linear-gradient(45deg, var(--monokai-blue), #2196f3);
    color: black;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--monokai-fg);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Scrollbar */
.qr-config-panel::-webkit-scrollbar {
    width: 6px;
}

.qr-config-panel::-webkit-scrollbar-track {
    background: transparent;
}

.qr-config-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 900px) {
    body {
        overflow-y: auto;
        height: auto;
    }

    .qr-tool-container {
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
        overflow-x: hidden;
    }

    .qr-workspace {
        flex-direction: column;
        height: auto;
        overflow: visible;
        width: 100%;
    }

    /* Adjust Preview Panel for Mobile */
    .qr-preview-panel {
        flex: none;
        width: 100%;
        height: auto;
        padding: 60px 20px 40px 20px;
        min-height: auto;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Resize QR Code for Mobile */
    .qr-card {
        padding: 15px;
        width: auto;
        max-width: calc(100vw - 30px);
        box-sizing: border-box;
        overflow: visible;
        margin: 0 auto;
    }

    #qr-canvas {
        width: 300px;
        height: 300px;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: hidden;
        border-radius: 16px;
    }
    
    /* Keep SVG at native size but ensure it fits within rounded container */
    #qr-canvas svg, #qr-canvas canvas {
        width: 300px !important;
        height: 300px !important;
        border-radius: 16px;
    }

    /* Adjust Config Panel for Mobile */
    .qr-config-panel {
        width: 100%;
        max-width: 100vw;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--glass-border);
        overflow: visible;
        padding: 30px 20px;
        box-sizing: border-box;
    }
    
    .config-section {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .options-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
        width: 100%;
        max-width: 100%;
    }

    .option-item {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix select dropdown for mobile */
    .option-item select {
        width: 100% !important;
        min-height: 40px;
        padding: 10px 12px;
        font-size: 16px;
        -webkit-appearance: menulist;
        appearance: menulist;
    }
    
    /* Fix color picker wrapper for mobile */
    .color-picker-wrapper {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix file input wrapper for mobile */
    .file-input-wrapper {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Reset any grid-column spans that might interfere */
    .option-item-full {
        grid-column: auto;
    }
    
    /* Move back button to be visible on top of the gradient */
    .back-btn {
        top: 15px;
        left: 15px;
    }
    
    /* Fix action footer for mobile */
    .action-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-footer button {
        width: 100%;
    }
}
