/* ============================================================
   Thumbnail Generator — git.nrw
   Design-tool aesthetic: dark panel, clean canvas
   ============================================================ */

/* --- Variables & Reset --- */

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

:root {
    --bg:             #111113;
    --surface:        #1a1a1d;
    --surface-2:      #242428;
    --surface-3:      #2e2e33;
    --border:         #333338;
    --border-light:   #48484f;
    --text:           #ececef;
    --text-secondary: #a0a0a8;
    --text-dim:       #6e6e78;
    --accent:         #f6a800;
    --accent-hover:   #e09800;
    --accent-subtle:  rgba(246, 168, 0, 0.08);
    --danger:         #e5484d;
    --success:        #30a46c;
    --canvas-bg:      #d8d8dd;

    --font-ui:   'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;

    --radius:    8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --transition: 150ms ease;
}

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* --- Layout --- */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Toolbar --- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.toolbar-logo {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #003057, #1a5a96);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.toolbar-btn {
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    line-height: 1;
}

.toolbar-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-light);
}

.toolbar-btn.accent {
    background: var(--accent);
    color: #1a1a1d;
    border-color: var(--accent);
    font-weight: 600;
}

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

.toolbar-btn.success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.toolbar-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

.btn-group {
    display: flex;
}

.btn-group .toolbar-btn {
    border-radius: 0;
    margin-left: -1px;
}

.btn-group .toolbar-btn:first-child {
    border-radius: var(--radius-xs) 0 0 var(--radius-xs);
    margin-left: 0;
}

.btn-group .toolbar-btn:last-child {
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* --- Canvas Area --- */

.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--canvas-bg);
    position: relative;
    min-width: 0;
}

#svg-container {
    width: 640px;
    height: 360px;
    background: white;
    border-radius: 6px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.06),
        0 12px 32px rgba(0, 0, 0, 0.08),
        0 32px 64px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    cursor: crosshair;
}

#svg-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

.canvas-hints {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 11px;
    color: #6e6e78;
    font-weight: 450;
}

.canvas-hints .dot {
    width: 3px;
    height: 3px;
    background: #9e9ea6;
    border-radius: 50%;
    flex-shrink: 0;
}

.hint-btn {
    background: white;
    border: 1px solid #c0c0c8;
    border-radius: var(--radius-xs);
    padding: 3px 10px;
    font-size: 11px;
    font-family: var(--font-ui);
    font-weight: 500;
    color: #52525b;
    cursor: pointer;
    transition: all var(--transition);
}

.hint-btn:hover {
    background: #f0f0f3;
    border-color: #a0a0a8;
    color: #27272a;
}

/* --- Panel (Right Sidebar) --- */

.panel {
    width: 320px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}

.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.panel::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* --- Panel Sections --- */

.panel-section {
    border-bottom: 1px solid var(--border);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.section-header h2 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chevron {
    width: 15px;
    height: 15px;
    color: var(--text-dim);
    transition: transform 200ms ease;
    flex-shrink: 0;
}

.panel-section:not(.open) .chevron {
    transform: rotate(-90deg);
}

.section-body {
    padding: 0 14px 14px;
}

.panel-section:not(.open) .section-body {
    display: none;
}

/* Keep backward compat with existing JS that toggles these on #colorControls */
#colorControls.collapsed {
    max-height: 0 !important;
    overflow: hidden;
    opacity: 0;
}

#colorSchemeChevron.rotated {
    transform: rotate(-90deg);
}

/* --- Panel Controls --- */

.panel-input {
    width: 100%;
    height: 32px;
    padding: 0 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.panel-input:focus { border-color: var(--accent); }
.panel-input::placeholder { color: var(--text-dim); }

.panel-select {
    width: 100%;
    height: 32px;
    padding: 0 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    outline: none;
    cursor: pointer;
    margin-bottom: 10px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236e6e78' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.panel-select option {
    background: var(--surface);
    color: var(--text);
}

.panel-select:focus { border-color: var(--accent); }

.num-input {
    width: 52px;
    height: 26px;
    padding: 0 5px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 11px;
    text-align: right;
    outline: none;
    flex-shrink: 0;
    -moz-appearance: textfield;
}

.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.num-input:focus { border-color: var(--accent); }

/* Range inputs */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    flex: 1;
    min-width: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--text);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 0 0 2px var(--surface);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent);
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--text);
    border-radius: 50%;
    border: 2px solid var(--surface);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--accent);
}

