/* ===== Genel Sıfırlama ve Düzen ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1e1e2e;
    color: #cdd6f4;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Araç Çubuğu ===== */
#toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: #181825;
    border-bottom: 1px solid #313244;
    flex-wrap: wrap;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
    padding-right: 16px;
    border-right: 1px solid #45475a;
}

.app-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.app-title {
    font-size: 13px;
    font-weight: 700;
    color: #89b4fa;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-group label {
    font-size: 12px;
    color: #a6adc8;
    white-space: nowrap;
}

.toolbar-group input[type="file"] {
    font-size: 12px;
    color: #cdd6f4;
    max-width: 220px;
}

button {
    padding: 6px 14px;
    border: 1px solid #45475a;
    border-radius: 6px;
    background: #313244;
    color: #cdd6f4;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

button:hover {
    background: #45475a;
    border-color: #585b70;
}

.btn-primary {
    background: #89b4fa;
    color: #1e1e2e;
    border-color: #89b4fa;
    font-weight: 600;
}

.btn-primary:hover {
    background: #74c7ec;
    border-color: #74c7ec;
}

/* ===== Ana Kapsayıcı ===== */
#main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ===== Sol Panel ===== */
#left-panel {
    width: 240px;
    min-width: 200px;
    background: #181825;
    border-right: 1px solid #313244;
    overflow-y: auto;
    padding: 8px;
}

#left-panel h3 {
    font-size: 14px;
    padding: 8px 4px;
    color: #89b4fa;
    border-bottom: 1px solid #313244;
    margin-bottom: 8px;
}

.panel-section {
    margin-bottom: 4px;
}

.section-header {
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #f5c2e7;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.section-header:hover {
    background: #313244;
}

.section-body {
    padding: 4px 0 4px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.section-body.collapsed {
    display: none;
}

.insert-btn {
    text-align: left;
    padding: 5px 10px;
    font-size: 11px;
    border: 1px solid transparent;
    background: transparent;
    color: #bac2de;
    border-radius: 4px;
    flex: 1;
    min-width: 0;
}

.insert-btn:hover {
    background: #313244;
    border-color: #45475a;
    color: #cdd6f4;
}

/* ===== Alan Checkbox Satırları ===== */
.field-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-check {
    width: 13px;
    height: 13px;
    accent-color: #a6e3a1;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.field-check:checked + .insert-btn {
    color: #a6e3a1;
}

.insert-btn.logo-btn {
    color: #a6e3a1;
    font-weight: 600;
}

.insert-btn.template-btn {
    color: #fab387;
    font-weight: 600;
}

.insert-btn.spacer-btn {
    color: #89b4fa;
    font-weight: 600;
}

/* ===== Orta Panel ===== */
#center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Sekmeler ===== */
#tabs {
    display: flex;
    background: #181825;
    border-bottom: 1px solid #313244;
}

.tab {
    padding: 8px 20px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #6c7086;
    font-size: 13px;
}

.tab.active {
    color: #cdd6f4;
    border-bottom: 2px solid #89b4fa;
    background: #1e1e2e;
}

.tab:hover {
    background: #313244;
    color: #cdd6f4;
}

/* ===== Sekme İçeriği ===== */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Editör */
#editor-view, #preview-view {
    flex: 1;
}

#preview-view {
    display: none;
}

#preview-view.active {
    display: flex;
    flex-direction: column;
}

.CodeMirror {
    height: 100% !important;
    font-size: 13px;
    font-family: 'Consolas', 'Courier New', monospace;
}

/* Önizleme */
#previewFrame, #previewFrameSplit {
    width: 100%;
    flex: 1;
    border: none;
    background: #fff;
}

/* Bölünmüş Görünüm */
#split-view {
    flex-direction: row !important;
}

.split-editor {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-right: 2px solid #313244;
}

.split-editor .CodeMirror {
    height: 100% !important;
}

.split-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== Diyalog Penceresi ===== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1e1e2e;
    border: 1px solid #45475a;
    border-radius: 10px;
    padding: 24px;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-content h3 {
    color: #89b4fa;
}

.modal-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.modal-actions label {
    font-size: 12px;
    color: #a6adc8;
}

