/* =====================================================
   MDF Kesim Optimizasyonu — Plugin CSS v2
   ===================================================== */

/* Reset */
#mdf-app, #mdf-app * { box-sizing: border-box; margin: 0; padding: 0; }

/* ── App Shell ───────────────────────────────────────── */
.mdf-app {
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    border: 1px solid #dde1e7;
    border-radius: 10px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    color: #1c1c1e;
    min-height: 640px;
    position: relative;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

/* ── Top Bar ─────────────────────────────────────────── */
.mdf-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 16px;
    flex-wrap: wrap; gap: 8px;
    min-height: 48px;
}
.mdf-topbar-left  { display: flex; align-items: center; gap: 9px; }
.mdf-topbar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mdf-title        { font-size: 14px; font-weight: 700; color: #111827; letter-spacing: -.01em; }
.mdf-badge {
    font-size: 10px; font-weight: 600;
    background: #eff6ff; color: #1d4ed8;
    padding: 2px 8px; border-radius: 20px;
    border: 1px solid #bfdbfe;
}
.mdf-lbl { font-size: 11px; color: #6b7280; white-space: nowrap; }

/* ── Sheet Buttons (top) ─────────────────────────────── */
.mdf-sheet-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.mdf-sheet-btn {
    font-size: 11px; font-weight: 500;
    padding: 4px 10px;
    border: 1px solid #d1d5db; border-radius: 5px;
    background: #fff; color: #374151; cursor: pointer;
    transition: all .12s;
}
.mdf-sheet-btn:hover   { background: #f3f4f6; border-color: #9ca3af; }
.mdf-sheet-btn.on      { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }

/* ── Main Grid ───────────────────────────────────────── */
.mdf-main {
    display: grid;
    grid-template-columns: 268px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */
.mdf-sidebar {
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px 10px 12px;
    overflow-y: auto;
}
.mdf-panel {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 11px;
}
.mdf-panel-grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mdf-ph {
    font-size: 10px; font-weight: 700;
    color: #6b7280; text-transform: uppercase; letter-spacing: .06em;
    margin-bottom: 9px;
}
.mdf-ph-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.mdf-ph-row .mdf-ph { margin-bottom: 0; }
.mdf-cnt {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px;
    background: #e0e7ff; color: #3730a3;
    border-radius: 50%; font-size: 10px; font-weight: 700;
    margin-left: 5px; vertical-align: middle;
}

/* ── Form ────────────────────────────────────────────── */
.mdf-ig3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.mdf-ig2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mdf-fld { display: flex; flex-direction: column; gap: 3px; }
.mdf-fld label { font-size: 11px; color: #6b7280; }
.mdf-fld input,
.mdf-fld textarea {
    font-size: 12px; padding: 5px 8px;
    border: 1px solid #d1d5db; border-radius: 5px;
    background: #fff; color: #111827; width: 100%;
    transition: border-color .12s, box-shadow .12s;
    font-family: inherit;
}
.mdf-fld input:focus {
    outline: none; border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── Buttons ─────────────────────────────────────────── */
.mdf-btn {
    font-size: 12px; font-weight: 500;
    padding: 6px 12px;
    border: 1px solid #d1d5db; border-radius: 6px;
    background: #fff; color: #374151; cursor: pointer;
    transition: all .12s; line-height: 1.4; white-space: nowrap;
    font-family: inherit;
}
.mdf-btn:hover   { background: #f3f4f6; border-color: #9ca3af; }
.mdf-btn:active  { transform: scale(.97); }
.mdf-btn-xs      { padding: 4px 8px; font-size: 11px; }
.mdf-flex1       { flex: 1; }
.mdf-btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.mdf-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.mdf-btn-ai      { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.mdf-btn-ai:hover { background: #6d28d9; border-color: #6d28d9; }
.mdf-danger      { color: #dc2626; border-color: #fca5a5; }
.mdf-danger:hover { background: #fef2f2; }
.mdf-row         { display: flex; gap: 6px; align-items: center; }
.mdf-ops         { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* ── Parts List ─────────────────────────────────────── */
.mdf-parts {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
    min-height: 0; max-height: 260px;
}
.mdf-part {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 9px;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
    font-size: 12px; transition: border-color .1s;
}
.mdf-part:hover { border-color: #9ca3af; }
.mdf-pdot  { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.mdf-pinfo { flex: 1; min-width: 0; }
.mdf-pdim  { font-weight: 600; color: #111827; }
.mdf-pmeta { font-size: 11px; color: #9ca3af; }
.mdf-prm {
    font-size: 14px; line-height: 1; cursor: pointer;
    color: #9ca3af; padding: 2px 4px; border-radius: 3px;
    background: none; border: none; font-family: inherit;
    transition: color .1s, background .1s;
}
.mdf-prm:hover { color: #dc2626; background: #fef2f2; }
.mdf-empty { font-size: 12px; color: #9ca3af; text-align: center; padding: 20px 8px; line-height: 1.7; }
.mdf-hint  { font-size: 11px; color: #9ca3af; line-height: 1.5; }
.mdf-hint a, .mdf-hint code { color: #3b82f6; }
.mdf-hint code { background: #f0f0f0; padding: 1px 4px; border-radius: 3px; font-family: monospace; }

/* ── Canvas Column ───────────────────────────────────── */
.mdf-canvas-col {
    display: flex; flex-direction: column;
    background: #f0f2f5; overflow: hidden;
}
.mdf-ctoolbar {
    display: flex; align-items: center; gap: 8px;
    background: #fff; border-bottom: 1px solid #e5e7eb;
    padding: 7px 14px; flex-wrap: wrap; min-height: 42px;
}
.mdf-tabs  { display: flex; }
.mdf-tab {
    font-size: 12px; font-weight: 500;
    padding: 6px 13px; cursor: pointer; color: #6b7280;
    border: none; background: none; font-family: inherit;
    border-bottom: 2px solid transparent; transition: all .12s;
}
.mdf-tab:hover    { color: #2563eb; }
.mdf-tab-on       { color: #2563eb; border-bottom-color: #2563eb; }
.mdf-stabs-wrap   { display: flex; align-items: center; gap: 5px; margin-left: auto; flex-wrap: wrap; }
.mdf-stabs        { display: flex; gap: 3px; flex-wrap: wrap; }
.mdf-stab {
    font-size: 11px; font-weight: 500;
    padding: 3px 10px; border: 1px solid #d1d5db;
    border-radius: 4px; cursor: pointer; color: #4b5563;
    background: #fff; transition: all .12s;
}
.mdf-stab.on { background: #2563eb; color: #fff; border-color: #2563eb; }
.mdf-zoom-row { display: flex; align-items: center; gap: 3px; }

/* ── Canvas Pane ─────────────────────────────────────── */
.mdf-cpane { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.mdf-cscroll { flex: 1; overflow: auto; padding: 14px; }
.mdf-outer {
    display: inline-block; position: relative;
    transform-origin: top left;
}
#mdfCanvas {
    display: block;
    border: 1.5px solid #9ca3af; border-radius: 5px;
    background: #fff; cursor: crosshair;
    box-shadow: 0 1px 6px rgba(0,0,0,.1);
}

/* ── Drag Layer ──────────────────────────────────────── */
.mdf-dl {
    position: absolute; top: 0; left: 0;
    pointer-events: none; overflow: visible;
}
.mdf-dp {
    position: absolute; cursor: grab; pointer-events: all;
    border: 2px solid transparent; border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    transition: border-color .1s, box-shadow .1s;
}
.mdf-dp:hover {
    border-color: rgba(255,255,255,.9);
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
    z-index: 10;
}
.mdf-dp.drag {
    cursor: grabbing; opacity: .88; z-index: 99;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.mdf-dp-lbl {
    font-size: 10px; font-weight: 700;
    color: rgba(255,255,255,.95);
    text-shadow: 0 1px 3px rgba(0,0,0,.6);
    pointer-events: none; text-align: center;
    padding: 2px; line-height: 1.25; overflow: hidden; max-width: 100%;
}
.mdf-dp-rot {
    position: absolute; bottom: 2px; right: 3px;
    font-size: 9px; color: rgba(255,255,255,.7);
    pointer-events: none;
}
.mdf-dp.overlap { outline: 2px solid #dc2626; animation: mdf-shake .3s; }
@keyframes mdf-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-3px); }
    75%      { transform: translateX(3px); }
}

.mdf-warn {
    margin: 5px 14px 0;
    font-size: 12px; color: #92400e;
    background: #fffbeb; border: 1px solid #fcd34d;
    border-radius: 6px; padding: 8px 12px;
}

/* ── AI Pane ─────────────────────────────────────────── */
.mdf-aipane  { padding: 14px; overflow: auto; }
.mdf-aibox {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 16px; font-size: 13px; line-height: 1.75;
    min-height: 200px; white-space: pre-wrap; color: #111827;
}
.mdf-aibox h3 { font-size: 14px; font-weight: 700; color: #7c3aed; margin-bottom: 10px; }
.mdf-ailoading { color: #6b7280; display: flex; align-items: center; gap: 8px; padding: 10px; }
.mdf-spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid #e5e7eb; border-top-color: #7c3aed;
    animation: mdf-spin .7s linear infinite; flex-shrink: 0;
}
@keyframes mdf-spin { to { transform: rotate(360deg); } }

/* ── Stats Bar ───────────────────────────────────────── */
.mdf-stats {
    display: flex; flex-wrap: wrap;
    background: #fff; border-top: 1px solid #e5e7eb;
    min-height: 50px;
}
.mdf-s {
    display: flex; flex-direction: column; gap: 2px;
    padding: 9px 14px; border-right: 1px solid #f3f4f6;
    min-width: 90px;
}
.mdf-s span   { font-size: 10px; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; }
.mdf-s strong { font-size: 16px; font-weight: 700; color: #111827; }
.mdf-s strong.ok { color: #16a34a; }
.mdf-s strong.ng { color: #dc2626; }

/* ── Context Menu ────────────────────────────────────── */
.mdf-cm {
    position: fixed; z-index: 99999;
    background: #fff; border: 1px solid #d1d5db;
    border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.14);
    min-width: 165px; overflow: hidden; font-size: 12px;
}
.mdf-cm button {
    display: block; width: 100%;
    padding: 9px 14px; text-align: left;
    background: none; border: none; cursor: pointer;
    color: #111827; font-size: 12px; font-family: inherit;
    transition: background .1s;
}
.mdf-cm button:hover { background: #f3f4f6; }
.mdf-cm button.ng    { color: #dc2626; }
.mdf-cm button.ng:hover { background: #fef2f2; }
.mdf-cm hr { border: none; border-top: 1px solid #f3f4f6; margin: 3px 0; }

/* ── Modals ──────────────────────────────────────────── */
.mdf-overlay {
    position: fixed; inset: 0; z-index: 999999;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
}
.mdf-modal {
    background: #fff; border-radius: 10px;
    min-width: 340px; max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0,0,0,.22); overflow: hidden;
}
.mdf-mh {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 16px; font-weight: 700; font-size: 14px;
    background: #f9fafb; border-bottom: 1px solid #e5e7eb;
}
.mdf-mh button {
    font-size: 18px; cursor: pointer; color: #6b7280;
    background: none; border: none; line-height: 1;
    padding: 2px 6px; border-radius: 4px; font-family: inherit;
}
.mdf-mh button:hover { background: #f3f4f6; color: #dc2626; }
.mdf-mb {
    padding: 14px 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.mdf-mb textarea {
    width: 100%; resize: vertical; font-size: 12px;
    font-family: "Courier New", monospace; padding: 8px;
    border: 1px solid #d1d5db; border-radius: 6px; color: #111827;
    background: #f9fafb;
}
.mdf-mf {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 11px 16px; border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 680px) {
    .mdf-main { grid-template-columns: 1fr; }
    .mdf-sidebar { max-height: 340px; border-right: none; border-bottom: 1px solid #e5e7eb; }
    .mdf-ops { grid-template-columns: 1fr; }
    .mdf-ig3 { grid-template-columns: 1fr 1fr; }
    .mdf-s   { min-width: 72px; padding: 7px 10px; }
}
