/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a1a;
    background: #f5f5f0;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #2d5016;
    color: #fff;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user {
    font-size: 0.9rem;
    opacity: 0.85;
}

.nav-link {
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.85;
}

.nav-link:hover { opacity: 1; }

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Flash messages */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.flash-error {
    background: #fde8e8;
    color: #991b1b;
    border: 1px solid #f5c6c6;
}

/* Login */
.login-wrap {
    max-width: 360px;
    margin: 3rem auto 0;
    text-align: center;
}

.login-wrap h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #2d5016;
}

.login-form {
    text-align: left;
}

.login-form label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #333;
}

.login-form input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: #2d5016;
    box-shadow: 0 0 0 2px rgba(45, 80, 22, 0.2);
}

.login-form button {
    width: 100%;
    padding: 0.7rem;
    background: #2d5016;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.login-form button:hover {
    background: #3a6b1e;
}

/* Nav links */
.nav-links {
    display: flex;
    gap: 1rem;
}

/* Shared components */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.page-header h1 { font-size: 1.4rem; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    line-height: 1.4;
}

.btn-primary {
    background: #2d5016;
    color: #fff;
}

.btn-primary:hover { background: #3a6b1e; }

.btn-secondary {
    background: #e5e5e0;
    color: #333;
}

.btn-secondary:hover { background: #d5d5d0; }

.btn-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    background: #e5e5e0;
    color: #333;
    border-radius: 4px;
    text-decoration: none;
}

.btn-tiny {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    background: #e5e5e0;
    color: #555;
    border-radius: 4px;
    text-decoration: none;
}

.empty-state {
    text-align: center;
    color: #888;
    padding: 2rem 0;
}

/* Card (generic clickable block) */
.card {
    display: block;
    background: #fff;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.12); }

/* Post card (list view) */
.post-thumbs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.post-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.thumb-more {
    font-size: 0.85rem;
    color: #888;
    font-weight: 600;
}

.post-text {
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.post-meta {
    display: flex;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: #888;
}

/* Post detail (view page) */
.post-detail { margin-bottom: 1rem; }

.post-detail-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.meta {
    font-size: 0.85rem;
    color: #888;
}

.post-detail-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.post-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.post-image-link img {
    max-width: 100%;
    border-radius: 6px;
}

/* Edit tag */
.edit-tag {
    background: none;
    border: none;
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

/* History panel */
.history-panel {
    background: #fafaf5;
    border: 1px solid #e0e0d8;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.history-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}

.history-item:last-child { border-bottom: none; }

.history-label {
    font-size: 0.75rem;
    color: #888;
    display: block;
    margin-bottom: 0.15rem;
}

/* Divider */
.divider {
    border: none;
    border-top: 1px solid #e0e0d8;
    margin: 1rem 0;
}

/* Comments */
.comment-heading {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.comment {
    background: #fff;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.comment-text {
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.comment-form {
    margin-top: 1rem;
}

.comment-form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.comment-form textarea:focus {
    outline: none;
    border-color: #2d5016;
    box-shadow: 0 0 0 2px rgba(45, 80, 22, 0.2);
}

/* Forms (shared) */
.idea-form label,
.std-form label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #333;
}

.idea-form textarea,
.idea-form input[type="file"],
.std-form textarea,
.std-form input[type="text"],
.std-form input[type="number"],
.std-form input[type="date"],
.std-form input[type="file"],
.std-form select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 1rem;
    background: #fff;
}

.idea-form textarea,
.std-form textarea {
    resize: vertical;
}

.idea-form textarea:focus,
.std-form textarea:focus,
.std-form input:focus,
.std-form select:focus {
    outline: none;
    border-color: #2d5016;
    box-shadow: 0 0 0 2px rgba(45, 80, 22, 0.2);
}

.idea-form input[type="file"],
.std-form input[type="file"] {
    padding: 0.5rem;
}

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

.form-col {
    flex: 1;
}

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

.flash-success {
    background: #e8f5e8;
    color: #1a5c1a;
    border: 1px solid #c6e6c6;
}

/* Header actions */
.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Danger button */
.btn-danger {
    background: #dc3545;
    color: #fff;
    border: none;
}

.btn-danger:hover { background: #c82333; }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    text-decoration: none;
    color: #555;
    background: #e5e5e0;
}

.filter-chip.active {
    background: #2d5016;
    color: #fff;
}

/* Stamp grid */
.stamp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.stamp-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stamp-card-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.stamp-card-placeholder {
    background: #e5e5e0;
}

.stamp-card-body {
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stamp-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.stamp-card-artist {
    font-size: 0.8rem;
    color: #666;
}

.stamp-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.2rem;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-active { background: #d4edda; color: #155724; }
.status-retired { background: #e2e3e5; color: #383d41; }
.status-damaged { background: #f8d7da; color: #721c24; }

/* Detail view */
.detail-fields {
    margin-bottom: 1rem;
}

.detail-row {
    padding: 0.4rem 0;
    border-bottom: 1px solid #eee;
}

.detail-label {
    font-size: 0.8rem;
    color: #888;
    display: block;
}

.detail-text {
    white-space: pre-wrap;
    margin-top: 0.15rem;
}

.section-heading {
    font-size: 1.1rem;
    margin: 0.75rem 0 0.5rem;
}

/* Image gallery */
.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.gallery-link img {
    max-width: 100%;
    border-radius: 6px;
    max-height: 300px;
}

/* Image removal grid (edit form) */
.image-remove-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.image-remove-item {
    position: relative;
    width: 100px;
}

.image-remove-item img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
}

.remove-check {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #991b1b;
    margin-top: 0.2rem;
    font-weight: normal;
}

/* Linked list */
.linked-item {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}

/* Checkbox group (multi-select stamps) */
.checkbox-group {
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0d8;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    font-weight: normal;
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-item input { margin: 0; }

/* Variant badge */
.variant-badge {
    font-size: 0.75rem;
    background: #d4edda;
    color: #155724;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-weight: 600;
}

/* ═══ Dynamic Attributes UI ═══ */
.attr-row {
    background: #fff;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.attr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.attr-name {
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}

.attr-name:hover {
    border-bottom-color: #999;
}

.attr-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.option-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: #eef5e8;
    border: 1px solid #c8ddb8;
    border-radius: 14px;
    padding: 0.2rem 0.15rem 0.2rem 0.55rem;
    font-size: 0.85rem;
}

.option-val {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}

.option-val:hover {
    border-bottom-color: #888;
}

.option-x {
    background: none;
    border: none;
    color: #999;
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.option-x:hover { color: #c00; }

.option-add-btn {
    background: #fff;
    border: 1px dashed #aaa;
    border-radius: 14px;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    cursor: pointer;
    color: #555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.option-add-btn:hover {
    background: #eef5e8;
    border-color: #2d5016;
    color: #2d5016;
}

/* Inline input for adding option */
.inline-input {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.inline-input input {
    width: 110px;
    padding: 0.2rem 0.4rem;
    border: 1px solid #aaa;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #999;
    padding: 0.15rem 0.3rem;
}

.btn-icon:hover { color: #c00; }

.btn-icon-ok:hover { color: #2d5016; }

/* Inline rename input */
.inline-rename {
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border: 1px solid #2d5016;
    border-radius: 4px;
    font-family: inherit;
    width: 150px;
}

.inline-rename-sm {
    font-size: 0.85rem;
    font-weight: 400;
    width: 100px;
}

/* Add attribute form */
.add-attr-form {
    background: #fff;
    border: 1px dashed #aaa;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

.add-attr-form input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 0.4rem;
}

.add-attr-form input:focus {
    outline: none;
    border-color: #2d5016;
}

.attr-add-btn {
    margin-top: 0.25rem;
}

/* ═══ Inventory ═══ */
.inv-sub-nav {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.inv-card-section {
    margin-bottom: 1.25rem;
}

.inv-card-name {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}

.inv-card-name a {
    color: #2d5016;
    text-decoration: none;
}

.inv-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.inv-table th, .inv-table td {
    padding: 0.35rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.inv-table th {
    background: #f5f5f0;
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
}

.inv-table td a {
    color: #2d5016;
    text-decoration: none;
}

.qty-zero {
    color: #c00;
    background: #fff0f0;
    font-weight: 600;
}

.qty-low {
    color: #856404;
    background: #fff8e1;
    font-weight: 600;
}

.qty-total {
    font-weight: 700;
}

.totals-row td {
    border-top: 2px solid #ccc;
    font-weight: 700;
    font-size: 0.85rem;
}

.loc-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* Locations management */
.loc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.loc-name {
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    flex: 1;
}

.loc-name:hover { border-bottom-color: #999; }

.loc-add-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.loc-add-row input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

/* Filter form (history) */
.filter-form {
    background: #fff;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.filter-form label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.15rem;
}

.filter-form select,
.filter-form input {
    width: 100%;
    padding: 0.3rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    margin-bottom: 0.4rem;
    background: #fff;
}

/* History events */
.history-events {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.event-row {
    background: #fff;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    border-left: 3px solid #ccc;
}

.event-transfer { border-left-color: #007bff; }
.event-sold { border-left-color: #28a745; }
.event-destroyed { border-left-color: #dc3545; }
.event-gifted { border-left-color: #ffc107; }
.event-other { border-left-color: #6c757d; }

.event-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.event-type-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    color: #fff;
}

.event-badge-transfer { background: #007bff; }
.event-badge-sold { background: #28a745; }
.event-badge-destroyed { background: #dc3545; }
.event-badge-gifted { background: #ffc107; color: #333; }
.event-badge-other { background: #6c757d; }

.event-body {
    font-size: 0.9rem;
}

.event-detail {
    font-size: 0.85rem;
    color: #555;
}

.event-notes {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
    margin-top: 0.15rem;
}

/* ═══ Dashboard ═══ */
.dash-quick-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.dash-section {
    margin-bottom: 1.5rem;
}

.dash-heading {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.dash-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d5016;
    margin-bottom: 0.5rem;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.dash-table th, .dash-table td {
    padding: 0.35rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.dash-table th {
    background: #f5f5f0;
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
}

.dash-table .num {
    text-align: right;
}

/* Low stock alerts */
.dash-alerts {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.alert-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.alert-zero {
    background: #fff0f0;
    border-left: 3px solid #c00;
}

.alert-low {
    background: #fff8e1;
    border-left: 3px solid #b8860b;
}

.alert-card {
    font-weight: 600;
    flex: 1;
}

.alert-loc {
    font-size: 0.8rem;
    color: #666;
}

.alert-qty {
    font-weight: 700;
    min-width: 1.5rem;
    text-align: right;
}
