:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-nav: #0f3460;
    --accent: #e94560;
    --accent-secondary: #533483;
    --text: #eee;
    --text-muted: #aaa;
    --success: #4CAF50;
    --warning: #FF9800;
    --info: #2196F3;
    --danger: #e94560;
    --radius: 12px;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

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

/* Layout */
.app-container { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 240px; background: var(--bg-nav);
    padding: 1.5rem 0; z-index: 100;
    display: flex; flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
}
.sidebar-logo { padding: 0 1.5rem 1.5rem; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.05); margin-bottom: 1rem; }
.sidebar-logo img { max-width: 120px; border-radius: 8px; }
.sidebar-logo h2 { margin: 0.5rem 0 0; font-size: 1.2rem; color: var(--accent); }
.sidebar-nav { flex: 1; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1.5rem; color: var(--text-muted);
    transition: all 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(233,69,96,0.1); color: var(--accent); }
.sidebar-user { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,0.05); font-size: 0.85rem; color: var(--text-muted); }

.main-content { flex: 1; margin-left: 240px; padding: 2rem; padding-bottom: 2rem; min-height: 100vh; }

.bottom-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-nav); z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 0.5rem 0; padding-bottom: env(safe-area-inset-bottom, 0.5rem);
}
.bottom-nav-items { display: flex; justify-content: space-around; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; color: var(--text-muted); font-size: 0.7rem; padding: 0.25rem; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a .nav-icon { font-size: 1.3rem; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h2 { margin: 0; font-size: 1.2rem; }

/* Grid / List / Detail views */
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.grid-item { background: var(--bg-card); border-radius: var(--radius); overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.grid-item:hover { transform: translateY(-4px); box-shadow: 0 8px 16px rgba(0,0,0,0.4); }
.grid-item img { width: 100%; height: 180px; object-fit: cover; background: #0a0a1a; }
.grid-item .item-info { padding: 0.75rem; }
.grid-item .item-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-item .item-meta { font-size: 0.75rem; color: var(--text-muted); }

.list-view { display: flex; flex-direction: column; gap: 0.5rem; }
.list-item { display: flex; align-items: center; gap: 1rem; background: var(--bg-card); border-radius: 8px; padding: 0.75rem; cursor: pointer; transition: background 0.2s; }
.list-item:hover { background: rgba(233,69,96,0.05); }
.list-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; background: #0a0a1a; }
.list-item .item-info { flex: 1; }
.list-item .item-name { font-weight: 600; font-size: 0.9rem; }
.list-item .item-meta { font-size: 0.75rem; color: var(--text-muted); }

.detail-view { display: flex; flex-direction: column; gap: 1rem; }
.detail-item { display: flex; gap: 1.5rem; background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; cursor: pointer; transition: background 0.2s; }
.detail-item:hover { background: rgba(233,69,96,0.05); }
.detail-item img { width: 150px; height: 150px; object-fit: cover; border-radius: 8px; background: #0a0a1a; flex-shrink: 0; }
.detail-item .item-info { flex: 1; }
.detail-item .item-name { font-weight: 600; font-size: 1.1rem; margin-bottom: 0.5rem; }
.detail-item .item-meta { font-size: 0.85rem; color: var(--text-muted); line-height: 1.8; }

/* Badges */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
.badge-sealed { background: var(--success); color: #fff; }
.badge-opened { background: var(--warning); color: #000; }
.badge-built { background: var(--info); color: #fff; }
.badge-storage { background: #9E9E9E; color: #000; }
.badge-wishlist { background: #E91E63; color: #fff; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; text-align: center; }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Quick Actions */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.quick-action { background: var(--bg-card); border-radius: var(--radius); padding: 1.25rem; text-align: center; cursor: pointer; transition: all 0.2s; border: 1px solid transparent; display: block; color: var(--text); }
.quick-action:hover { border-color: var(--accent); transform: translateY(-2px); }
.quick-action .action-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.quick-action .action-label { font-size: 0.85rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.7rem 1rem; background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
    color: var(--text); font-size: 0.9rem; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233,69,96,0.2);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.7rem 1.25rem; border-radius: 8px; border: none;
    font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
    background: var(--accent); color: #fff; text-decoration: none;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); color: #fff; }
.btn-secondary { background: var(--accent-secondary); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* View Toggle */
.view-toggle { display: flex; background: rgba(0,0,0,0.3); border-radius: 8px; overflow: hidden; }
.view-toggle button { padding: 0.5rem 1rem; border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; transition: all 0.2s; }
.view-toggle button.active { background: var(--accent); color: #fff; }

/* Filter Bar */
.filter-bar { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filter-bar select { padding: 0.5rem 1rem; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; color: var(--text); font-size: 0.85rem; }

/* Flash Messages */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.85rem; animation: fadeIn 0.3s; }
.flash-success { background: rgba(76,175,80,0.15); border: 1px solid rgba(76,175,80,0.3); color: var(--success); }
.flash-error { background: rgba(233,69,96,0.15); border: 1px solid rgba(233,69,96,0.3); color: var(--danger); }
.flash-warning { background: rgba(255,152,0,0.15); border: 1px solid rgba(255,152,0,0.3); color: var(--warning); }
.flash-info { background: rgba(33,150,243,0.15); border: 1px solid rgba(33,150,243,0.3); color: var(--info); }

/* Auth Pages */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { background: var(--bg-card); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; margin: 0 0 0.5rem; color: var(--accent); }
.auth-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-card .auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-muted); }

/* Scanner */
.scanner-container { position: relative; max-width: 500px; margin: 0 auto; }
.scanner-container video { width: 100%; border-radius: var(--radius); background: #000; }
.scanner-container.scanning video { border: 3px solid var(--accent); }
.scanner-container.detected video { border: 3px solid var(--success); }
.scanner-actions { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }
#scan-results { margin-top: 1.5rem; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.photo-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; cursor: pointer; transition: transform 0.2s; }
.photo-grid img:hover { transform: scale(1.05); }

/* Set Detail */
.set-hero { display: flex; gap: 2rem; margin-bottom: 2rem; flex-wrap: wrap; }
.set-hero img { width: 300px; max-width: 100%; border-radius: var(--radius); background: #0a0a1a; }
.set-info { flex: 1; min-width: 250px; }
.set-info h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.set-meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.meta-item { background: rgba(0,0,0,0.2); padding: 0.75rem; border-radius: 8px; }
.meta-item .meta-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.meta-item .meta-value { font-size: 1rem; font-weight: 600; margin-top: 0.2rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.05); }
th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }

/* FAB */
.fab { position: fixed; bottom: 5rem; right: 1.5rem; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 1.5rem; cursor: pointer; box-shadow: 0 4px 12px rgba(233,69,96,0.4); transition: transform 0.2s; z-index: 50; display: none; }
.fab:hover { transform: scale(1.1); }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { margin: 0; font-size: 1.5rem; }

/* Placeholder image */
.img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #0a0a1a; color: var(--text-muted); font-size: 2rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-nav); border-radius: 4px; }

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 1rem; padding-bottom: 5rem; }
    .bottom-nav { display: block; }
    .fab { display: block; }
    .grid-view { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .grid-item img { height: 130px; }
    .detail-item { flex-direction: column; }
    .detail-item img { width: 100%; height: 200px; }
    .set-hero { flex-direction: column; }
    .set-hero img { width: 100%; }
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
}
