/* ==========================================================================
   Kartenwerkstatt - Base Theme (modern, Inter, Purple)
   ========================================================================== */

:root {
    /* Colors — Rich Purple Palette */
    --color-primary: #7c3aed;
    --color-primary-hover: #6d28d9;
    --color-primary-dark: #5b21b6;
    --color-primary-medium: #a78bfa;
    --color-primary-light: #ede9fe;
    --color-primary-bg: rgba(124,58,237,0.08);
    --color-accent: #f59e0b;
    --color-bg: #faf8ff;
    --color-surface: #ffffff;
    --color-surface-glass: rgba(255,255,255,0.7);
    --color-text: #1e1b4b;
    --color-text-light: #6b7280;
    --color-text-secondary: #6b7280;
    --color-border: rgba(124,58,237,0.12);
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;

    /* Glassmorphism */
    --glass-blur: blur(12px);
    --glass-bg: var(--color-surface-glass);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Layered Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(124,58,237,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.04), 0 2px 12px rgba(124,58,237,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.06), 0 4px 16px rgba(124,58,237,0.1);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.08), 0 8px 24px rgba(124,58,237,0.12);
    --shadow-card: 0 4px 20px rgba(124,58,237,0.15);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4,0,0.2,1);
    --transition-normal: 250ms cubic-bezier(0.4,0,0.2,1);

    /* Spacing */
    --topbar-height: 52px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body.ww2-page {
    overflow: auto;
    height: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    border: none;
    outline: none;
    background: none;
    color: inherit;
}

select, input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
}

/* ==========================================================================
   Top Bar
   ========================================================================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 12px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: relative;
    z-index: 100;
}

.topbar__name {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    min-width: 0;
    outline: none;
    transition: background 0.15s;
}

.topbar__name:focus {
    background: var(--color-primary-light);
}

.topbar__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex: 1;
}

.topbar__btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--color-text-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.topbar__btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* Vorlage button (pill in header center) */
.topbar__template-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.topbar__template-chevron {
    transition: transform 0.2s;
    opacity: 0.5;
}

.topbar__template-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.topbar__template-btn--active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.topbar__template-btn--active .topbar__template-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.topbar__autosave {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--color-text-muted, #94a3b8);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.topbar__autosave--visible {
    opacity: 1;
}

.topbar__lang {
    height: 36px;
    padding: 0 8px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    text-align: center;
    min-width: 48px;
}

.topbar__lang:focus {
    border-color: var(--color-primary);
}

/* ==========================================================================
   Template Bar (horizontal, under header)
   ========================================================================== */

.template-bar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    z-index: 90;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    animation: templateBarSlideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes templateBarSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.template-bar__section {
    padding: 0;
}

.template-bar__section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 16px 0;
}

.template-bar__divider {
    height: 1px;
    background: var(--color-border);
    margin: 0 16px;
}

.template-bar__scroll {
    display: flex;
    gap: 12px;
    padding: 6px 16px 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.template-bar__scroll::-webkit-scrollbar {
    height: 4px;
}

.template-bar__scroll::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

.template-card {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
}

.template-card:hover {
    background: var(--color-bg);
}

.template-card--active .template-card__preview {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

.template-card--active .template-card__label {
    color: var(--color-primary);
}

.template-card__preview {
    width: 72px;
    height: 100px;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    background: #ffffff;
    position: relative;
    overflow: hidden;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.template-card:hover .template-card__preview {
    border-color: var(--color-primary);
}

.template-card__preview--square {
    width: 80px;
    height: 80px;
}

.template-card__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text);
    text-align: center;
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* User template preview with thumbnail */
.template-card__preview--user {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.template-card__thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.template-card__session-icon {
    opacity: 0.35;
}

/* Delete X on user templates */
.template-card__delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-danger);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 2;
    padding: 0;
}

.template-card:hover .template-card__delete {
    opacity: 1;
}

.template-card__delete:hover {
    background: var(--color-danger-hover);
}

/* Template card needs relative positioning for delete button */
.template-card {
    position: relative;
}

/* [+ Speichern] button at end of user row */
.template-bar__save-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 72px;
    min-height: 100px;
    border: 2px dashed var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--color-text-light);
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
    padding: 6px;
}

.template-bar__save-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

/* ==========================================================================
   Workspace
   ========================================================================== */

.workspace {
    height: calc(100% - var(--topbar-height));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px;
    position: relative;
}

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

.workspace__card-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.workspace__card-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}

#card-toolbar {
    justify-self: end;
}

#object-toolbar {
    justify-self: start;
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

/* ==========================================================================
   Utility
   ========================================================================== */

[hidden] {
    display: none !important;
}
