/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;700&family=Noto+Sans+Thai:wght@300;400;500;700&display=swap');

:root {
    --asc-primary: #6366f1;
    /* Indigo */
    --asc-secondary: #a855f7;
    /* Purple */
    --asc-accent: #ec4899;
    /* Pink */
    --asc-bg: #f8fafc;
    --asc-card-bg: #ffffff;
    --asc-text: #1e293b;
    --asc-text-light: #64748b;
    --asc-border: #e2e8f0;
    --asc-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --asc-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --asc-glass: rgba(255, 255, 255, 0.7);
    --asc-glass-border: rgba(255, 255, 255, 0.5);
    --asc-radius: 16px;
}

/* Ad Block */
.asc-top-ad {
    max-width: 1400px;
    width: 95%;
    margin: 0 auto 24px auto;
    /* Match container alignment */
    background-color: #f1f5f9;
    border: 2px dashed #cbd5e1;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 20px;
    font-weight: 500;
    border-radius: 16px;
    font-family: 'Outfit', 'Noto Sans Thai', sans-serif;
    user-select: none;
}

/* Container */
#asc-container {
    font-family: 'Outfit', 'Noto Sans Thai', sans-serif;
    max-width: 1400px;
    width: 95%;
    margin: 40px auto;
    background: var(--asc-bg);
    border-radius: 24px;
    box-shadow:
        0 20px 25px -5px rgb(0 0 0 / 0.1),
        0 8px 10px -6px rgb(0 0 0 / 0.1);
    /* overflow: hidden; */
    position: relative;
    border: 1px solid var(--asc-border);
}

/* --- 1. Main Header --- */
.asc-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--asc-border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
    gap: 16px;
}

/* Logo Area */
.asc-header-left {
    display: flex;
    align-items: center;
}

.asc-logo {
    /* Container for the link */
}

/* Ensure link behaves like the original container */
.asc-logo-link {
    transition: opacity 0.2s;
}

.asc-logo-link:hover {
    opacity: 0.8;
}

.asc-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
    object-fit: cover;
}

