/* ===== CSS Variables ===== */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --accent: #f093fb;
    --dark: #1a1a2e;
    --dark-light: #16213e;
    --gray-100: #f7fafc;
    --gray-200: #edf2f7;
    --gray-300: #e2e8f0;
    --gray-400: #cbd5e0;
    --gray-500: #a0aec0;
    --gray-600: #718096;
    --gray-700: #4a5568;
    --gray-800: #2d3748;
    --white: #ffffff;
    --success: #48bb78;
    --warning: #ed8936;
    --error: #fc8181;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
}

/* ===== Reset & Base ===== */
* {
    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: var(--gray-800);
    line-height: 1.6;
}

/* ===== App Container ===== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 28px;
    height: 28px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.date-display {
    font-size: 0.9rem;
    color: var(--gray-600);
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border-radius: var(--radius);
}

/* ===== Main Content ===== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
}

/* ===== Panels ===== */
.config-panel,
.preview-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.config-panel h2,
.preview-panel h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
}

/* ===== Form Groups ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.label-icon {
    font-size: 1rem;
}

/* ===== Input Styles ===== */
input[type="url"],
input[type="text"],
select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: var(--white);
    transition: all 0.2s ease;
    font-family: inherit;
}

input[type="url"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* ===== Range Slider ===== */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--white);
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

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

/* ===== Color Section ===== */
.color-section {
    margin-bottom: 1.5rem;
}

.color-section h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-picker-group label {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 0;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: var(--radius);
    border: 2px solid var(--gray-200);
}

input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    padding: 0;
    -webkit-appearance: none;
}

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

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
}

.color-value {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    color: var(--gray-600);
}

/* ===== Checkbox ===== */
.checkbox-group {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--gray-400);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
}

.gradient-colors {
    padding: 1rem;
    background: var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* ===== Style Options ===== */
.style-options {
    display: flex;
    gap: 0.75rem;
}

.style-btn,
.corner-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    color: var(--gray-600);
}

.style-btn:hover,
.corner-btn:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.style-btn.active,
.corner-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    color: var(--primary);
}

.style-preview,
.corner-preview {
    width: 24px;
    height: 24px;
    background: var(--dark);
}

.style-preview.square { border-radius: 0; }
.style-preview.rounded { border-radius: 4px; }
.style-preview.dots { border-radius: 50%; }

.corner-preview.square { border-radius: 0; }
.corner-preview.rounded { border-radius: 4px; }
.corner-preview.extra-rounded { border-radius: 8px; }

/* ===== File Upload ===== */
.file-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-upload input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-btn {
    padding: 0.75rem 1.5rem;
    background: var(--gray-100);
    border: 2px dashed var(--gray-400);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--gray-600);
    transition: all 0.2s ease;
}

.file-upload:hover .file-upload-btn {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.file-name {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.remove-logo-btn {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.remove-logo-btn:hover {
    background: #e53e3e;
}

/* ===== Select ===== */
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 3rem;
}

/* ===== Generate Button ===== */
.generate-btn {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.generate-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.1rem;
}

/* ===== Preview Container ===== */
.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 350px;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.qr-wrapper {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transition: all 0.3s ease;
}

.qr-wrapper:hover {
    transform: scale(1.02);
}

#qrCode {
    display: flex;
    justify-content: center;
    align-items: center;
}

#qrCode canvas,
#qrCode svg {
    display: block;
}

/* ===== Download Section ===== */
.download-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.download-btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.download-btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.download-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.download-btn.secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

.download-btn.secondary:hover {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

/* ===== Presets Section ===== */
.presets-section {
    padding-top: 1rem;
    border-top: 2px solid var(--gray-200);
}

.presets-section h3 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.preset-btn {
    aspect-ratio: 1;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    padding: 0.25rem;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    border-color: var(--primary);
    transform: scale(1.1);
}

.preset-preview {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    display: block;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.footer p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .config-panel {
        order: 2;
    }

    .preview-panel {
        order: 1;
    }
}

@media (max-width: 640px) {
    .app-container {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .config-panel,
    .preview-panel {
        padding: 1.5rem;
    }

    .style-options {
        flex-direction: column;
    }

    .download-section {
        grid-template-columns: 1fr;
    }

    .preset-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.config-panel,
.preview-panel {
    animation: fadeIn 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.generate-btn:disabled {
    animation: pulse 1.5s infinite;
    cursor: wait;
}
