:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --primary-dark: #3f37c9;
    --secondary: #4cc9f0;
    --background: #f8f9fa;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #ffffff;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border: rgba(226, 232, 240, 0.8);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 8px 16px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 24px rgba(0,0,0,0.06);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Noto Sans TC', 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Decorative Elements */
.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 15% 50%, rgba(67, 97, 238, 0.05), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(76, 201, 240, 0.05), transparent 25%);
}

.background-decor::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -10%;
    width: 50%;
    height: 60%;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(80px);
}

.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

/* Hero Banner Matching Image Style */
.hero-banner {
    background-color: #21418b;
    background: linear-gradient(135deg, #244699 0%, #1c377a 100%);
    color: white;
    width: 100%;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    padding: 1.5rem 0 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.hero-banner-inner {
    width: 100%;
    margin: 0 auto;
    padding: 0 2.5rem;
}

.hero-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.hero-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hero-logo-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 24px;
}

.hero-logo-bars span {
    display: block;
    width: 3px;
    border-radius: 2px;
}
.hero-logo-bars .bar-1 { height: 16px; background-color: #fde047; }
.hero-logo-bars .bar-2 { height: 24px; background-color: #facc15; }
.hero-logo-bars .bar-3 { height: 20px; background-color: #ffffff; }
.hero-logo-bars .bar-4 { height: 14px; background-color: #eab308; }

.hero-logo-text .title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 0.1rem;
    color: #ffffff;
}

.hero-logo-text .subtitle {
    font-size: 0.8rem;
    font-weight: 400;
    color: #e2e8f0;
    letter-spacing: 0.5px;
}

.hero-top-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.hero-top-links a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.hero-top-links a:hover {
    color: #ffffff;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-content h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: 2px;
    color: #ffffff;
}

.hero-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
}

.hero-search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1.3rem;
    z-index: 2;
}

.hero-search-wrapper #searchInput {
    width: 100%;
    padding: 1.1rem 3rem 1.1rem 3.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1.15rem;
    color: var(--text-dark);
    font-family: inherit;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    background: #ffffff;
    transition: var(--transition);
}

.hero-search-wrapper #searchInput::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.hero-search-wrapper #searchInput:focus {
    outline: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(255, 255, 255, 0.2);
}

.hero-clear-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 2;
    transition: var(--transition);
}

.hero-clear-btn:hover {
    color: var(--text-dark);
}

/* Controls Section (Search & Filters) */
.controls-section {
    padding: 2rem;
}


.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 0 2.5rem;
    border-radius: 50px;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 6px 15px rgba(67, 97, 238, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(67, 97, 238, 0.3);
}

/* Filters */
.filters-container {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.filter-label {
    min-width: 80px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    background: var(--background);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.filter-btn:hover {
    background: var(--surface-solid);
    border-color: var(--primary-light);
    color: var(--primary);
    transform: translateY(-1px);
}

.filter-btn.active, .btn-secondary.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.2);
}

.btn-secondary {
    background: var(--background);
    border: 1px solid var(--border);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-md);
    color: var(--text-dark);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

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

/* Table Section */
.table-section {
    padding: 2rem;
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table-header h2 {
    font-size: 1.4rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-header h2 i {
    color: var(--primary);
}

.result-count {
    background: var(--background);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border);
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-solid);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.modern-table th {
    background: #f1f5f9;
    padding: 1.2rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.modern-table td {
    padding: 1.2rem 1.5rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dark);
    transition: var(--transition);
    vertical-align: middle;
}

.modern-table tbody tr {
    transition: var(--transition);
}

.modern-table tbody tr:hover {
    background-color: #f8fafc;
    transform: scale(1.002);
    box-shadow: var(--shadow-sm);
    z-index: 1;
    position: relative;
}

.modern-table tbody tr:last-child td {
    border-bottom: none;
}

/* Sorting and Select Styles */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.sortable:hover {
    color: var(--primary-dark);
    background: #e2e8f0;
}

.sortable i {
    margin-left: 0.3rem;
    color: var(--text-muted);
    opacity: 0.4;
    transition: var(--transition);
}

.sortable.asc i {
    opacity: 1;
    color: var(--primary);
}

.sortable.desc i {
    opacity: 1;
    color: var(--primary);
}

.modern-select {
    padding: 0.4rem 2rem 0.4rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--surface-solid);
    color: var(--text-dark);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748b%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem top 50%;
    background-size: 0.65rem auto;
    transition: var(--transition);
}

.modern-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

/* Links and Badges Formatting */
.db-name {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 1.15rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    background: #f1f5f9;
    color: #475569;
    line-height: 1.2;
    white-space: nowrap;
}

.badge-subject {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-dark);
}

.badge-lang {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
}

.badge-purchase {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.badge-free {
    background: rgba(20, 184, 166, 0.15); /* Teal */
    color: #0f766e;
}

.badge-gift {
    background: rgba(168, 85, 247, 0.15); /* Purple */
    color: #7e22ce;
}

.badge-note {
    background: rgba(100, 116, 139, 0.1);
    color: #475569;
}

.badge-type {
    background: rgba(76, 201, 240, 0.15);
    color: #0369a1;
}

.action-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(67, 97, 238, 0.08);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.action-link:hover {
    background: var(--primary);
    color: white;
}

.file-link {
    color: #ec4899;
    background: rgba(236, 72, 153, 0.05);
}

.file-link:hover {
    background: #ec4899;
}

.no-file {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

/* Loading State */
.loading-cell {
    text-align: center;
    padding: 4rem !important;
    color: var(--text-muted);
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(67, 97, 238, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text-dark);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.25);
}

.page-btn:disabled {
    background: var(--background);
    color: var(--border);
    cursor: not-allowed;
}

/* App Footer */
.hero-footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    background-color: #111827; /* Dark slate matching the image */
    padding: 1.5rem;
    font-size: 0.95rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 900px) {
    .hero-top-bar {
        flex-direction: column;
        gap: 1.5rem;
    }

    .hero-logo {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .hero-content h1 {
        font-size: 1.6rem;
    }
    
    .hero-search-wrapper #searchInput {
        font-size: 1rem;
        padding: 1rem 2.5rem 1rem 2.5rem;
    }
    
    .hero-search-icon {
        font-size: 1.1rem;
        left: 1rem;
    }
    
    .btn-primary {
        padding: 1rem;
    }
}