.asc-logo-text-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.asc-logo-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 20px;
    line-height: 1.1;
    color: var(--asc-text);
    background: linear-gradient(135deg, var(--asc-primary), var(--asc-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.asc-logo-subtitle {
    font-size: 11px;
    font-weight: 500;
    color: var(--asc-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tools Area */
.asc-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    justify-content: flex-end;
    /* Removed max-width restriction to allow full expansion */
    width: 100%;
    flex-wrap: wrap;
    /* Allow wrapping on very small screens */
}

.asc-search-wrapper {
    position: relative;
    flex: 1;
    /* Give search more weight to grow */
    min-width: 200px;
}

.asc-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.5;
    pointer-events: none;
}

.asc-search-input,
.asc-category-select {
    box-sizing: border-box;
    /* Fix padding adding to width */
    /* width: 100%; Removed to allow individual control */
    padding: 12px 16px 12px 42px;
    /* Slightly larger padding for better touch/visual */
    border-radius: 12px;
    border: 1px solid var(--asc-border);
    font-size: 15px;
    /* Slightly larger text */
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
    color: var(--asc-text);
    font-family: inherit;
}

.asc-search-input {
    width: 100%;
    /* Helper to fill wrapper */
}

.asc-category-select {
    padding-left: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%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 14px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
    flex: 0 0 auto;
    /* Do not grow, do not shrink */
    width: auto;
    /* Allow auto width based on content/min-width */
    min-width: 180px;
    /* Ensure not too small */
    max-width: 250px;
    /* Ensure not too wide */

    /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Force Option Colors */
.asc-category-select option {
    color: #1e293b;
    background-color: #ffffff;
    padding: 8px;
}

.asc-search-input:focus,
.asc-category-select:focus {
    background: white;
    border-color: var(--asc-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* --- 2. Navigation (Pills) --- */
.asc-nav-wrapper {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--asc-border);
    position: relative;
    z-index: 15;
}

.asc-nav-links {
    flex: 1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    white-space: nowrap;
    scrollbar-width: none;
    /* Firefox */
    padding: 4px;
    mask-image: linear-gradient(to right, transparent, black 20px, black 95%, transparent);
}

.asc-nav-links::-webkit-scrollbar {
    display: none;
}

.asc-nav-item {
    padding: 8px 16px;
    border-radius: 50px;
    text-decoration: none;
    color: var(--asc-text-light);
    font-size: 14px;
    font-weight: 500;
    background: #f1f5f9;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.asc-nav-item:hover {
    background: #e2e8f0;
    color: var(--asc-text);
    transform: translateY(-1px);
}

.asc-nav-item.active {
    background: linear-gradient(135deg, var(--asc-primary), var(--asc-secondary));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.asc-nav-divider {
    color: #cbd5e1;
    margin: 0 4px;
    align-self: center;
}

.asc-nav-scroll-btn {
    background: white;
    border: 1px solid var(--asc-border);
    color: var(--asc-text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.asc-nav-scroll-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--asc-primary);
}

/* --- 3. Content Area (Grid) --- */
.asc-content {
    /* height: 500px; Removed to show full content */
    /* overflow-y: auto; Removed */
    padding: 24px;
    background-color: #f8fafc;
    min-height: 200px;
    /* Ensure loading spinner has space */
}

/* Removed inner scrollbar styling as we use main scroll */

.asc-section {
    margin-bottom: 24px;
    /* animation: fadeIn 0.4s ease-out; */
}

.asc-inline-ad {
    width: 100%;
    margin: 30px 0;
    padding: 24px;
    background-color: #f8fafc;
    border: 1px dashed #e2e8f0;
    border-radius: 12px;
    text-align: center;
    position: relative;
    box-sizing: border-box;
}

.asc-inline-ad span {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 10px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.asc-inline-ad .asc-ad-slot {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.asc-section-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--asc-text);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
}

.asc-section-header h3::before {
    content: '';
    display: block;
    width: 6px;
    height: 24px;
    background: linear-gradient(to bottom, var(--asc-primary), var(--asc-accent));
    margin-right: 10px;
    border-radius: 3px;
}

.asc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 12px;
}

.asc-char-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    /* Big Chars */
    background: white;
    border: 1px solid var(--asc-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--asc-text);
    user-select: none;
    box-shadow: var(--asc-shadow);
}

.asc-char-item:hover {
    transform: scale(1.15) translateY(-4px);
    border-color: var(--asc-primary);
    box-shadow: var(--asc-shadow-hover);
    z-index: 10;
    color: var(--asc-primary);
}

.asc-char-item:active,
.asc-char-item.clicked {
    transform: scale(0.95);
    background-color: var(--asc-primary);
    color: white;
    border-color: var(--asc-primary);
}

/* --- Fixed Footer Action Bar --- */
.asc-sticky-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    background-color: #ffffff !important;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15) !important;
    padding: 16px 20px;
    z-index: 999999 !important;
    border-top: 1px solid #e2e8f0;
    display: block !important;
}

.asc-footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.asc-input-group {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px 12px;
    border: 2px solid #e2e8f0;
    transition: all 0.2s ease;
}

.asc-input-group:focus-within {
    border-color: #cbd5e1;
    background: #fff;
}

.asc-result-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-size: 16px;
    color: #0f172a;
    outline: none;
    font-family: inherit;
    font-weight: 500;
}

.asc-result-input::placeholder {
    color: #64748b;
    opacity: 1;
}

.asc-clear-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.asc-clear-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Share Buttons */
.asc-share-group {
    display: flex;
    gap: 8px;
    margin: 0 4px;
}

.asc-share-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.asc-share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.asc-share-btn:active {
    transform: translateY(0);
}

.asc-fb {
    background-color: #1877F2;
}

.asc-x {
    background-color: #000000;
}

.asc-line {
    background-color: #06C755;
}

/* Copy Button */
.asc-copy-btn {
    background: #0f172a;
    /* Dark sleek color */
    color: #fff;
    border: none;
    padding: 0 20px;
    /* Adjust padding */
    height: 36px;
    /* Match height */
    border-radius: 18px;
    /* Rounded pill */
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
}

.asc-copy-btn:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.15);
}

.asc-copy-btn:active {
    transform: translateY(0);
}

/* Adjust Toast Position */
.asc-toast {
    position: fixed;
    /* Use fixed relative to viewport for safety */
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #1e293b;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000000;
    /* Above footer */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.asc-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .asc-sticky-footer {
        padding: 12px 10px;
    }

    .asc-footer-container {
        gap: 8px;
    }

    .asc-share-btn {
        width: 32px;
        height: 32px;
    }

    .asc-copy-btn {
        padding: 0 16px;
        height: 32px;
        font-size: 13px;
    }

    .asc-input-group {
        /* Keep input grow */
    }
}

/* Loading Indicator */
.asc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--asc-text-light);
    gap: 12px;
    font-size: 14px;
}

.asc-loading.hidden {
    display: none;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid var(--asc-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .asc-main-header {
        flex-direction: column;
        align-items: stretch;
    }

    .asc-header-left {
        justify-content: center;
        margin-bottom: 12px;
    }

    .asc-header-right {
        flex-direction: column;
        max-width: 100%;
        gap: 12px;
    }

    .asc-search-wrapper,
    .asc-category-select {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        flex: auto;
    }

    .asc-grid {
        grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    }

    .asc-char-item {
        font-size: 20px;
    }
}