.modal-actions input[type="number"] {
    width: 70px;
    padding: 4px 6px;
    border: 1px solid #45475a;
    border-radius: 4px;
    background: #313244;
    color: #cdd6f4;
}

/* ===== Durum Çubuğu ===== */
#statusbar {
    display: flex;
    justify-content: space-between;
    padding: 4px 16px;
    background: #181825;
    border-top: 1px solid #313244;
    font-size: 11px;
    color: #6c7086;
}

#autoSaveStatus {
    color: #a6adc8;
    font-style: italic;
}

.developer-credit {
    color: #585b70;
    font-size: 10px;
    font-style: italic;
}

/* ===== Kurtarma Çubuğu ===== */
#recoveryBar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #f9e2af;
    color: #1e1e2e;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid #e0c97f;
}

.btn-recovery {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    background: #40a02b;
    color: #fff;
}

.btn-recovery:hover {
    background: #2d8a1a;
}

.btn-recovery-discard {
    background: #d20f39;
}

.btn-recovery-discard:hover {
    background: #b00c30;
}

/* ===== Geri Al / İleri Al ===== */
#btnUndo, #btnRedo {
    font-weight: 600;
}

#btnUndo:hover, #btnRedo:hover {
    background: #585b70;
}

/* ===== İnceleme Butonu ===== */
.btn-inspect {
    background: #313244;
    color: #cdd6f4;
    border-color: #45475a;
}

.btn-inspect.active {
    background: #f38ba8;
    color: #1e1e2e;
    border-color: #f38ba8;
    font-weight: 600;
}

/* ===== Önizleme Sarmalayıcı (bırakma katmanı) ===== */
.preview-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-drop-overlay {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10;
    cursor: copy;
}

.preview-drop-overlay.active {
    display: block;
    background: rgba(137, 180, 250, 0.06);
    border: 2px dashed rgba(137, 180, 250, 0.4);
}

.preview-drop-overlay.drop-hover {
    background: rgba(137, 180, 250, 0.12);
    border-color: #89b4fa;
}

/* ===== Sürükleme İpucu ===== */
.drag-hint {
    font-size: 10px;
    color: #a6adc8;
    padding: 4px 8px 8px;
    border-bottom: 1px solid #313244;
    margin-bottom: 6px;
    line-height: 1.4;
}

/* ===== Sürükle ve Bırak ===== */
.insert-btn[draggable="true"] {
    cursor: grab;
}

.insert-btn[draggable="true"]:active {
    cursor: grabbing;
}

.insert-btn.dragging {
    opacity: 0.4;
    outline: 1px dashed #89b4fa;
}

.CodeMirror.cm-awaiting-drop {
    outline: 2px dashed rgba(137, 180, 250, 0.35);
    outline-offset: -2px;
}

.CodeMirror.cm-drop-target {
    outline: 2px solid #89b4fa;
    outline-offset: -2px;
    background: rgba(137, 180, 250, 0.03);
}

.cm-drop-line {
    background: rgba(137, 180, 250, 0.18) !important;
    border-left: 3px solid #89b4fa !important;
}

/* ===== İnceleme Vurgusu ===== */
.cm-inspect-line {
    background: rgba(244, 67, 54, 0.10) !important;
    border-left: 3px solid #f44336 !important;
}

/* ===== Örnek Dosya Seçiciler ===== */
#sampleXsltSelect,
#sampleXmlSelect {
    padding: 4px 8px;
    border: 1px solid #45475a;
    border-radius: 4px;
    background: #313244;
    color: #cdd6f4;
    font-size: 12px;
    cursor: pointer;
    max-width: 220px;
}

#sampleXsltSelect:hover,
#sampleXmlSelect:hover {
    border-color: #89b4fa;
}

#sampleXsltSelect:focus,
#sampleXmlSelect:focus {
    outline: none;
    border-color: #89b4fa;
    box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.2);
}

/* ===== Hizalama Seçici ===== */
.align-picker {
    display: flex;
    gap: 4px;
}

.align-btn {
    width: 36px;
    height: 32px;
    padding: 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #45475a;
    border-radius: 4px;
    background: #313244;
    color: #cdd6f4;
    cursor: pointer;
}

