/* HatıraKutu Editör */

/* ─── Tema değişkenleri ───────────────────────────────────── */
:root,
[data-theme="dark"] {
    --ed-bg: #0c1222;
    --ed-panel: #151d2e;
    --ed-panel-border: rgba(148, 163, 184, 0.14);
    --ed-text: #f1f5f9;
    --ed-muted: #94a3b8;
    --ed-primary: #14b8a6;
    --ed-primary-dark: #0d9488;
    --ed-danger: #ef4444;
    --ed-hover: rgba(255, 255, 255, 0.05);
    --ed-active: rgba(20, 184, 166, 0.14);
    --ed-canvas-bg: #080d18;
    --ed-canvas-pattern: rgba(148, 163, 184, 0.06);
    --ed-page-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
    --ed-overlay: rgba(0, 0, 0, 0.72);
    --ed-color-ring: #fff;
    --ed-warn: #fbbf24;
    --ed-kbd-bg: rgba(255, 255, 255, 0.08);
    --ed-kbd-border: rgba(148, 163, 184, 0.2);
}

[data-theme="light"] {
    --ed-bg: #eef2f7;
    --ed-panel: #ffffff;
    --ed-panel-border: rgba(15, 23, 42, 0.1);
    --ed-text: #0f172a;
    --ed-muted: #64748b;
    --ed-primary: #0d9488;
    --ed-primary-dark: #0f766e;
    --ed-danger: #dc2626;
    --ed-hover: rgba(15, 23, 42, 0.04);
    --ed-active: rgba(13, 148, 136, 0.12);
    --ed-canvas-bg: #dde3ec;
    --ed-canvas-pattern: rgba(15, 23, 42, 0.05);
    --ed-page-shadow: 0 8px 32px rgba(15, 23, 42, 0.14);
    --ed-overlay: rgba(15, 23, 42, 0.45);
    --ed-color-ring: #0f172a;
    --ed-warn: #b45309;
    --ed-kbd-bg: #fff;
    --ed-kbd-border: rgba(15, 23, 42, 0.12);
}

:root {
    --ed-header-h: 56px;
    --ed-panel-w: 272px;
    --ed-font: 'DM Sans', system-ui, sans-serif;
    --ed-display: 'Playfair Display', Georgia, serif;
}

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

body.editor-app {
    font-family: var(--ed-font);
    background: var(--ed-bg);
    color: var(--ed-text);
    height: 100vh;
    overflow: hidden;
}

/* ─── Header ──────────────────────────────────────────────── */
.editor-header {
    height: var(--ed-header-h);
    background: var(--ed-panel);
    border-bottom: 1px solid var(--ed-panel-border);
    display: flex;
    align-items: center;
    padding: 0 0.875rem;
    gap: 0.75rem;
    z-index: 100;
}
.editor-header__left,
.editor-header__right {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}
.editor-header__center { flex: 1; min-width: 0; }
.editor-header__right { margin-left: auto; }
.editor-header__group { display: flex; align-items: center; gap: 0.25rem; }
.editor-header__divider {
    width: 1px;
    height: 24px;
    background: var(--ed-panel-border);
    margin: 0 0.25rem;
}

