/* CSS Reset and Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --info-color: #3b82f6;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 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);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--radius-lg);
    color: white;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-emoji {
    font-size: 3rem;
    animation: bounce 2s infinite;
}

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

.header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.tagline {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Section Styling */
.section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
}

.section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    font-weight: 500;
}

.tab-btn:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}

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

/* Emoji Grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.emoji-item {
    font-size: 1.8rem;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    user-select: none;
}

.emoji-item:hover {
    background: var(--primary-color);
    transform: scale(1.2);
}

.emoji-item.selected {
    background: var(--success-color);
    transform: scale(1.1);
}

/* Workspace */
.workspace-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.selected-emojis {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.emoji-slot {
    width: 80px;
    height: 80px;
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
}

.emoji-slot:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}

.emoji-slot.filled {
    border-style: solid;
    border-color: var(--success-color);
    background: #f0fdf4;
}

.emoji-slot .placeholder {
    color: var(--text-muted);
    font-size: 2rem;
}

.combiner {
    font-size: 1.8rem;
    color: var(--text-muted);
    font-weight: bold;
}

.preview-container {
    width: 128px;
    height: 128px;
    border: 3px solid var(--primary-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: var(--shadow-md);
}

#previewCanvas {
    max-width: 100%;
    max-height: 100%;
}

.slot-actions {
    display: flex;
    gap: 10px;
}

/* Customization Options */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

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

.option-group label {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95rem;
}

.option-group select,
.option-group input[type="range"] {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
}

.option-group select:focus,
.option-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.option-group input[type="range"] {
    padding: 0;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    cursor: pointer;
}

.option-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.option-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

/* Background Options */
.bg-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bg-btn {
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

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

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

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

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

/* Action Buttons Grid */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* Gallery */
.gallery-hint {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.gallery-item {
    position: relative;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
    transition: var(--transition);
}

.gallery-item:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.gallery-item img {
    max-width: 100%;
    height: auto;
}

.gallery-item .delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.gallery-item:hover .delete-btn {
    opacity: 1;
}

/* Footer */
.footer {
    text-align: center;
    padding: 25px;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: white;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }

    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo-emoji {
        font-size: 2rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .section {
        padding: 20px 15px;
    }

    .section h2 {
        font-size: 1.1rem;
    }

    .category-tabs {
        justify-content: center;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    }

    .emoji-item {
        font-size: 1.5rem;
        padding: 6px;
    }

    .emoji-slot {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }

    .preview-container {
        width: 100px;
        height: 100px;
    }

    .combiner {
        font-size: 1.3rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 8px;
    }

    .selected-emojis {
        gap: 10px;
    }

    .emoji-slot {
        width: 55px;
        height: 55px;
        font-size: 1.8rem;
    }

    .preview-container {
        width: 80px;
        height: 80px;
    }

    .slot-actions {
        flex-direction: column;
        width: 100%;
    }

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

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

    .bg-btn {
        text-align: center;
    }
}

/* Animation for newly added gallery items */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gallery-item.new {
    animation: fadeInScale 0.3s ease forwards;
}

/* Checkered background for transparent preview */
.transparent-bg {
    background-image:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}
