/* Reset และ Base Styles */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* สี */
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #00d4aa;
    --warning-color: #ffc107;
    --danger-color: #f56565;
    --info-color: #4299e1;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    
    /* ขนาด */
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --border-radius-sm: 8px;
    --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);
    
    /* Font */
    --font-family: 'Kanit', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-weight: var(--font-weight-normal);
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(102, 126, 234, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-4);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Navigation */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: var(--space-4) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--primary-color);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    gap: var(--space-6);
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

/* Hero Section */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    overflow: hidden;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    z-index: -1;
}

.hero-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="10" cy="10" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="30" cy="20" r="0.5" fill="rgba(255,255,255,0.05)"/><circle cx="60" cy="30" r="1.5" fill="rgba(255,255,255,0.08)"/><circle cx="80" cy="50" r="0.8" fill="rgba(255,255,255,0.06)"/><circle cx="20" cy="70" r="1.2" fill="rgba(255,255,255,0.04)"/><circle cx="90" cy="80" r="0.6" fill="rgba(255,255,255,0.07)"/></svg>') repeat;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.hero-content {
    max-width: 800px;
    z-index: 2;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-6);
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(45deg, #fff 30%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    font-weight: var(--font-weight-normal);
    margin-bottom: var(--space-10);
    opacity: 0.9;
    line-height: 1.6;
}

.hero-buttons {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-large {
    padding: var(--space-4) var(--space-8);
    font-size: 1.1rem;
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 0.875rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* Main Content */
.main-content {
    padding: var(--space-20) 0;
    background: var(--bg-secondary);
}

/* Section Styles */
.section-header {
    text-align: center;
    margin-bottom: var(--space-16);
}

.section-title {
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Generator Section */
.generator-section {
    margin-bottom: var(--space-20);
}

.generator-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-8);
    max-width: 1400px;
    margin: 0 auto;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.panel-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

/* Input Panel */
.input-panel,
.customization-panel,
.preview-panel {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.content-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.tab-button {
    flex: 1;
    padding: var(--space-4);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: rgba(102, 126, 234, 0.05);
    color: var(--primary-color);
}

.tab-button.active {
    background: white;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.content-forms {
    padding: var(--space-6);
}

.content-form {
    display: none;
}

.content-form.active {
    display: block;
}

.form-group {
    margin-bottom: var(--space-6);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-group label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Style Tabs */
.style-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.style-tab {
    flex: 1;
    padding: var(--space-3);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.style-tab.active {
    background: white;
    color: var(--primary-color);
}

.style-panels {
    padding: var(--space-6);
}

.style-panel {
    display: none;
}

.style-panel.active {
    display: block;
}

/* Range Slider */
.range-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

/* Color Controls */
.color-presets {
    margin-bottom: var(--space-6);
}

.preset-colors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.color-preset {
    padding: var(--space-3);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.color-preset:hover {
    border-color: var(--primary-color);
}

.preset-preview {
    display: flex;
    height: 30px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.preset-preview div {
    flex: 1;
}

.color-input-wrapper {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 50px;
    height: 40px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

.hex-input {
    width: 100px;
    padding: var(--space-2);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-family: monospace;
}

/* Upload Areas */
.upload-area {
    border: 2px dashed var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

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

.upload-placeholder i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

/* Preview Panel */
.preview-actions {
    display: flex;
    gap: var(--space-2);
}

.qr-preview-container {
    padding: var(--space-6);
    text-align: center;
    background: var(--bg-secondary);
}

.qr-preview {
    display: inline-block;
    padding: var(--space-4);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    min-height: 300px;
    min-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.preview-placeholder i {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.preview-info {
    padding: var(--space-4) var(--space-6);
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
}

.info-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.generate-actions {
    padding: var(--space-6);
}

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

.modal-content {
    background: white;
    margin: 5% auto;
    border-radius: var(--border-radius-lg);
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6);
    border-bottom: 1px solid var(--bg-tertiary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: var(--space-2);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--bg-tertiary);
    display: flex;
    gap: var(--space-4);
    justify-content: flex-end;
}

.format-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-4);
    margin: var(--space-4) 0;
}

.format-option {
    cursor: pointer;
}

.format-card {
    padding: var(--space-4);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    text-align: center;
    transition: all 0.3s ease;
}

.format-option input:checked + .format-card {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

/* Gallery */
.gallery-filters {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}

.filter-btn {
    padding: var(--space-3) var(--space-6);
    border: 2px solid var(--bg-tertiary);
    background: white;
    color: var(--text-secondary);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover,
.filter-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-8);
}

.gallery-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-20);
    color: var(--text-muted);
}

.gallery-placeholder i {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: white;
    padding: var(--space-16) 0 var(--space-8);
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.footer-brand .brand-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
}

.link-group h4 {
    margin-bottom: var(--space-4);
    color: white;
}

.link-group a {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    margin-bottom: var(--space-2);
    transition: color 0.3s ease;
}

.link-group a:hover {
    color: var(--accent-color);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-8);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.social-links {
    display: flex;
    gap: var(--space-4);
}

.social-links a {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.25rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .generator-container {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-6);
    }
    
    .preview-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-3);
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .generator-container {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .content-tabs {
        overflow-x: auto;
    }
    
    .tab-button {
        white-space: nowrap;
        flex: none;
        min-width: 120px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: var(--space-4);
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .preset-colors {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .format-options {
        grid-template-columns: 1fr;
    }
}

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

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* Checkbox and Radio Custom Styles */
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    user-select: none;
}

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

.checkmark,
.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    position: relative;
    transition: all 0.3s ease;
}

.radio-custom {
    border-radius: 50%;
}

.checkbox-label input:checked + .checkmark,
.radio-label input:checked + .radio-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkmark::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.checkbox-label input:checked + .checkmark::after {
    opacity: 1;
}

.radio-custom::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.radio-label input:checked + .radio-custom::after {
    opacity: 1;
}

/* Ad Section */
.ad-section {
    background: var(--bg-primary);
    padding: var(--space-8);
    margin: var(--space-16) 0;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--bg-tertiary);
}

/* Gallery Styles */
.gallery-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.gallery-item-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.gallery-thumb {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.gallery-meta {
    padding: var(--space-4);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.g-name {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.g-date {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: var(--space-3);
}

.g-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto;
}

.g-actions .btn {
    flex: 1;
    justify-content: center;
}

/* Preview Modal */
#galleryPreview .modal-content {
    max-width: 500px;
}

.preview-image-container {
    text-align: center;
    margin-bottom: var(--space-6);
}

.preview-image-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.preview-info {
    background: var(--bg-secondary);
    padding: var(--space-4);
    border-radius: var(--border-radius);
}

.preview-info .info-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.preview-info .info-item:last-child {
    margin-bottom: 0;
}

.preview-info i {
    width: 20px;
    color: var(--text-muted);
}

/* Responsive Gallery */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: var(--space-4);
    }
    
    .g-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}