/* Custom styles for QR Code Generator */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom color picker styling */
input[type="color"] {
    -webkit-appearance: none;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
}

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

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 0.25rem;
}

/* Custom range slider */
input[type="range"] {
    -webkit-appearance: none;
    background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, #6366f1 0%, #8b5cf6 100%);
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #6366f1;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(to right, #6366f1 0%, #8b5cf6 100%);
    border-radius: 4px;
}

input[type="range"]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Style picker buttons */
.style-btn {
    width: 100%;
    aspect-ratio: 1;
    padding: 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.style-btn:hover {
    border-color: #a5b4fc;
    color: #6366f1;
    background: #f5f3ff;
}

.style-btn.active {
    border-color: #6366f1;
    color: #6366f1;
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Error Correction Level buttons */
.ec-btn {
    background: #fff;
    cursor: pointer;
    text-align: center;
}

.ec-btn.active {
    border-color: #6366f1;
    background: #eef2ff;
}

.ec-btn.active span:first-child {
    color: #6366f1;
}

.style-btn svg {
    width: 100%;
    height: 100%;
}

/* QR type button hover effect */
.qr-type-btn {
    transition: all 0.2s ease;
}

.qr-type-btn:hover {
    transform: translateY(-2px);
}

.qr-type-btn svg {
    transition: color 0.2s ease;
}

.qr-type-btn:hover svg {
    color: #6366f1;
}

/* QR Preview container */
#qr-preview {
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qr-preview canvas,
#qr-preview svg {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

/* Download buttons - fallback styles */
#download-svg,
#download-png,
#download-jpg {
    background-color: #6366f1;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

#download-svg:disabled,
#download-png:disabled,
#download-jpg:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#download-svg:not(:disabled):hover,
#download-png:not(:disabled):hover,
#download-jpg:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Focus states */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    ring: 2px;
    ring-color: #6366f1;
    border-color: transparent;
}

/* Checkbox custom styling */
input[type="checkbox"] {
    accent-color: #6366f1;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    /* Header */
    header h1 {
        font-size: 1.25rem;
    }

    /* Main container */
    main {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    /* Sections */
    section.p-6 {
        padding: 1rem;
    }

    section h2 {
        font-size: 1rem;
    }

    /* QR type buttons */
    .qr-type-btn {
        padding: 0.5rem;
    }

    .qr-type-btn span.w-8 {
        width: 1.25rem;
        height: 1.25rem;
    }

    .qr-type-btn span.text-xs {
        font-size: 0.6rem;
        line-height: 1.2;
    }

    /* Style buttons grid */
    #dots-style,
    #corners-style {
        gap: 0.5rem;
    }

    .style-btn {
        padding: 0.375rem;
        border-radius: 0.5rem;
    }

    /* Color inputs */
    .flex.items-center.gap-3 {
        flex-wrap: wrap;
    }

    .flex.items-center.gap-3 label {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    /* QR Preview */
    #qr-preview {
        min-height: 200px;
        padding: 0.75rem;
    }

    /* Download buttons */
    #download-svg,
    #download-png,
    #download-jpg {
        padding: 0.625rem 0.5rem;
        font-size: 0.875rem;
    }

    /* Form inputs */
    input[type="text"],
    input[type="url"],
    input[type="tel"],
    input[type="email"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Footer */
    footer {
        margin-top: 2rem;
        padding: 1.5rem 0;
    }
}

/* Small mobile (< 375px) */
@media (max-width: 374px) {
    .qr-type-btn span.text-xs {
        font-size: 0.5rem;
    }

    #dots-style {
        grid-template-columns: repeat(3, 1fr);
    }

    .style-btn {
        padding: 0.25rem;
    }
}

/* Loading animation for QR generation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.qr-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Sticky preview on scroll - only on desktop */
.sticky {
    position: static;
}

@media (min-width: 1024px) {
    .sticky {
        position: sticky;
        top: 1rem;
    }
}

/* Select dropdown styling */
select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Custom Color Picker Modal */
.color-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.color-picker-overlay.active {
    opacity: 1;
    visibility: visible;
}

.color-picker-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 1.5rem 1.5rem 0 0;
    padding: 1.5rem;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.color-picker-overlay.active .color-picker-modal {
    transform: translateY(0);
}

.color-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.color-picker-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.color-picker-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background 0.2s ease;
}

.color-picker-close:hover {
    background: #e5e7eb;
}

.color-picker-section {
    margin-bottom: 1.25rem;
}

.color-picker-section-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.625rem;
}

.color-preset {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
    min-height: 2.5rem;
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.color-custom-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.color-custom-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-family: monospace;
    text-transform: uppercase;
}

.color-custom-input:focus {
    outline: none;
    border-color: #6366f1;
}

.color-custom-preview {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    border: 2px solid #e5e7eb;
    flex-shrink: 0;
}

.color-native-picker {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

.color-native-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-native-picker::-webkit-color-swatch {
    border: none;
    border-radius: 0.5rem;
}

.color-picker-apply {
    width: 100%;
    padding: 1rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 0.5rem;
}

.color-picker-apply:hover {
    background: #4f46e5;
}

/* Color trigger button (replaces native input) */
.color-trigger {
    width: 3rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: border-color 0.2s ease;
    padding: 0;
}

.color-trigger:hover {
    border-color: #a5b4fc;
}

/* Desktop: side modal */
@media (min-width: 640px) {
    .color-picker-modal {
        position: fixed;
        bottom: auto;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%) scale(0.95);
        border-radius: 1rem;
        width: 100%;
        max-width: 24rem;
        max-height: 90vh;
    }

    .color-picker-overlay.active .color-picker-modal {
        transform: translate(-50%, -50%) scale(1);
    }

    .color-presets {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Dark mode support (optional, can be enabled later) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here when needed */
}