.editor-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ed-text);
    text-decoration: none;
    font-weight: 700;
}
.editor-logo__icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #14b8a6, #6366f1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ed-display);
    color: #fff;
}
.editor-badge {
    font-size: 0.68rem;
    color: var(--ed-muted);
    background: var(--ed-active);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.editor-title-input {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    display: block;
    background: var(--ed-bg);
    border: 1px solid var(--ed-panel-border);
    color: var(--ed-text);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: var(--ed-font);
    text-align: center;
}
.editor-title-input:focus { outline: none; border-color: var(--ed-primary); box-shadow: 0 0 0 3px var(--ed-active); }

/* ─── Buttons ─────────────────────────────────────────────── */
.editor-btn {
    font-family: var(--ed-font);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--ed-panel-border);
    background: var(--ed-bg);
    color: var(--ed-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.editor-btn .icon { flex-shrink: 0; }
.editor-btn:hover:not(:disabled) { border-color: var(--ed-primary); color: var(--ed-primary); background: var(--ed-hover); }
.editor-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.editor-btn--primary { background: var(--ed-primary); border-color: var(--ed-primary); color: #fff; }
.editor-btn--primary:hover:not(:disabled) { background: var(--ed-primary-dark); border-color: var(--ed-primary-dark); color: #fff; }
.editor-btn--ghost { background: transparent; border-color: transparent; }
.editor-btn--ghost:hover:not(:disabled) { background: var(--ed-hover); }
.editor-btn--icon { padding: 0.5rem; min-width: 36px; justify-content: center; }
.editor-btn--sm { padding: 0.375rem 0.625rem; font-size: 0.75rem; }
.editor-btn--block { width: 100%; margin-top: 0.5rem; }
.editor-btn--danger:hover:not(:disabled) { border-color: var(--ed-danger); color: var(--ed-danger); }

/* ─── Layout ──────────────────────────────────────────────── */
.editor-body {
    display: flex;
    height: calc(100vh - var(--ed-header-h));
}

.editor-panel {
    width: var(--ed-panel-w);
    background: var(--ed-panel);
    border-right: 1px solid var(--ed-panel-border);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: width 0.22s ease, opacity 0.22s ease;
}
.editor-panel--right {
    border-right: none;
    border-left: 1px solid var(--ed-panel-border);
}
.editor-panel__scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.editor-panel.is-collapsed {
    width: 0;
    border: none;
    opacity: 0;
    pointer-events: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--ed-panel-border);
    flex-shrink: 0;
    background: var(--ed-panel);
    position: sticky;
    top: 0;
    z-index: 2;
}
.panel-header h2 { font-size: 0.85rem; font-weight: 600; }
.panel-section { padding: 0.875rem 1rem; border-bottom: 1px solid var(--ed-panel-border); }
.panel-section h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ed-muted);
    margin-bottom: 0.625rem;
    font-weight: 600;
}
.panel-hint { font-size: 0.75rem; color: var(--ed-muted); margin-bottom: 0.75rem; line-height: 1.45; }

.editor-label {
    display: block;
    font-size: 0.75rem;
    color: var(--ed-muted);
    margin-bottom: 0.375rem;
}
.editor-label--range {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.editor-label--range output {
    font-variant-numeric: tabular-nums;
    color: var(--ed-primary);
    font-weight: 600;
    font-size: 0.72rem;
}
.editor-select,
.editor-textarea {
    width: 100%;
    background: var(--ed-bg);
    border: 1px solid var(--ed-panel-border);
    color: var(--ed-text);
    padding: 0.5rem 0.625rem;
    border-radius: 8px;
    font-family: var(--ed-font);
    font-size: 0.85rem;
}
.editor-textarea { resize: vertical; min-height: 72px; }
.editor-select:focus,
.editor-textarea:focus {
    outline: none;
    border-color: var(--ed-primary);
    box-shadow: 0 0 0 3px var(--ed-active);
}
.editor-range { width: 100%; accent-color: var(--ed-primary); margin-bottom: 0.625rem; }

/* ─── Sayfa listesi ───────────────────────────────────────── */
.page-list { list-style: none; padding: 0.5rem; }
.page-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    border: 1px solid transparent;
}
.page-item:hover { background: var(--ed-hover); }
.page-item.active { background: var(--ed-active); border-color: var(--ed-primary); }
.page-item__thumb {
    width: 36px;
    height: 48px;
    border-radius: 4px;
    background: var(--page-color, #6366f1);
    flex-shrink: 0;
    border: 1px solid var(--ed-panel-border);
}
.page-item__actions { margin-left: auto; display: flex; gap: 0.125rem; }
.page-item__btn {
    background: none;
    border: none;
    color: var(--ed-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
}
.page-item__btn:hover { color: var(--ed-danger); background: var(--ed-hover); }

/* ─── Tuval ───────────────────────────────────────────────── */
.editor-canvas-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--ed-canvas-bg);
    background-image:
        linear-gradient(45deg, var(--ed-canvas-pattern) 25%, transparent 25%),
        linear-gradient(-45deg, var(--ed-canvas-pattern) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--ed-canvas-pattern) 75%),
        linear-gradient(-45deg, transparent 75%, var(--ed-canvas-pattern) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--ed-panel);
    border-bottom: 1px solid var(--ed-panel-border);
    flex-wrap: wrap;
}
.canvas-toolbar__sep {
    width: 1px;
    height: 24px;
    background: var(--ed-panel-border);
    margin: 0 0.125rem;
}
.canvas-toolbar__spacer { flex: 1; min-width: 0.5rem; }
.canvas-toolbar__indicator {
    font-size: 0.8rem;
    color: var(--ed-muted);
    min-width: 88px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--ed-bg);
    border: 1px solid var(--ed-panel-border);
    border-radius: 8px;
    padding: 0.125rem;
}
.zoom-controls__label {
    min-width: 52px;
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem !important;
    border: none !important;
    background: transparent !important;
}

.editor-canvas-scroller {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.editor-page-frame {
    transform-origin: center center;
    transition: transform 0.15s ease;
}
.editor-page.export-mode::before,
.is-exporting .editor-page::before { display: none !important; }
.is-exporting .page-element.selected { outline: none !important; }
.is-exporting .resize-handle { display: none !important; }

.editor-page {
    width: 420px;
    aspect-ratio: 210 / 297;
    background: #6366f1;
    border-radius: 4px;
    box-shadow: var(--ed-page-shadow);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    --page-accent: #6366f1;
    transition: background 0.2s ease;
}

.canvas-hint {
    text-align: center;
    font-size: 0.68rem;
    color: var(--ed-muted);
    padding: 0.5rem 1rem;
    background: var(--ed-panel);
    border-top: 1px solid var(--ed-panel-border);
}
.canvas-hint kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    margin: 0 0.1rem;
    font-size: 0.62rem;
    font-family: inherit;
    background: var(--ed-kbd-bg);
    border: 1px solid var(--ed-kbd-border);
    border-radius: 4px;
}

