/* CSS Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);

    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.1);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(102, 126, 234, 0.5);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(102, 126, 234, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(79, 172, 254, 0.1) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
    animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: relative;
    padding: 3rem 2rem 4rem;
    text-align: center;
    overflow: hidden;
}

.header-content {
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    font-size: 2rem;
    font-weight: 700;
    box-shadow: var(--shadow-glow);
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.05em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

.header-decoration {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--bg-primary));
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 0 2rem 3rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Search Section */
.search-section {
    margin-bottom: 3rem;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input {
    flex: 1;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-family: inherit;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.search-btn:active {
    transform: translateY(0);
}

.search-icon {
    width: 20px;
    height: 20px;
}

/* Decompose Button */
.decompose-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--secondary-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.decompose-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(240, 147, 251, 0.4);
}

.decompose-btn:active {
    transform: translateY(0);
}

.decompose-icon {
    width: 20px;
    height: 20px;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease, toastSlideOut 0.3s ease forwards;
    animation-delay: 0s, 2.7s;
}

.toast.success {
    border-color: rgba(34, 197, 94, 0.5);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), var(--bg-secondary));
}

.toast.warning {
    border-color: rgba(251, 191, 36, 0.5);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), var(--bg-secondary));
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.5);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), var(--bg-secondary));
}

.toast.info {
    border-color: var(--border-glow);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), var(--bg-secondary));
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.search-tips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.tip-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.tip-btn {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tip-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-glow);
    transform: translateY(-2px);
}

/* Results Section */
.results-section {
    position: relative;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.results-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.results-title span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.results-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
}

/* Character Card */
.char-card {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 2rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.char-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.char-card:hover {
    transform: translateY(-4px) scale(1.05);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.char-card:hover::before {
    opacity: 0.15;
}

.char-card span {
    position: relative;
    z-index: 1;
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1.5rem;
}

.loading-indicator.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.empty-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 10;
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-content {
    padding: 2rem;
    overflow-y: auto;
    max-height: 85vh;
}

/* Character Detail */
.char-detail {
    text-align: center;
}

.char-display {
    font-size: 8rem;
    font-weight: 400;
    line-height: 1;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.char-unicode {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.detail-section {
    margin-bottom: 1.5rem;
    text-align: left;
}

.detail-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.pronunciation-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pronunciation-tag {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.component-grid {
    display: grid;
    gap: 0.75rem;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.component-key {
    color: var(--text-muted);
    font-size: 0.9rem;
    min-width: 80px;
}

.component-value {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.variant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.variant-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.variant-char:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    transform: scale(1.1);
}

.no-data {
    color: var(--text-muted);
    font-style: italic;
}

/* Footer */
.footer {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 2rem 1rem 3rem;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .logo-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .main-content {
        padding: 0 1rem 2rem;
    }

    .search-box {
        flex-direction: column;
    }

    .search-btn {
        justify-content: center;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 0.75rem;
    }

    .char-card {
        font-size: 1.5rem;
    }

    .modal {
        max-height: 90vh;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .char-display {
        font-size: 5rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Animation for results */
.char-card {
    animation: fadeInUp 0.3s ease backwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation delay */
.char-card:nth-child(1) {
    animation-delay: 0.02s;
}

.char-card:nth-child(2) {
    animation-delay: 0.04s;
}

.char-card:nth-child(3) {
    animation-delay: 0.06s;
}

.char-card:nth-child(4) {
    animation-delay: 0.08s;
}

.char-card:nth-child(5) {
    animation-delay: 0.1s;
}

.char-card:nth-child(6) {
    animation-delay: 0.12s;
}

.char-card:nth-child(7) {
    animation-delay: 0.14s;
}

.char-card:nth-child(8) {
    animation-delay: 0.16s;
}

.char-card:nth-child(9) {
    animation-delay: 0.18s;
}

.char-card:nth-child(10) {
    animation-delay: 0.2s;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: rgba(102, 126, 234, 0.4);
    color: white;
}