/* Control row */
.control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.control label {
    font-size: 11px;
    color: var(--text-dim);
    width: 48px;
    flex-shrink: 0;
    font-weight: 500;
}

.controls-group {
    margin-top: 10px;
}

/* Color inputs */
input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 26px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 2px;
    background: transparent;
    cursor: pointer;
    transition: border-color var(--transition);
}

input[type="color"]:hover { border-color: var(--border-light); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }

/* Toggle row */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 0 10px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-row input[type="checkbox"],
.lock-toggle input[type="checkbox"] {
    accent-color: var(--accent);
}

.lock-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 500;
}

/* --- Text Line Cards --- */

.text-line-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 8px;
    transition: border-color var(--transition);
}

.text-line-card:hover { border-color: var(--border-light); }

.text-line-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.text-line-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.text-line-remove {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 15px;
    cursor: pointer;
    border-radius: 3px;
    transition: all var(--transition);
    line-height: 1;
}

.text-line-remove:hover {
    background: rgba(229, 72, 77, 0.15);
    color: var(--danger);
}

.add-line-btn {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 4px;
}

.add-line-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* --- Icon Picker --- */

.icon-tray {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    min-height: 34px;
    padding: 5px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    margin-bottom: 10px;
    align-items: center;
}

.icon-tray-empty {
    font-size: 11px;
    color: var(--text-dim);
    padding: 2px 4px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

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

.icon-btn:hover svg { stroke: var(--bg) !important; }
.icon-btn:hover i { color: var(--bg) !important; }

.icon-btn.selected {
    background: var(--accent);
    border-color: var(--accent);
}

.icon-btn.selected svg { stroke: var(--bg) !important; }
.icon-btn.selected i { color: var(--bg) !important; }

.icon-picker {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 10px;
}

.picker-tabs {
    display: flex;
    margin-bottom: 8px;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.tab-button {
    flex: 1;
    padding: 7px 8px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    text-align: center;
}

.tab-button:hover { color: var(--text-secondary); }

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.icon-grid::-webkit-scrollbar { width: 4px; }
.icon-grid::-webkit-scrollbar-track { background: transparent; }
.icon-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.icon-grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
    padding: 14px 0;
}

.upload-btn {
    width: 100%;
    padding: 7px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 10px;
}

.upload-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.subsection { margin-bottom: 10px; }

.subsection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.subsection-header span {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.text-btn {
    border: none;
    background: transparent;
    font-family: var(--font-ui);
    font-size: 10px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
    transition: all var(--transition);
}

.text-btn.danger { color: var(--text-dim); }
.text-btn.danger:hover { color: var(--danger); background: rgba(229, 72, 77, 0.1); }

/* --- Colors Section --- */

.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.color-row > label {
    font-size: 11px;
    color: var(--text-dim);
    width: 48px;
    flex-shrink: 0;
    font-weight: 500;
}

.color-swatches {
    display: flex;
    gap: 8px;
}

.swatch-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.swatch-group span {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --- Drag & Drop --- */

.canvas-area.drag-over::after {
    content: 'PNG ablegen um Settings zu laden';
    position: absolute;
    inset: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(246, 168, 0, 0.06);
    border: 2px dashed var(--accent);
    border-radius: 10px;
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    pointer-events: none;
    z-index: 10;
    animation: fadeIn 100ms ease;
}

/* --- Interactive elements (on SVG canvas) --- */

.interactive-element {
    transition: filter 150ms ease;
}

.interactive-element:hover {
    filter: drop-shadow(0 0 6px rgba(246, 168, 0, 0.35));
}

.interactive-element.selected {
    filter: drop-shadow(0 0 8px rgba(246, 168, 0, 0.6));
}

/* --- Modal --- */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal:not(.hidden) {
    animation: fadeIn 150ms ease;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-header h3 {
    font-size: 13px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-preview {
    width: 1280px;
    height: 720px;
    overflow: hidden;
    border-radius: var(--radius-xs);
    background: var(--bg);
}

.modal-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 10px;
}

/* --- Animations --- */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Disabled state --- */

input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
