/* ============================================
   EmojiMix — Emoji Combiner / Mashup Maker
   style.css
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --primary: #7C5CFF;
    --primary-light: #9B82FF;
    --primary-dark: #5B3FE0;
    --primary-bg: #F1EDFF;
    --primary-10: rgba(124, 92, 255, 0.1);
    --primary-20: rgba(124, 92, 255, 0.2);

    /* Light theme */
    --bg: #F6F7FB;
    --bg-panel: #FFFFFF;
    --bg-section: #F1F3F9;
    --bg-hover: #EEF0F7;
    --bg-input: #FFFFFF;
    --border: #E4E7EF;
    --border-focus: var(--primary);
    --text: #14161F;
    --text-secondary: #51566B;
    --text-muted: #969BB0;
    --text-on-primary: #FFFFFF;
    --danger: #E5484D;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --transition: 0.18s ease;

    --font-body: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
}

[data-theme="dark"] {
    --primary: #9B82FF;
    --primary-light: #B5A2FF;
    --primary-dark: #7C5CFF;
    --primary-bg: rgba(124, 92, 255, 0.16);
    --primary-10: rgba(155, 130, 255, 0.12);
    --primary-20: rgba(155, 130, 255, 0.24);

    --bg: #0D0F17;
    --bg-panel: #161924;
    --bg-section: #1E2230;
    --bg-hover: #262B3B;
    --bg-input: #1A1E2B;
    --border: #2A2F40;
    --text: #ECEEF5;
    --text-secondary: #A2A8BE;
    --text-muted: #6B7186;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    transition: background var(--transition), color var(--transition);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; opacity: 0.5; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* --- Top Bar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 18px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-divider { width: 1px; height: 26px; background: var(--border); margin: 0 2px; }

.logo { display: flex; align-items: center; gap: 9px; }
.logo-text {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.logo-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-on-primary);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 2px 7px;
    border-radius: 6px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 9px 16px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1;
    color: var(--text);
    background: transparent;
}
.btn svg { flex-shrink: 0; }
.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    box-shadow: 0 2px 8px var(--primary-20);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
    background: var(--bg-section);
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; gap: 5px; }

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
}
.btn-link:hover { text-decoration: underline; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-section);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* --- Layout --- */
.app-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - 56px);
}

.editor-panel {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.editor-scroll { overflow-y: auto; padding: 18px; flex: 1; }

.editor-section { margin-bottom: 22px; }
.editor-section:last-child { margin-bottom: 4px; }

.section-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.section-header .section-title { margin-bottom: 0; }

/* --- Form controls --- */
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.form-input, .form-select {
    width: 100%;
    padding: 9px 11px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-10);
}
.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23969BB0' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 30px;
}

.mt-2 { margin-top: 10px; }

/* --- Emoji slots --- */
.emoji-slots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}
.emoji-slot {
    position: relative;
    width: 92px;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-section);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
}
.emoji-slot:hover { background: var(--bg-hover); transform: translateY(-2px); }
.emoji-slot.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-10);
}
.emoji-slot-glyph { font-size: 46px; line-height: 1; }
.emoji-slot-tag {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.emoji-plus {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-muted);
}

.picker-target-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 12px;
}
.picker-target-label strong { color: var(--primary); }

/* --- Emoji search & grid --- */
.emoji-search-wrap { position: relative; margin-bottom: 10px; }
.emoji-search-wrap .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.emoji-search-wrap .form-input { padding-left: 33px; }

.emoji-cats {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 8px;
    scrollbar-width: none;
}
.emoji-cats::-webkit-scrollbar { display: none; }
.cat-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--bg-section);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.cat-btn:hover { background: var(--bg-hover); }
.cat-btn.active { background: var(--primary-bg); border-color: var(--primary); }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 224px;
    overflow-y: auto;
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
}
.emoji-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 23px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.1s ease;
}
.emoji-btn:hover { background: var(--bg-hover); transform: scale(1.18); }
.emoji-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px 0;
}

/* --- Sliders --- */
.control-row {
    display: grid;
    grid-template-columns: 78px 1fr 44px;
    align-items: center;
    gap: 10px;
    margin-bottom: 11px;
}
.control-row label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}
.control-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: var(--bg-hover);
    outline: none;
    cursor: pointer;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-panel);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.1s ease;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-panel);
    cursor: pointer;
}

.hint-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

/* --- Preview panel --- */
.preview-panel {
    background: var(--bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.preview-scroll {
    overflow-y: auto;
    flex: 1;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stage-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.checkerboard {
    --c1: rgba(0,0,0,0.05);
    --c2: transparent;
    background-color: var(--bg-panel);
    background-image:
        linear-gradient(45deg, var(--c1) 25%, var(--c2) 25%, var(--c2) 75%, var(--c1) 75%, var(--c1)),
        linear-gradient(45deg, var(--c1) 25%, var(--c2) 25%, var(--c2) 75%, var(--c1) 75%, var(--c1));
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    border: 1px solid var(--border);
}
[data-theme="dark"] .checkerboard { --c1: rgba(255,255,255,0.06); }

#mixCanvas {
    display: block;
    width: min(440px, 60vh, 70vw);
    height: min(440px, 60vh, 70vw);
    border-radius: var(--radius-lg);
}

.stage-caption {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

/* --- Recent combos --- */
.recent-block {
    width: 100%;
    max-width: 480px;
    margin-top: 36px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.recent-header h4 {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
}
.recent-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-section);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    padding: 6px;
}
.recent-item:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-md); }
.recent-item img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.recent-empty {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 16px 0;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 18, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.25s ease;
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: scale(1); } }
.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg-section);
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-icon { margin-bottom: 14px; }
.modal h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.modal > p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    line-height: 1.5;
}
.pro-features {
    list-style: none;
    text-align: left;
    margin: 0 auto 18px;
    max-width: 280px;
}
.pro-features li {
    position: relative;
    padding-left: 26px;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 9px;
}
.pro-features li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--primary-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 6L5 8.5L9.5 3.5' stroke='%237C5CFF' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
.pro-price {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}
.price-amount {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}
.price-label { font-size: 13px; color: var(--text-muted); }
.modal-footer-text { font-size: 11px; color: var(--text-muted); margin-top: 12px; }

/* --- Responsive --- */
@media (max-width: 860px) {
    body { overflow: auto; height: auto; }
    .app-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        order: 2;
    }
    .editor-scroll { overflow-y: visible; }
    .preview-panel { order: 1; overflow: visible; }
    .preview-scroll { overflow-y: visible; padding: 24px 16px; }
    #mixCanvas { width: min(360px, 80vw); height: min(360px, 80vw); }
}

@media (max-width: 480px) {
    .topbar { padding: 0 12px; }
    .logo-text { font-size: 16px; }
    .btn-sm span { display: none; }
    #btnGetProTop { padding: 7px 10px; }
    .emoji-grid { grid-template-columns: repeat(7, 1fr); }
}
