/* Global Styles & Variables */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Sans+TC:wght@300;400;500;700;900&display=swap');

:root {
    --font-primary: 'Outfit', 'Noto Sans TC', sans-serif;
    --bg-dark: #0b0f19;
    --bg-card-dark: rgba(22, 28, 45, 0.7);
    --bg-card-light: rgba(255, 255, 255, 0.8);
    --text-light: #f3f4f6;
    --text-dark: #1f2937;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.15);
    --gold: #f59e0b;
    --border-color-dark: rgba(255, 255, 255, 0.08);
    --border-color-light: rgba(0, 0, 0, 0.08);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-light);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Header Styles */
header {
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color-dark);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #a78bfa 0%, #6366f1 50%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-link {
    color: var(--text-muted) !important;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-link:hover, .nav-link.active {
    color: var(--text-light) !important;
}

/* Hero Section */
.hero-section {
    position: relative;
    padding: 80px 0 60px;
    background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0%, rgba(11, 15, 25, 0) 70%);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 20px;
}

.hero-title span {
    background: linear-gradient(135deg, #a78bfa, #818cf8, #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 30px;
}

/* Stats Counter */
.stat-tag {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color-dark);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.9rem;
    margin: 5px;
}

.stat-tag i {
    color: var(--primary);
    margin-right: 8px;
}

/* Search and Controls */
.search-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color-dark);
    color: var(--text-light);
    border-radius: 12px;
    padding: 12px 20px;
    transition: var(--transition-smooth);
}

.search-control:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    color: var(--text-light);
}

.search-icon-wrapper {
    position: relative;
}

.search-icon-wrapper i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color-dark);
    color: var(--text-light);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.control-btn:hover, .control-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Layout Wrapper */
.gallery-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    padding: 40px 0;
}

@media (max-width: 991px) {
    .gallery-layout {
        grid-template-columns: 1fr;
    }
}

/* Filter Sidebar */
.filter-sidebar {
    background: rgba(22, 28, 45, 0.4);
    border: 1px solid var(--border-color-dark);
    border-radius: 20px;
    padding: 24px;
    position: sticky;
    top: 90px;
    height: fit-content;
}

.filter-group {
    margin-bottom: 24px;
}

.filter-group-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.filter-group-title i {
    margin-right: 8px;
    color: var(--primary);
}

.filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    margin-bottom: 4px;
}

.filter-item:hover, .filter-item.active {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
}

.filter-badge {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.filter-item.active .filter-badge {
    background: var(--primary);
    color: var(--text-light);
}

/* Template Grid and Cards */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    transition: var(--transition-smooth);
}

.template-grid.list-view {
    grid-template-columns: 1fr;
}

.template-card {
    background: var(--bg-card-dark);
    border: 1px solid var(--border-color-dark);
    border-radius: 20px;
    overflow: hidden;
    transition: var(--transition-smooth);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--primary);
}

.card-img-wrapper {
    position: relative;
    padding-top: 60%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.2);
}

.card-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.template-card:hover .card-img-wrapper img {
    transform: scale(1.05);
}

.card-badge-top {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border-color-dark);
}

.card-badge-theme {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary);
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.card-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 2px 8px;
    border-radius: 6px;
}

.card-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.card-tag {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color-dark);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
    border-top: 1px solid var(--border-color-dark);
    padding-top: 15px;
    margin-bottom: 15px;
}

.card-meta span {
    display: flex;
    align-items: center;
}

.card-meta i {
    margin-right: 6px;
    color: var(--primary);
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.card-btn {
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.btn-primary-custom {
    background: var(--primary);
    color: white;
}

.btn-primary-custom:hover {
    background: #4f46e5;
    color: white;
}

.btn-secondary-custom {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color-dark);
    color: var(--text-light);
}

.btn-secondary-custom:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.btn-disabled {
    background: rgba(255, 255, 255, 0.02) !important;
    border-color: var(--border-color-dark) !important;
    color: rgba(255, 255, 255, 0.2) !important;
    cursor: not-allowed;
}

/* List View Style Overrides */
.template-grid.list-view .template-card {
    flex-direction: row;
    height: auto;
}

@media (max-width: 767px) {
    .template-grid.list-view .template-card {
        flex-direction: column;
    }
}

.template-grid.list-view .card-img-wrapper {
    width: 300px;
    padding-top: 0;
    min-height: 100%;
}

@media (max-width: 767px) {
    .template-grid.list-view .card-img-wrapper {
        width: 100%;
        padding-top: 60%;
    }
}

.template-grid.list-view .card-body {
    padding: 30px;
}

/* Details Page Styles */
.detail-header {
    padding: 60px 0 40px;
    border-bottom: 1px solid var(--border-color-dark);
    background: radial-gradient(circle at 10% 50%, rgba(99, 102, 241, 0.08) 0%, rgba(11, 15, 25, 0) 100%);
}

.detail-back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    margin-bottom: 30px;
    transition: var(--transition-smooth);
}

.detail-back-link:hover {
    color: var(--primary);
    transform: translateX(-4px);
}

.detail-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 15px;
}

.detail-img-wrapper {
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color-dark);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    margin-bottom: 30px;
}

.detail-img-wrapper img {
    width: 100%;
    height: auto;
}

.spec-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color-dark);
    padding: 10px 20px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.spec-badge-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.spec-badge-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

.prompt-box {
    background: rgba(11, 15, 25, 0.6);
    border: 1px solid var(--border-color-dark);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
}

.prompt-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color-dark);
    padding-bottom: 12px;
}

.prompt-box-header h5 {
    margin: 0;
    font-weight: 700;
}

.prompt-code {
    font-family: 'Courier New', Courier, monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    color: #e5e7eb;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 400px;
}

/* Footer */
footer {
    background: #07090f;
    border-top: 1px solid var(--border-color-dark);
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-smooth);
}

footer a:hover {
    color: var(--text-light);
}

/* Helper styles for Light mode cards preview inside dark theme */
.mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 4px;
    padding: 2px 6px;
}

.mode-dark {
    background: rgba(0, 0, 0, 0.4);
    color: #a78bfa;
}

.mode-light {
    background: rgba(255, 255, 255, 0.9);
    color: #1e3a8a;
}
