/* CSS Variables */
:root {
    /* Colors */
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --secondary-color: #6366f1;
    --accent-blue: #0ea5e9;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-orange: #f97316;
    --accent-yellow: #f59e0b;

    /* Light Theme */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --header-bg: rgba(255, 255, 255, 0.8);
    --sidebar-bg: #ffffff;
    --content-bg: #f8fafc;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.3);

    --header-bg: rgba(15, 23, 42, 0.8);
    --sidebar-bg: #1e293b;
    --content-bg: #0f172a;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

body.menu-open {
    overflow: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

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

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

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Header Styles */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: all var(--transition-normal);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--primary-color);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.slogan {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.search-section {
    flex: 1;
    max-width: 500px;
    margin: 0 40px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 44px;
    padding: 0 44px 0 48px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

.search-clear {
    position: absolute;
    right: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.search-clear.visible {
    display: flex;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.favorites-count {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent-orange);
    border-radius: 9px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
    text-align: center;
    line-height: 18px;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.favorites-count.visible {
    opacity: 1;
    transform: scale(1);
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

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

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

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 900;
    transition: transform var(--transition-normal), background-color var(--transition-normal);
}

.nav-menu {
    padding: 16px 12px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    padding: 16px 12px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    flex-direction: column;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(99, 102, 241, 0.15));
    color: var(--primary-color);
}

.nav-link svg {
    flex-shrink: 0;
}

/* Overlay */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 800;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.overlay.visible {
    display: block;
    opacity: 1;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: calc(var(--header-height) + 24px) 32px 64px;
    min-height: 100vh;
    background: var(--content-bg);
    transition: margin-left var(--transition-normal), background-color var(--transition-normal);
}

/* Daily Banner */
.daily-banner {
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 50%, #8b5cf6 100%);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 40px;
    color: white;
    position: relative;
    overflow: hidden;
}

.daily-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.daily-banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: 10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
    border-radius: 50%;
}

.banner-content {
    position: relative;
    z-index: 1;
    margin-bottom: 24px;
}

.banner-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.banner-subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.banner-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    position: relative;
    z-index: 1;
}

.banner-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.banner-card:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.card-tag {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.banner-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.banner-card p {
    font-size: 0.875rem;
    opacity: 0.85;
    line-height: 1.5;
}

/* Section Styles */
.category-section {
    margin-bottom: 48px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-title svg {
    flex-shrink: 0;
}

.section-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.section-purple .section-title svg {
    stroke: var(--accent-purple);
}

.section-green .section-title svg {
    stroke: var(--accent-green);
}

.section-orange .section-title svg {
    stroke: var(--accent-orange);
}

.favorites-section .section-title svg {
    stroke: var(--accent-yellow);
}

.clear-favorites {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-favorites:hover {
    background: #fee2e2;
    color: #ef4444;
}

.search-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 8px;
}

/* Resource Grid */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* Resource Card */
.resource-card {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.resource-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.resource-card.favorited {
    border-color: var(--accent-yellow);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(249, 115, 22, 0.05));
}

.card-icon-wrapper {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-primary));
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    font-size: 1.5rem;
    overflow: hidden;
}

.card-icon-wrapper svg {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
}

.resource-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resource-card p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.card-tag-item {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.card-favorite-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.resource-card:hover .card-favorite-btn {
    opacity: 1;
}

.card-favorite-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-yellow);
}

.card-favorite-btn.favorited {
    opacity: 1;
    color: var(--accent-yellow);
}

.card-favorite-btn.favorited svg {
    fill: var(--accent-yellow);
}

/* Favorites Section */
.favorites-section {
    margin-bottom: 40px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(249, 115, 22, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-xl);
}

.favorites-section.hidden {
    display: none;
}

/* Search Results Section */
.search-results-section {
    margin-bottom: 40px;
}

.search-results-section.hidden {
    display: none;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.no-results svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.no-results p {
    font-size: 0.9375rem;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--primary-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

/* Empty State */
.empty-favorites {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-favorites svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-favorites p {
    font-size: 0.9375rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .resource-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .slogan {
        display: none;
    }

    .search-section {
        margin: 0 16px;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .header-container {
        padding: 0 16px;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .search-section {
        display: none;
    }

    .main-content {
        padding: calc(var(--header-height) + 16px) 16px 48px;
    }

    .daily-banner {
        padding: 24px;
        margin-bottom: 32px;
    }

    .banner-cards {
        grid-template-columns: 1fr;
    }

    .banner-title {
        font-size: 1.5rem;
    }

    .category-section {
        margin-bottom: 32px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .section-title {
        font-size: 1.125rem;
    }

    .resource-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .resource-card {
        padding: 16px;
    }

    .card-icon-wrapper {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
    }

    .card-icon-wrapper svg {
        width: 24px;
        height: 24px;
    }

    .resource-card h3 {
        font-size: 0.9375rem;
    }

    .resource-card p {
        font-size: 0.8125rem;
        -webkit-line-clamp: 2;
    }

    .back-to-top {
        bottom: 24px;
        right: 24px;
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .resource-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .resource-card {
        padding: 14px;
    }

    .card-icon-wrapper {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
    }

    .card-icon-wrapper svg {
        width: 20px;
        height: 20px;
    }

    .resource-card h3 {
        font-size: 0.875rem;
        margin-bottom: 6px;
    }

    .resource-card p {
        font-size: 0.75rem;
        margin-bottom: 10px;
    }

    .card-tags {
        display: none;
    }
}

/* Animation Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.resource-card {
    animation: fadeIn 0.4s ease forwards;
}

.nav-item {
    animation: slideIn 0.3s ease forwards;
}

/* Stagger animation for cards */
.resource-grid .resource-card:nth-child(1) { animation-delay: 0.05s; }
.resource-grid .resource-card:nth-child(2) { animation-delay: 0.1s; }
.resource-grid .resource-card:nth-child(3) { animation-delay: 0.15s; }
.resource-grid .resource-card:nth-child(4) { animation-delay: 0.2s; }
.resource-grid .resource-card:nth-child(5) { animation-delay: 0.25s; }
.resource-grid .resource-card:nth-child(6) { animation-delay: 0.3s; }

/* Focus States */
.search-input:focus,
.nav-link:focus,
.action-btn:focus,
.resource-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .header,
    .sidebar,
    .back-to-top,
    .overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .resource-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
