/* ===== Theme-Variablen ===== */
:root {
    --bg-color: #f3f4f6;
    --text-color: #111827;
    --header-bg: #2563eb;
    --header-text: #ffffff;
    --button-bg: #2563eb;
    --button-hover-bg: #1d4ed8;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-color: #1f2937;
    --text-color: #f3f4f6;
    --header-bg: #111827;
    --header-text: #ffffff;
    --button-bg: #2563eb;
    --button-hover-bg: #1d4ed8;
    --card-bg: #374151;
    --border-color: #4b5563;
}

/* ===== Reset & Grundlayout ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* ===== Header ===== */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

header nav {
    display: flex;
    gap: 15px;
}

header nav a {
    color: var(--header-text);
    text-decoration: none;
    font-size: 1rem;
}

header nav button {
    background: none;
    border: none;
    color: var(--header-text);
    font-size: 1.2rem;
    cursor: pointer;
}

/* ===== Main Layout ===== */
main {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
}

.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.dashboard-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ===== Buttons ===== */
button {
    padding: 10px 20px;
    background-color: var(--button-bg);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: var(--button-hover-bg);
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ===== Inputs & Textareas ===== */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 10px;
    margin: 5px 0 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.dashboard-toolbar-controls input,
.dashboard-toolbar-controls select {
    width: auto;
    margin: 0;
}

.dashboard-toolbar-controls #box-search {
    width: 240px;
}

.dashboard-toolbar-controls #box-sort {
    width: 220px;
}

/* ===== Item/Box Cards ===== */
div.item-card,
div.box-card {
    padding: 15px;
    margin-bottom: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

/* ===== Images ===== */
img {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    margin-bottom: 10px;
}

.item-feedback {
    min-height: 1.5rem;
    margin-top: 10px;
    font-size: 0.95rem;
}

.box-feedback {
    min-height: 0;
    margin-top: 0;
    font-size: 0.95rem;
}

.item-feedback.is-success {
    color: #166534;
}

.item-feedback.is-error {
    color: #b91c1c;
}

.box-feedback.is-success {
    color: #166534;
}

.box-feedback.is-error {
    color: #b91c1c;
}

.status-card {
    padding: 12px 14px;
}

.status-card p + p {
    margin-top: 6px;
}

.status-card-error {
    background-color: #fee2e2;
    color: #b91c1c;
}

.box-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.box-list .box-card {
    margin-bottom: 0;
}

.dashboard-box {
    position: relative;
    padding: 18px 18px 12px;
}

.box-view h2 {
    margin-bottom: 8px;
    line-height: 1.3;
    padding-right: 48px;
}

.box-view p {
    margin-bottom: 0;
    min-height: 3.2rem;
}

.box-edit {
    padding-right: 48px;
}

.box-count {
    font-size: 0.95rem;
    font-weight: 400;
    color: #6b7280;
}

.box-edit[hidden],
.box-view[hidden],
.box-actions[hidden] {
    display: none;
}

.box-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.box-actions-primary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 16px;
}

.box-actions-edit {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
}

.box-actions-primary > *,
.box-actions-edit > * {
    width: 100%;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 20px;
    background-color: var(--button-bg);
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.button-link:hover {
    background-color: var(--button-hover-bg);
}

.button-secondary {
    background-color: #6b7280;
}

.button-secondary:hover {
    background-color: #4b5563;
}

.button-danger {
    background-color: #dc2626;
}

.button-danger:hover {
    background-color: #b91c1c;
}

.icon-button {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 1rem;
    line-height: 1;
}

.box-feedback:not(:empty) {
    min-height: 1.3rem;
    margin-top: 8px;
}

#box-filter-empty-state {
    margin-top: 12px;
}

.box-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.box-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.upload-card {
    display: grid;
    gap: 16px;
}

.upload-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.upload-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.upload-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.22);
    background: rgba(37, 99, 235, 0.1);
    font-size: 0.9rem;
}

.upload-card h2,
.items-panel h2 {
    margin-bottom: 8px;
}

.upload-help {
    margin-bottom: 0;
    color: #6b7280;
}

.upload-form {
    display: grid;
    gap: 14px;
}

.upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-dropzone {
    display: grid;
    gap: 6px;
    padding: 18px;
    border: 1.5px dashed var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.38);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.upload-dropzone:hover {
    border-color: var(--button-bg);
    background: rgba(37, 99, 235, 0.08);
}

.upload-dropzone strong {
    font-size: 1rem;
}

.upload-dropzone span {
    color: #6b7280;
}

.upload-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.upload-status {
    margin: 0;
    flex: 1 1 260px;
    font-size: 0.95rem;
    color: #6b7280;
}

