/* ======================================
   Böhnlein Etiketten-Tool – Styles
   ====================================== */

/* Michroma Font (lokal gehostet) */
@font-face {
    font-family: 'Michroma';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/michroma-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Michroma';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/michroma-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --color-primary: #1a1a2e;
    --color-accent: #c9a84c;
    --color-accent-hover: #b8953e;
    --color-bg: #f5f3ef;
    --color-white: #ffffff;
    --color-text: #333333;
    --color-text-light: #777777;
    --color-border: #ddd;
    --color-error: #c0392b;
    --color-success: #27ae60;
    --radius: 6px;
}

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

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

/* ======================================
   Login
   ====================================== */

.login {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login__card {
    background: var(--color-white);
    padding: 3rem 2.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    text-align: center;
    width: 100%;
    max-width: 380px;
}

.login__title {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.login__subtitle {
    color: var(--color-text-light);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.login__error {
    background: #fdecea;
    color: var(--color-error);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

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

.login__label {
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login__input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.login__input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.login__button {
    padding: 0.75rem;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login__button:hover {
    background: #2a2a4e;
}

/* ======================================
   Topbar
   ====================================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: var(--color-white);
}

.topbar__title {
    font-size: 1.1rem;
    font-weight: 600;
}

.topbar__nav {
    display: flex;
    gap: 1rem;
}

.topbar__link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.topbar__link:hover {
    color: var(--color-white);
}

.topbar__link--logout {
    color: #aaa;
}

/* ======================================
   Admin
   ====================================== */

.admin__main {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.admin__message--success {
    background: #e8f8ef;
    color: var(--color-success);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.admin__form {
    background: var(--color-white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.admin__fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.admin__legend {
    font-weight: 600;
    color: var(--color-primary);
    padding: 0 0.5rem;
}

.admin__row {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.admin__field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.admin__field label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-light);
}

.admin__field input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.admin__field input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.admin__field small {
    color: var(--color-text-light);
    font-size: 0.8rem;
}

.admin__button {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.admin__preview {
    margin-top: 2rem;
}

.admin__preview h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--color-primary);
}

.admin__preview-label {
    border: 1px dashed var(--color-text-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2mm;
    background: var(--color-white);
}

.admin__preview-label .label__text {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 2.2mm;
    line-height: 1.3;
    margin-bottom: 1mm;
}

.admin__preview-label .label__price {
    font-size: 4mm;
    font-weight: 700;
}

/* ======================================
   App – Layout
   ====================================== */

.app__main {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    min-height: calc(100vh - 52px);
}

.app__sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.app__preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app__preview-title {
    font-size: 1rem;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

/* ======================================
   Label Form
   ====================================== */

.label-form {
    background: var(--color-white);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.label-form__fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.label-form__legend {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-primary);
    padding: 0 0.25rem;
}

.label-form__radios {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.label-form__radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.label-form__fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.label-form__fields[hidden] {
    display: none;
}

.label-form__field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.label-form__field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-light);
}

.label-form__field input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.label-form__field input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.label-form__button {
    display: block;
    width: 100%;
    padding: 0.6rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.label-form__button--add {
    background: var(--color-accent);
    color: var(--color-white);
}

.label-form__button--add:hover {
    background: var(--color-accent-hover);
}

.label-form__actions {
    display: flex;
    gap: 0.75rem;
}

.label-form__button--print {
    background: var(--color-primary);
    color: var(--color-white);
    flex: 1;
}

.label-form__button--print:hover {
    background: #2a2a4e;
}

.label-form__button--clear {
    background: var(--color-white);
    color: var(--color-error);
    border: 1px solid var(--color-error);
    flex: 1;
}

.label-form__button--clear:hover {
    background: #fdecea;
}

.label-form__button--grid {
    flex: 1;
    border: 1px solid var(--color-border);
}

.label-form__button--grid-on {
    background: var(--color-white);
    color: var(--color-text-light);
}

.label-form__button--grid-on:hover {
    background: var(--color-bg);
}

.label-form__button--grid-off {
    background: var(--color-white);
    color: var(--color-accent-hover);
    border-color: var(--color-accent);
}

.label-form__button--grid-off:hover {
    background: #faf3e0;
}

/* ======================================
   Label List
   ====================================== */

.label-list {
    background: var(--color-white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.label-list__title {
    font-size: 0.9rem;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.label-list__items {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.label-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.label-list__item-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.label-list__item-type {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-accent);
    text-transform: uppercase;
}

.label-list__item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.label-list__item-edit,
.label-list__item-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.35rem;
    line-height: 1;
    border-radius: 4px;
    transition: background 0.15s;
}

.label-list__item-edit {
    color: var(--color-accent);
}

.label-list__item-edit:hover {
    background: #faf3e0;
}

.label-list__item-delete {
    color: var(--color-error);
}

.label-list__item-delete:hover {
    background: #fdecea;
}

.label-list__item--editing {
    border: 1px solid var(--color-accent);
    background: #faf3e0;
}

.label-list__item-detail {
    font-size: 0.8rem;
    color: var(--color-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.label-list__empty {
    font-size: 0.85rem;
    color: var(--color-text-light);
    padding: 0.5rem 0;
}

/* Edit mode indicator */
.label-form__edit-indicator {
    background: #faf3e0;
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    color: #7a5c00;
    margin-bottom: 0.5rem;
}

.label-form__cancel-edit {
    background: none;
    border: none;
    color: var(--color-accent-hover);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0;
    text-decoration: underline;
}

/* ======================================
   Save Panel
   ====================================== */

.save-panel {
    background: var(--color-white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.save-panel__title {
    font-size: 0.9rem;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.save-panel__row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.save-panel__input {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.save-panel__input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.save-panel__button {
    padding: 0.45rem 0.9rem;
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.save-panel__button:hover {
    background: var(--color-accent-hover);
}

/* Saved pages list */
.saved-pages__title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.saved-pages__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
}

.saved-pages__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    gap: 0.5rem;
}

.saved-pages__item-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    overflow: hidden;
}

.saved-pages__item-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-pages__item-meta {
    font-size: 0.75rem;
    color: var(--color-text-light);
}

.saved-pages__item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.saved-pages__btn {
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    transition: background 0.15s;
}

.saved-pages__btn--load {
    background: var(--color-primary);
    color: var(--color-white);
    font-size: 0.9rem;
}

.saved-pages__btn--load:hover {
    background: #2a2a4e;
}

.saved-pages__btn--copy {
    background: rgba(201, 168, 76, 0.15);
    color: var(--color-accent-hover);
    font-size: 0.9rem;
}

.saved-pages__btn--copy:hover {
    background: rgba(201, 168, 76, 0.35);
}

.saved-pages__btn--delete {
    background: none;
    color: var(--color-error);
    font-size: 1rem;
    padding: 0.25rem 0.35rem;
}

.saved-pages__btn--delete:hover {
    background: #fdecea;
}

.saved-pages__empty {
    font-size: 0.82rem;
    color: var(--color-text-light);
    padding: 0.25rem 0;
}

/* ======================================
   Print Sheet (A4 Preview)
   ====================================== */

.print-sheet {
    width: 210mm;
    min-height: 297mm;
    background: var(--color-white);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}

/* ======================================
   Label (on sheet)
   ====================================== */

.label {
    border: 0.3mm dashed #ccc;
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: 1.5mm;
    cursor: default;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.print-sheet--no-style .label {
    border-radius: 0;
    box-shadow: none;
}

.print-sheet--no-grid .label {
    border-color: transparent;
}

.print-sheet--no-grid .label:hover {
    border-color: var(--color-accent);
}

.label:hover {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px var(--color-accent);
    z-index: 10;
}

.label--editing {
    border-color: var(--color-accent) !important;
    box-shadow: 0 0 0 1.5px var(--color-accent) !important;
    background: #faf3e0;
}

.label--dragging {
    opacity: 0.4;
}

.label--dragover {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 1.5px var(--color-primary) !important;
    background: #eef0ff;
}

/* Label content wrapper */
.label__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Controls overlay */
.label__controls {
    position: absolute;
    top: 0.5mm;
    right: 0.5mm;
    display: flex;
    gap: 0.3mm;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 20;
}

.label:hover .label__controls {
    opacity: 1;
}

.label__ctrl {
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 2.8mm;
    width: 4.5mm;
    height: 4.5mm;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.1s;
}

.label__ctrl--drag {
    background: rgba(100, 100, 100, 0.15);
    color: #555;
    cursor: grab;
}

.label__ctrl--drag:hover {
    background: rgba(100, 100, 100, 0.3);
}

.label__ctrl--edit {
    background: rgba(201, 168, 76, 0.2);
    color: var(--color-accent-hover);
}

.label__ctrl--edit:hover {
    background: rgba(201, 168, 76, 0.5);
}

.label__ctrl--delete {
    background: rgba(192, 57, 43, 0.15);
    color: var(--color-error);
}

.label__ctrl--delete:hover {
    background: rgba(192, 57, 43, 0.35);
}

.label__text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
    text-align: center;
    width: 100%;
}

.label__text span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.label__price {
    font-weight: 700;
    text-align: center;
}

.label__price--old {
    text-decoration: line-through;
    color: #999;
    font-weight: 400;
}

.label__price--new {
    font-weight: 700;
    color: var(--color-error);
}

/* ======================================
   Print Styles
   ====================================== */

@media print {
    body {
        background: white;
    }

    .topbar,
    .app__sidebar,
    .app__preview-title {
        display: none !important;
    }

    .app__main {
        padding: 0;
        display: block;
    }

    .app__preview {
        display: block;
    }

    .print-sheet {
        box-shadow: none;
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 0;
        page-break-after: always;
    }

    .label {
        border-color: #ccc;
        border-radius: 5px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
        cursor: default !important;
    }

    .print-sheet--no-style .label {
        border-radius: 0;
        box-shadow: none;
    }

    .label__controls {
        display: none !important;
    }

    .label--editing {
        background: white !important;
        box-shadow: none !important;
        border-color: #ccc !important;
    }

    @page {
        size: A4;
        margin: 0;
    }
}
