/* ─── Theme Variables ─── */
:root {
    --bg: #0f0f1a;
    --bg2: #1a1a2e;
    --bg3: #25253e;
    --text: #e0e0e8;
    --text2: #a0a0b8;
    --accent: #7c5cfc;
    --accent2: #5a3fd4;
    --border: #2a2a44;
    --danger: #ff4757;
    --success: #2ed573;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,.3);
}

[data-theme="light"] {
    --bg: #f5f5fa;
    --bg2: #ffffff;
    --bg3: #e8e8f0;
    --text: #1a1a2e;
    --text2: #6a6a84;
    --accent: #6c4ce8;
    --accent2: #5a3fd4;
    --border: #d0d0e0;
    --shadow: 0 2px 12px rgba(0,0,0,.1);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }
img { max-width: 100%; height: auto; }

/* ─── Navbar ─── */
.navbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent) !important;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.nav-logo-img {
    height: 28px;
    width: auto;
    border-radius: 4px;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.nav-links a {
    color: var(--text2);
    font-size: .9rem;
    transition: color .2s;
}
.nav-links a:hover { color: var(--text); }
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
}
.theme-toggle {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.theme-toggle:hover { background: var(--accent); }

/* ─── Container ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    min-height: calc(100vh - 56px - 80px);
}

/* ─── Gallery ─── */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.gallery-header h1 { font-size: 1.5rem; }
.sort-links { display: flex; gap: .5rem; }
.sort-links a {
    padding: .3rem .8rem;
    border-radius: var(--radius);
    background: var(--bg3);
    color: var(--text2);
    font-size: .85rem;
}
.sort-links a.active { background: var(--accent); color: #fff; }

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1.5rem;
    padding: .8rem;
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.tag {
    display: inline-block;
    padding: .2rem .6rem;
    background: var(--bg3);
    border-radius: 4px;
    font-size: .8rem;
    color: var(--text2);
    white-space: nowrap;
}
.tag:hover { background: var(--accent); color: #fff; }
.tag.active { background: var(--accent); color: #fff; }
.clear-tag { background: var(--danger); color: #fff; }
.clear-tag:hover { opacity: .8; }

/* ─── Card Grid ─── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.card-item {
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
}
.card-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.card-thumb {
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--bg3);
}
.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-info {
    padding: .6rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.card-name {
    font-weight: 600;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-meta {
    font-size: .8rem;
    color: var(--text2);
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text2);
}
.empty-state h1 { font-size: 3rem; margin-bottom: .5rem; }

/* ─── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}
.page-link {
    padding: .5rem 1rem;
    border-radius: var(--radius);
    background: var(--bg3);
    color: var(--text);
    font-size: .9rem;
}
.page-link:hover { background: var(--accent); color: #fff; }
.page-info { color: var(--text2); font-size: .9rem; }

/* ─── Auth Forms ─── */
.auth-form {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--bg2);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.auth-form h1 { margin-bottom: 1rem; font-size: 1.5rem; }
.auth-form label { display: block; margin-bottom: .3rem; font-size: .9rem; color: var(--text2); }
.auth-form input {
    width: 100%;
    padding: .6rem;
    margin-bottom: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 1rem;
}
.auth-link { margin-top: 1rem; text-align: center; font-size: .9rem; }

/* ─── Buttons ─── */
.btn {
    display: inline-block;
    padding: .6rem 1.2rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .9rem;
    transition: background .2s;
}
.btn:hover { background: var(--accent2); color: #fff; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }

/* ─── Alerts ─── */
.alert {
    padding: .8rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-error { background: rgba(255,71,87,.15); color: var(--danger); border: 1px solid rgba(255,71,87,.3); }

/* ─── Upload ─── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s;
    margin-bottom: 1rem;
}
.drop-zone:hover { border-color: var(--accent); }
.drop-zone input[type="file"] { display: none; }
.drop-zone p { color: var(--text2); }

.image-field { margin-bottom: 1rem; }
.image-field label { display: block; margin-bottom: .5rem; color: var(--text2); font-size: .9rem; }
.image-field input[type="file"] { display: block; }
.image-preview { margin-top: .5rem; }
.image-preview img { max-width: 200px; max-height: 200px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); }
.upload-fields { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.upload-fields > div { flex: 1; min-width: 250px; }

/* ─── Card Detail ─── */
.card-main {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.card-avatar {
    flex-shrink: 0;
    width: 250px;
}
.card-avatar img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.card-data { flex: 1; min-width: 300px; }
.card-data h1 { margin-bottom: .5rem; }
.card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .8rem;
    margin-bottom: 1rem;
    font-size: .85rem;
    color: var(--text2);
}
.card-actions {
    display: flex;
    gap: .8rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.favorite-btn.favorited { background: var(--danger); }
.card-sections section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.card-sections h3 { margin-bottom: .5rem; font-size: 1rem; color: var(--accent); }
.card-sections blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text2);
    font-style: italic;
}
.card-sections pre {
    background: var(--bg);
    padding: .8rem;
    border-radius: var(--radius);
    font-size: .85rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* ─── Comments ─── */
.card-comments { margin-top: 2rem; }
.card-comments h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.comment-form { margin-bottom: 1.5rem; }
.comment-form textarea {
    width: 100%;
    padding: .6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    resize: vertical;
    font-family: inherit;
    font-size: .9rem;
    margin-bottom: .5rem;
}
.comment {
    padding: .8rem;
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: .5rem;
}
.comment-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .3rem;
    font-size: .85rem;
}
.comment-time { color: var(--text2); font-size: .8rem; }
.comment-delete { color: var(--danger); margin-left: auto; font-weight: bold; }
.comment-body { font-size: .9rem; }

/* ─── Profile ─── */
.profile-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
}
.profile-info h1 { margin-bottom: .3rem; }
.profile-meta { color: var(--text2); font-size: .9rem; margin-bottom: .5rem; }
.profile-bio { margin-bottom: 1rem; }
.bio-form textarea {
    width: 100%;
    padding: .6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    resize: vertical;
    font-family: inherit;
    font-size: .9rem;
    margin-bottom: .5rem;
}
.profile-page h2 { margin-bottom: 1rem; }

/* ─── Search ─── */
.search-form {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.search-form input {
    flex: 1;
    padding: .6rem;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 1rem;
}
.search-count, .search-tag { margin-bottom: 1rem; color: var(--text2); font-size: .9rem; }

/* ─── Admin ─── */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    padding: 1.5rem;
    background: var(--bg2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
}
.stat-card h3 { font-size: 2rem; color: var(--accent); }
.stat-card p { color: var(--text2); font-size: .9rem; }
.admin-links { display: flex; gap: .5rem; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: .9rem;
}
.admin-table th {
    text-align: left;
    padding: .6rem;
    border-bottom: 2px solid var(--border);
    color: var(--text2);
}
.admin-table td {
    padding: .6rem;
    border-bottom: 1px solid var(--border);
}
.admin-table a { margin-right: .5rem; }

/* ─── Footer ─── */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg2);
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: .85rem;
    color: var(--text2);
}

/* ─── Edit Card ─── */
.edit-card-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    margin-top: 1.5rem;
}
.edit-card-preview img {
    width: 100%;
    border-radius: var(--radius);
    object-fit: cover;
}
.edit-card-form .form-group {
    margin-bottom: 1rem;
}
.edit-card-form label {
    display: block;
    margin-bottom: .4rem;
    color: var(--text2);
    font-size: .9rem;
}
.edit-card-form input[type="text"] {
    width: 100%;
    padding: .6rem .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg1);
    color: var(--text1);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .nav-links { display: none; flex-direction: column; position: absolute; top: 56px; left: 0; right: 0; background: var(--bg2); padding: 1rem; border-bottom: 1px solid var(--border); }
    .nav-links.show { display: flex; }
    .hamburger { display: block; }
    .card-main { flex-direction: column; }
    .card-avatar { width: 200px; }
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .gallery-header { flex-direction: column; align-items: flex-start; }
}