.upload-status.is-error {
    color: #b91c1c;
}

.items-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.items-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
}

.items-toolbar-controls input,
.items-toolbar-controls select {
    width: auto;
    margin: 0;
}

.items-toolbar-controls #item-search {
    width: 240px;
}

.items-toolbar-controls #item-sort {
    width: 220px;
}

.items-toolbar-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.items-toolbar-main > [hidden] {
    display: none;
}

.items-toolbar-main [aria-pressed="true"] {
    background-color: #4b5563;
}

.grid-switch {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.grid-switch-label {
    font-size: 0.9rem;
    color: #6b7280;
}

.grid-toggle {
    min-width: 42px;
    padding: 10px 12px;
}

.grid-toggle[hidden] {
    display: none;
}

.grid-toggle.is-active {
    background-color: #111827;
}

.item-grid {
    display: grid;
    gap: 16px;
}

.item-grid.view-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.item-grid.view-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.item-grid.view-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.item-grid.view-1 {
    grid-template-columns: 1fr;
}

.item-grid-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
}

.item-grid-card[hidden] {
    display: none;
}

.item-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.item-select[hidden],
.item-view[hidden],
.item-edit[hidden],
.item-card-actions[hidden] {
    display: none;
}

.item-select input {
    width: auto;
    margin: 0;
}

.item-delete-button {
    top: 12px;
    right: 12px;
    z-index: 2;
}

.item-image-wrap img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    margin-bottom: 0;
}

.item-view,
.item-edit {
    display: grid;
    gap: 8px;
}

.item-card-title {
    line-height: 1.35;
}

.item-card-description {
    min-height: 3.2rem;
}

.item-card-description.is-empty {
    color: #6b7280;
}

.item-card textarea {
    min-height: 110px;
    resize: vertical;
}

.item-grid-card input[type="text"],
.item-grid-card textarea {
    margin-bottom: 0;
}

.item-card-actions {
    display: grid;
    gap: 10px;
}

.item-card-actions-view {
    grid-template-columns: 1fr;
}

.item-card-actions-edit {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.item-card-actions > * {
    width: 100%;
}

#item-filter-empty-state,
#item-empty-state {
    margin-top: 12px;
}

.public-hero {
    text-align: center;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    opacity: 0.75;
    margin-bottom: 8px;
}

.meta-line {
    margin-top: 12px;
    font-size: 0.95rem;
    opacity: 0.8;
}

.public-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.public-item-card {
    display: block;
    padding: 15px;
    color: inherit;
    text-decoration: none;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.public-item-card:hover {
    transform: translateY(-2px);
    border-color: var(--button-bg);
}

.public-item-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.public-item-body h2 {
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.public-item-detail {
    display: grid;
    gap: 20px;
}

.public-item-detail img {
    width: 100%;
    max-height: 520px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.04);
}

.public-item-copy h2 {
    margin-bottom: 12px;
}

/* ===== Modal ===== */
#confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

#confirm-modal > div {
    background: var(--card-bg);
    padding: 20px;
    margin: 100px auto;
    width: 90%;
    max-width: 400px;
    border-radius: 8px;
    color: var(--text-color);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}

.modal-actions > * {
    flex: 1 1 0;
    width: 50%;
}

[data-theme="dark"] .upload-dropzone {
    background: rgba(17, 24, 39, 0.28);
}

[data-theme="dark"] .upload-dropzone:hover {
    background: rgba(37, 99, 235, 0.14);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 0.9rem;
}

/* ===== Media Queries ===== */
@media (max-width: 600px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    main {
        padding: 15px;
    }

    .public-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-toolbar-controls {
        width: 100%;
        margin-left: 0;
    }

    .dashboard-toolbar-controls input,
    .dashboard-toolbar-controls select {
        width: 100%;
    }

    .upload-card-head {
        flex-direction: column;
    }

    .items-toolbar-controls {
        width: 100%;
        margin-left: 0;
    }

    .items-toolbar-controls input,
    .items-toolbar-controls select {
        width: 100%;
    }

    .upload-form-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .upload-form-actions button {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .box-list {
        grid-template-columns: 1fr;
    }

    .item-grid.view-4,
    .item-grid.view-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .box-actions-primary,
    .box-actions-edit {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .box-page-header {
        flex-direction: column;
    }

    .desktop-only {
        display: none;
    }

    .items-toolbar-main,
    .grid-switch {
        width: 100%;
    }

    .item-grid.view-4,
    .item-grid.view-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .item-grid.view-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .item-card-actions {
        grid-template-columns: 1fr;
    }
}