.align-btn.active {
    background: #89b4fa;
    color: #1e1e2e;
    border-color: #89b4fa;
}

.align-btn:hover:not(.active) {
    background: #45475a;
}

/* ===== Düzen Rehberi Butonu ===== */
.btn-guide {
    background: #f5c2e7;
    color: #1e1e2e;
    border-color: #f5c2e7;
    font-weight: 600;
}

.btn-guide:hover {
    background: #f38ba8;
    border-color: #f38ba8;
}

/* ===== Düzen Rehberi Penceresi ===== */
.layout-guide-content {
    background: #1e1e2e;
    border: 1px solid #45475a;
    border-radius: 12px;
    padding: 28px;
    min-width: 560px;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.layout-guide-content h3 {
    color: #f5c2e7;
    font-size: 16px;
    text-align: center;
}

.guide-hint {
    text-align: center;
    font-size: 12px;
    color: #a6adc8;
    line-height: 1.5;
}

.invoice-wireframe {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 2px solid #45475a;
    border-radius: 8px;
    padding: 10px;
    background: #11111b;
}

.wf-row {
    display: flex;
    gap: 6px;
}

.wf-header-row .wf-cell {
    flex: 1;
}

.wf-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px dashed #585b70;
    border-radius: 6px;
    background: #181825;
    transition: all 0.2s;
}

.wf-cell.wf-full {
    flex: 1;
}

.wf-cell.wf-clickable {
    cursor: pointer;
}

.wf-cell.wf-clickable:hover {
    border-color: #89b4fa;
    background: #313244;
    transform: scale(1.02);
}

.wf-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.wf-label {
    font-size: 12px;
    color: #cdd6f4;
    font-weight: 500;
}

.wf-large .wf-cell {
    min-height: 60px;
}

/* ===== Kaydırma Çubuğu ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #181825; }
::-webkit-scrollbar-thumb { background: #45475a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #585b70; }

/* ===== Alan Seçici Diyaloğu ===== */
.field-picker-content {
    min-width: 480px;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
}

.field-picker-content h3 {
    color: #89b4fa;
    margin: 0 0 12px 0;
    font-size: 15px;
}

.field-picker-sections {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.field-picker-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border: 1px solid #313244;
    border-radius: 6px;
    background: #181825;
}

.field-picker-group-title {
    width: 100%;
    font-size: 11px;
    font-weight: 600;
    color: #f5c2e7;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-picker-item {
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid #45475a;
    border-radius: 4px;
    background: #313244;
    color: #cdd6f4;
    cursor: pointer;
    transition: all 0.15s;
}

.field-picker-item:hover {
    background: #89b4fa;
    color: #1e1e2e;
    border-color: #89b4fa;
}

/* ===== Tablo Diyaloğu ===== */
.table-dialog-content {
    min-width: 480px;
    max-width: 560px;
}

.table-dialog-content h3 {
    color: #89b4fa;
    margin: 0 0 14px 0;
    font-size: 15px;
}

.table-dialog-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.table-dialog-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #a6adc8;
}

.table-dialog-grid input[type="number"],
.table-dialog-grid input[type="text"] {
    width: 70px;
    padding: 4px 6px;
    border: 1px solid #45475a;
    border-radius: 4px;
    background: #313244;
    color: #cdd6f4;
    font-size: 12px;
}

.table-dialog-grid .checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #cdd6f4;
    font-size: 12px;
}

.table-dialog-grid .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #89b4fa;
}

.table-dialog-colors {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.color-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid #313244;
    border-radius: 6px;
    background: #181825;
    flex: 1;
    min-width: 130px;
}

.color-group-title {
    font-size: 11px;
    font-weight: 600;
    color: #f5c2e7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #a6adc8;
}

.color-group input[type="color"] {
    width: 28px;
    height: 24px;
    padding: 0;
    border: 1px solid #45475a;
    border-radius: 3px;
    background: none;
    cursor: pointer;
}

.table-preview-box {
    max-height: 120px;
    overflow: auto;
    border: 1px solid #313244;
    border-radius: 4px;
    padding: 6px;
    margin-bottom: 10px;
    background: #fff;
}