/* ─── Sayfa öğeleri ───────────────────────────────────────── */
.page-element {
    position: absolute;
    cursor: move;
    user-select: none;
    touch-action: none;
}
.page-element.selected {
    outline: 2px solid var(--ed-primary);
    outline-offset: 2px;
}
.page-element .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--ed-primary);
    border: 2px solid #fff;
    border-radius: 50%;
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
    display: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.page-element.selected .resize-handle { display: block; }

.el-photo { overflow: hidden; border-radius: 4px; background: #e2e8f0; }
.el-photo img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.el-text { padding: 4px 6px; word-break: break-word; line-height: 1.3; min-height: 28px; min-width: 32px; }
.el-text.style-heading { font-family: var(--ed-display); font-size: 1.4rem; font-weight: 700; color: #1e293b; }
.el-text.style-subheading { font-family: var(--ed-display); font-size: 1rem; font-weight: 600; color: #334155; }
.el-text.style-body { font-size: 0.85rem; color: #475569; }
.el-text.style-caption { font-size: 0.7rem; color: #94a3b8; font-style: italic; }
.page-dark-bg .el-text.style-heading { color: #fff; }
.page-dark-bg .el-text.style-subheading { color: #f1f5f9; }
.page-dark-bg .el-text.style-body { color: #e2e8f0; }
.page-dark-bg .el-text.style-caption { color: #cbd5e1; }
.page-dark-bg .el-sticker .icon { color: #fff; stroke: #fff; }
.el-sticker { line-height: 1; cursor: move; color: var(--page-accent, #6366f1); }
.el-sticker .icon { color: inherit; stroke: currentColor; }
.el-photo__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
}

/* ─── Renkler ─────────────────────────────────────────────── */
.color-row { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; }
.color-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.color-dot:hover,
.color-dot.active { border-color: var(--ed-color-ring); transform: scale(1.08); }

.editor-label-hint {
    font-weight: 400;
    font-size: 0.62rem;
    color: var(--ed-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.cmyk-info {
    margin: 0.5rem 0 0;
    font-size: 0.72rem;
    color: var(--ed-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}
.cmyk-warn {
    margin: 0.35rem 0 0;
    font-size: 0.68rem;
    color: var(--ed-warn);
    line-height: 1.4;
}
.color-picker-input {
    width: 30px;
    height: 30px;
    border: 2px solid var(--ed-panel-border);
    padding: 0;
    background: none;
    cursor: pointer;
    border-radius: 50%;
}

/* ─── İkonlar & katmanlar ─────────────────────────────────── */
.sticker-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.375rem; }
.sticker-pick {
    padding: 0.4rem;
    background: #ffffff;
    border: 1px solid var(--ed-panel-border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.sticker-pick .icon {
    color: #1e293b;
    stroke: currentColor;
}
.sticker-pick:hover,
.sticker-pick.active {
    border-color: var(--ed-primary);
    background: #f0fdfa;
}
.sticker-pick.active .icon {
    color: var(--ed-primary-dark);
}

.layer-list { list-style: none; }
.layer-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-bottom: 0.2rem;
}
.layer-item:hover { background: var(--ed-hover); }
.layer-item.active { background: var(--ed-active); color: var(--ed-primary); font-weight: 600; }
.layer-item__icon { flex-shrink: 0; opacity: 0.85; }

/* ─── Overlay ───────────────────────────────────────────────── */
.editor-overlay[hidden] { display: none !important; }
.editor-overlay {
    position: fixed;
    inset: 0;
    background: var(--ed-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.editor-overlay__box {
    background: var(--ed-panel);
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--ed-panel-border);
    box-shadow: var(--ed-page-shadow);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ed-panel-border);
    border-top-color: var(--ed-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 1200px) {
    :root { --ed-panel-w: 240px; }
    .editor-btn__label { display: none; }
}
@media (max-width: 900px) {
    .editor-body { flex-direction: column; }
    .editor-panel {
        width: 100% !important;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--ed-panel-border);
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    .editor-panel.is-collapsed { max-height: 0; padding: 0; }
    .editor-panel--right { border-left: none; }
    .editor-page { width: min(420px, 92vw); }
    .canvas-toolbar__spacer { display: none; }
    .editor-badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
    .editor-panel,
    .editor-page-frame { transition: none; }
}
