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

:root {
    --bg: #111;
    --bg-surface: #1a1a1a;
    --bg-hover: #222;
    --text: #e5e5e5;
    --text-muted: #888;
    --accent: #e8a03e;
    --accent-hover: #d4912e;
    --border: #2a2a2a;
    --radius: 6px;
    --max-width: 1100px;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

a:hover {
    color: var(--accent-hover);
}

/* Nav */
.nav {
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.nav-logo:hover {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.nav-links a:hover {
    color: var(--text);
}

/* Main */
.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Hero */
.hero {
    padding: 4rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.15rem;
    max-width: 500px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #111;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #111;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Forms */
input, select, textarea {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

/* Auth pages */
.auth-page {
    max-width: 380px;
    margin: 3rem auto;
}

.auth-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.btn-full {
    width: 100%;
    text-align: center;
}

.auth-switch {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(220, 60, 60, 0.15);
    color: #f08080;
    border: 1px solid rgba(220, 60, 60, 0.3);
}

/* Nav extras */
.nav-logout {
    display: inline;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.btn-link:hover {
    color: var(--text);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

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

.dashboard-empty {
    color: var(--text-muted);
    padding: 3rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* Collection grid */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.collection-card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    color: var(--text);
    transition: border-color 0.15s;
}

.collection-card:hover {
    border-color: var(--accent);
    color: var(--text);
}

.collection-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.collection-card p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.collection-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Collection page */
.collection-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.collection-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.collection-actions {
    display: flex;
    gap: 0.5rem;
}

/* Form pages */
.form-page {
    max-width: 500px;
}

.form-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* Danger zone */
.danger-zone {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.danger-zone h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.btn-danger {
    background: rgba(220, 60, 60, 0.15);
    color: #f08080;
    border: 1px solid rgba(220, 60, 60, 0.3);
}

.btn-danger:hover {
    background: rgba(220, 60, 60, 0.25);
}

/* Item grid */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.item-card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--text);
    transition: border-color 0.15s;
}

.item-card:hover {
    border-color: var(--accent);
    color: var(--text);
}

.item-card-img {
    display: block;
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: var(--radius) var(--radius) 0 0;
}

.item-card-img + .item-card-body {
    padding-top: 0.75rem;
}

.item-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.item-type-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    background: var(--bg-hover);
    border-radius: 3px;
    color: var(--text-muted);
    margin-right: 0.4rem;
}

.item-status {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 3px;
}

.status-owned { background: rgba(76, 175, 80, 0.15); color: #81c784; }
.status-for_sale { background: rgba(232, 160, 62, 0.15); color: var(--accent); }
.status-sold { background: rgba(120, 120, 120, 0.15); color: var(--text-muted); }
.status-wishlist { background: rgba(100, 149, 237, 0.15); color: #90b4f0; }

/* Item detail page */
.item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.item-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.item-description {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.item-metadata {
    margin-bottom: 2rem;
}

.item-metadata h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.meta-item dt {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meta-item dd {
    font-size: 0.95rem;
}

.item-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-item {
    display: flex;
    gap: 1rem;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 120px;
}

.detail-value {
    font-size: 0.9rem;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Field row (side by side) */
.field-row {
    display: flex;
    gap: 1rem;
}

.field-row .field {
    flex: 1;
}

/* Filter bar */
.filter-bar {
    margin-bottom: 1.5rem;
}

.filter-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-form select {
    width: auto;
    min-width: 140px;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
}

/* Search page */
.search-page h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.search-bar {
    margin-bottom: 1.5rem;
}

.search-bar input {
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

.result-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.search-hint {
    padding: 2rem;
    text-align: center;
}

/* Image gallery */
.image-gallery {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.image-item {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: 160px;
}

.image-item.is-primary {
    border-color: var(--accent);
}

.image-item img {
    display: block;
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.image-actions {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
    background: var(--bg-surface);
    font-size: 0.75rem;
}

.image-primary-label {
    color: var(--accent);
    font-size: 0.75rem;
}

.btn-link-danger {
    color: #f08080;
}

.btn-link-danger:hover {
    color: #e55;
}

.image-upload-section {
    margin-bottom: 1.5rem;
}

/* HTMX indicator */
.htmx-indicator {
    display: none;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.htmx-request .htmx-indicator {
    display: inline;
}

/* AI Catalog */
.ai-catalog-section {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.ai-label {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.ai-catalog-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-accent {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #111;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.ai-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.ai-loading {
    color: var(--accent);
}

.ai-success {
    color: #5cb85c;
}

.ai-error {
    color: #d9534f;
}

.ai-cleared {
    color: var(--text-muted);
}

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

.ai-preview {
    margin-top: 0.75rem;
}

.ai-preview img {
    max-width: 200px;
    max-height: 160px;
    border-radius: var(--radius);
    object-fit: cover;
}

/* Admin settings */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.field-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(92, 184, 92, 0.15);
    border: 1px solid rgba(92, 184, 92, 0.3);
    color: #5cb85c;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* Admin table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.admin-table th,
.admin-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.admin-table td a {
    color: var(--accent);
}
.admin-table-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
}
