/* ========== WRAPPER / LAYOUT ========== */
.ape-wrapper {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0f172a; /* dark */
    border-radius: 10px;
    padding: 0;
    border: 1px solid #1f2937;
    color: #e5e7eb;
    max-width: 1200px;          /* पेज के बीच में बॉक्स जैसा */
    margin: 20px auto 40px;     /* नीचे extra space ताकि comments से ना टकराए */
    overflow: hidden;
}

/* ========== TOPBAR ========== */
.ape-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #020617;
    border-bottom: 1px solid #1f2937;
    gap: 8px;
    flex-wrap: wrap;
}

.ape-left, .ape-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ape-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* file select */
.ape-file-btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0b1120;
    font-size: 13px;
    cursor: pointer;
    color: #e5e7eb;
}
.ape-file-btn:hover {
    background: #111827;
}
.ape-file-btn input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.ape-file-name {
    font-size: 12px;
    color: #9ca3af;
    max-width: 220px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* toolbar buttons */
.ape-tool-btn,
.ape-page-footer button {
    border: 1px solid #334155;
    background: #020617;
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #e5e7eb;
}
.ape-tool-btn:hover,
.ape-page-footer button:hover {
    background: #1f2937;
}
.ape-tool-active {
    background: #2563eb;
    color: #f9fafb;
    border-color: #2563eb;
}

/* main orange button */
.ape-primary-btn {
    background: #f97316;
    color: #111827;
    border-radius: 999px;
    padding: 6px 16px;
    border: none;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
}
.ape-primary-btn:hover {
    background: #fb923c;
}
.ape-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ape-zoom-label {
    font-size: 12px;
    min-width: 40px;
    text-align: center;
    color: #cbd5f5;
}

/* ========== MAIN GRID ========== */
.ape-main {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 260px;
    gap: 0;
    min-height: 540px;   /* सिर्फ minimum height */
    height: auto;        /* अब box comments पर नहीं चढ़ेगा */
}

/* ========== SIDEBAR (THUMBS) ========== */
.ape-sidebar {
    border-right: 1px solid #1f2937;
    background: #020617;
    display: flex;
    flex-direction: column;
}
.ape-sidebar-title {
    padding: 8px;
    font-size: 13px;
    border-bottom: 1px solid #111827;
    color: #9ca3af;
}
.ape-thumbs {
    padding: 8px;
    overflow-y: auto;
    max-height: 100%;
}
.ape-thumb-item {
    border: 1px solid transparent;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    padding: 4px;
    background: #020617;
    transition: background 0.15s, border-color 0.15s;
}
.ape-thumb-item:hover {
    background: #0f172a;
}
.ape-thumb-item-active {
    border-color: #2563eb;
    background: #1e293b;
}
.ape-thumb-canvas {
    width: 100%;
    display: block;
    background: #f9fafb;
}

/* ========== VIEWER ========== */
.ape-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;   /* ऊपर से शुरू, नीचे extra जगह नहीं */
    background: radial-gradient(circle at top, #1f2937, #020617);
    position: relative;
    padding: 16px 0 18px;
}
.ape-page-container {
    position: relative;
    background: transparent;
    padding: 12px;
    border-radius: 8px;
    box-shadow:
        0 25px 50px -12px rgba(15, 23, 42, 0.9),
        0 0 0 1px rgba(148, 163, 184, 0.2);
}

/* pdf page white (A4 look) */
/* PDF वाला canvas सफ़ेद */
#apePdfCanvas {
    background: #ffffff;
    display: block;
    border-radius: 4px;
}

/* Fabric.js overlay transparent रहे */
#apeDrawCanvas {
    background: transparent;
    display: block;
    border-radius: 4px;
}

/* Fabric की wrapper div (canvas-container) को PDF के ऊपर चिपका दो */
.canvas-container {
    position: absolute !important;
    left: 12px;
    top: 12px;
    pointer-events: auto;
}

/* page footer */
.ape-page-footer {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: #e5e7eb;
}

/* ========== RIGHT PANEL ========== */
.ape-rightpanel {
    border-left: 1px solid #1f2937;
    background: #020617;
    padding: 14px 12px;
}
.ape-panel-box h3 {
    margin-top: 0;
    font-size: 15px;
    color: #e5e7eb;
}
.ape-panel-box p,
.ape-panel-box li {
    font-size: 13px;
    color: #9ca3af;
}
.ape-panel-box ul {
    padding-left: 18px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .ape-main {
        grid-template-columns: 1fr;
        grid-template-rows: 120px minmax(0,1fr) 160px;
        height: auto;
    }
    .ape-sidebar {
        order: 1;
        height: 120px;
    }
    .ape-viewer {
        order: 2;
        min-height: 420px;
    }
    .ape-rightpanel {
        order: 3;
    }
}
