/* ============================================
   An-Gallery — CSS
   Dark theme figure collection
   ============================================ */

:root {
    --bg-primary: #0d0d0f;
    --bg-secondary: #16161a;
    --bg-card: #1c1c22;
    --bg-card-hover: #222229;
    --bg-input: #1a1a20;
    --border: #2a2a32;
    --border-light: #35353f;
    --text-primary: #e8e6e3;
    --text-secondary: #9a9a9a;
    --text-muted: #6b6b6b;
    --accent: #e87461;
    --accent-hover: #f08574;
    --accent-soft: rgba(232, 116, 97, 0.12);
    --success: #5cb985;
    --warning: #e8b44e;
    --info: #5b9bd5;
    --tag-bg: #252530;
    --tag-text: #c0bdb8;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --font-display: 'Zen Kaku Gothic New', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
    --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-weight: 400;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

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

/* ---- HEADER ---- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 13, 15, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 0;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}
.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
}
.logo:hover { color: var(--text-primary); }

.main-nav { display: flex; gap: 4px; }
.nav-link {
    padding: 6px 16px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }
.nav-admin {
    color: var(--accent);
    border: 1px solid var(--accent);
    margin-left: 8px;
}
.nav-admin:hover { background: var(--accent); color: #fff; }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ---- HERO / PAGE HEADER ---- */
.page-header {
    padding: 48px 0 32px;
}
.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 6px;
}
.stats-row {
    display: flex;
    gap: 24px;
    margin-top: 16px;
}
.stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.stat-num {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- FILTERS ---- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    margin-bottom: 24px;
}
.filter-select, .filter-input {
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}
.filter-select:focus, .filter-input:focus { border-color: var(--accent); }
.filter-input { min-width: 200px; }

/* ---- FIGURE GRID ---- */
.figures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding-bottom: 48px;
}
.figure-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
}
.figure-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-light);
    box-shadow: var(--shadow-lg);
}
.figure-card .card-image {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--bg-secondary);
}
.figure-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.figure-card:hover .card-image img { transform: scale(1.05); }
.card-status {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-owned { background: var(--success); color: #fff; }
.status-ordered { background: var(--warning); color: #1a1a1a; }
.status-wished { background: var(--info); color: #fff; }

.card-body { padding: 14px 16px 18px; }
.card-body .card-character {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 4px;
}
.card-body .card-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.card-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
}

/* ---- FIGURE DETAIL PAGE ---- */
.figure-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding: 32px 0 64px;
}
.figure-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.gallery-main {
    aspect-ratio: 4/5;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}
.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: zoom-in;
}
.gallery-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.gallery-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--transition);
}
.gallery-thumb.active, .gallery-thumb:hover { border-color: var(--accent); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.figure-info { padding-top: 8px; }
.figure-info h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.figure-origin {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 20px;
}
.info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table th {
    text-align: left;
    padding: 10px 16px 10px 0;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85rem;
    width: 140px;
    white-space: nowrap;
}
.info-table td {
    padding: 10px 0;
    font-size: 0.9rem;
}

/* ---- ORDER INFO (admin only) ---- */
.order-section {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.order-section h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.order-section h3::before { content: '🔒'; font-size: 0.85rem; }

/* ---- ADMIN PANEL ---- */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: calc(100vh - 60px);
}
.admin-sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px 0;
}
.admin-sidebar .sidebar-link {
    display: block;
    padding: 10px 24px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all var(--transition);
}
.admin-sidebar .sidebar-link:hover { color: var(--text-primary); background: var(--bg-card); }
.admin-sidebar .sidebar-link.active { color: var(--accent); background: var(--accent-soft); border-right: 3px solid var(--accent); }

.admin-content {
    padding: 32px;
}
.admin-content h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 24px;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition);
    outline: none;
}
.form-control:focus { border-color: var(--accent); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-light); }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

/* ---- IMAGE UPLOAD ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-input);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.upload-zone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.upload-preview .preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
}
.upload-preview .preview-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview .preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-item.is-cover { border-color: var(--accent); }
.preview-item .cover-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    text-align: center;
    padding: 2px;
    font-weight: 600;
}

/* ---- DATA TABLE (admin) ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}
.data-table tr:hover td { background: var(--bg-card); }
.data-table .thumb-sm {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}
.actions-cell { display: flex; gap: 6px; }

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
}
.alert-success { background: rgba(92, 185, 133, 0.15); color: var(--success); border: 1px solid rgba(92,185,133,0.3); }
.alert-error { background: rgba(192, 57, 43, 0.15); color: #e74c3c; border: 1px solid rgba(231,76,60,0.3); }

/* ---- LIGHTBOX ---- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.92);
    justify-content: center;
    align-items: center;
    padding: 32px;
}
.lightbox.active { display: flex; }
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}
.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.7;
}
.lightbox-close:hover { opacity: 1; }

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 32px 0;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all var(--transition);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 64px 0;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 1rem; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .main-nav { 
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        flex-direction: column;
        padding: 12px;
        border-bottom: 1px solid var(--border);
    }
    .main-nav.open { display: flex; }
    .nav-toggle { display: flex; }
    .figures-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .figure-detail { grid-template-columns: 1fr; gap: 24px; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: fixed;
        left: -220px;
        top: 60px;
        bottom: 0;
        width: 220px;
        z-index: 90;
        transition: left 0.3s ease;
    }
    .admin-sidebar.open { left: 0; }
    .admin-content { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 1.3rem; }
    .stats-row { gap: 16px; }
}
